Commit Graph

796 Commits

Author SHA1 Message Date
Wolfgang Bumiller
def1d54aa6 various clippy lint fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-16 13:44:42 +02:00
Wolfgang Bumiller
43a25b7713 websocket feature dependency fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 14:59:39 +02:00
Dominik Csapak
7e614ed9eb proxmox/tools/websocket: add WebSocket implementation
uses the existing WebSocketReader and Writer to establish a
two-way communication between an upstream and downstream connection.

The upstream connection sends and receives WebSocket frames, while
the downstream one only receives and sends raw data.

For now we do not support extensions, and only accept the protocol version 13

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 14:09:25 +02:00
Dominik Csapak
02ca323ce5 proxmox/tools/websocket: replace CallBack with a channel
instead of having a callback that we call on a control frame,
use a channel to send the data to a receiver

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 14:07:36 +02:00
Dominik Csapak
025ad876c7 proxmox/tools/websocket: implement send_control_frame for writer
so that we can easily send a control frame to the endpoint

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 13:33:30 +02:00
Dominik Csapak
861a855cdf proxmox/tools/websocket: improve mask_bytes and create_frame interface
by using a Box<[u8]> instead of a vector (we do not need it)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 13:29:43 +02:00
Dominik Csapak
a3faec8322 proxmox/tools/websocket: use io::Error and Result explicitely
and add a helper struct for the ReadResult
(so that the types are properly documented)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 13:29:29 +02:00
Dominik Csapak
ca7333cb92 proxmox/tools/websocket: correctly return eof
only return Ok(0) when the upstream reader did return that, not when
we have no data in the buffer, else the downstream reader believes
we are EOF (even if we are not)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 12:37:15 +02:00
Dominik Csapak
859c195a0b proxmox/tools/websocket: use ready macro for WebSocketWriter
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 12:35:49 +02:00
Dominik Csapak
d90e0afdcb proxmox/tools/byte_buffer: impl Default
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 12:33:22 +02:00
Dominik Csapak
5f4eace905 proxmox/tools/byte_buffer: improve ByteBuffer interface
by implementing Deref and DerefMut, renaming consume to 'remove_data'
adapt the usage inside of websocket (we did not use it anywhere else for now)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-15 12:33:18 +02:00
Wolfgang Bumiller
080b3b4329 tools::common_regex: add IPRE_BRACKET
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-14 09:48:55 +02:00
Wolfgang Bumiller
5eaadc1219 bump proxmox version to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 11:04:20 +02:00
Wolfgang Bumiller
2904b622be bump api macro to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 11:04:20 +02:00
Wolfgang Bumiller
e3800fb853 api-macro: test using return schemas within return objects
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 11:04:00 +02:00
Wolfgang Bumiller
0ce4c9eeb8 api-macro: reference consistency
API_RETURN_* and API_PARAMETER_* schemas are no references
anymore to allow using them as external schemas via the
`"schema"` key inside object schemas inside the `#[api]`
macro.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 10:56:29 +02:00
Wolfgang Bumiller
59467a11d6 completion: COMP_POINT is a codepoint count not a byte index
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-09 14:01:03 +02:00
Wolfgang Bumiller
aea0abf838 compile fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 14:45:15 +02:00
Wolfgang Bumiller
4f05a5d9f7 add websocket (default-)feature, make futures optional
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 12:06:34 +02:00
Wolfgang Bumiller
e65cc32cb8 make the proxmox crate without default features again
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 11:41:49 +02:00
Wolfgang Bumiller
ce859656ec some minor clippy lint cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:44:50 +02:00
Wolfgang Bumiller
2aeeb83203 ByteBuffer: use T: AsyncRead, not AsyncReadExt
it's just weird otherwise

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:37:26 +02:00
Wolfgang Bumiller
7856139d72 test cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:37:10 +02:00
Wolfgang Bumiller
a45555df07 ByteBuffer: don't require Sized on Read references
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:33:35 +02:00
Wolfgang Bumiller
8bae897ff6 ByteBuffer: actually test the doc comment code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:32:16 +02:00
Wolfgang Bumiller
816015ed01 ByteBuffer: skip the temporary Vec
The docs say `into_boxed_slice()` "drops" excess capacity,
but doesn't specify whether that just means it becomes
inaccessible or the vector potentially reallocates to the
exact size.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-07 09:27:17 +02:00
Dietmar Maurer
f8ea74dfc1 bump version to 0.1.42-1 2020-07-03 13:01:48 +02:00
Dominik Csapak
68bddb9fed sys/linux/pty: add examples and docs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:59 +02:00
Dominik Csapak
c734a627a8 tools/byte_buffer: add examples and docs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:50 +02:00
Dominik Csapak
6fffca783e tools/websocket: add examples and docs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:33 +02:00
Dominik Csapak
dfcb50b690 tools/websocket: improve traits for WebSocketReader
by dropping unecessary trais for R
and impl Sync for ReaderState when R implements Sync

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:24 +02:00
Dominik Csapak
521b26d6a2 tools/websocket: require writer to be Unpin
so we can safely pin/unpin it

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:58:11 +02:00
Dominik Csapak
556df80841 tools/websocket: make mask not a reference
so we can drop the dereferencing, also use shorter syntax for mask_bit

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 12:57:56 +02:00
Dominik Csapak
d700327b8d tools: add Websocket helper
for now there is a helper for Reading and Writing
still missing is a utility for the handshake/accepting a connection

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 06:34:58 +02:00
Dominik Csapak
f74f33671a sys/linux: add PTY helper
for creating a PTY and make the secondary part a
controlling terminal for a child process

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 06:26:46 +02:00
Dominik Csapak
2cdddb8271 tools: add ByteBuffer
this is a Buffer struct that holds u8 and has convenience methods
for reading onto the back and consuming from the front

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-03 06:26:18 +02:00
Wolfgang Bumiller
5f9f3f373f cleanup: libc has 'getrandom' since 0.2.59
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-01 10:54:14 +02:00
Dietmar Maurer
2b6b94dd3a bump proxmox to 0.1.41-1 2020-06-26 10:36:35 +02:00
Dominik Csapak
d7165108cb api/router: percent decode the components of the uri
those can contain percent encoded values, so we have to decode them
before lookin up the path

this is especially important for the 'MatchAll' branch
when the parameter can contain some reserved characters

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-26 09:17:35 +02:00
Wolfgang Bumiller
53e7e76b5f bump proxmox to 0.1.40-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 13:56:00 +02:00
Wolfgang Bumiller
2eaea4b9ea tools: add mmap helper
Mmap<T> acts like a slice of `T`s, inhereting its `Send` and
`Sync` traits

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 13:54:12 +02:00
Wolfgang Bumiller
3516c9e2ec AsHex Display helper
This way we can use
    println!("something: {}", AsHex(bytes));

without having to turn them into an allocated string first.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-12 11:18:41 +02:00
Wolfgang Bumiller
c927b5ebba add TtyOutpu helper and use it for read_password
This way read_password() will not write the prompt into
stdout if stdout was redirected into a file, but instead
opens `/dev/tty`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-09 11:16:41 +02:00
Dietmar Maurer
620775d267 bump version to 0.1.39-1 2020-06-05 07:27:10 +02:00
Dominik Csapak
72974335a4 fix Permission::Privilege path check
when checking a path, we only pushed the components to the checked value
that would contain a parameter and not fixed ones

e.g. from the path components (with params datastore="foo")
["datastore", "{datastore}"]

only ["foo"] was given to the lookup_privs function
instead of ["datastore", "foo"]

this fixes an issue where e.g. a prune on /datastore/foo would fail
for a user that has the role DatastorePowerUser on /datastore (with
propagate) or /datastore/foo

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-05 07:24:15 +02:00
Dominik Csapak
2ca2559c94 add tests for check_api_permission
add tests for check_api_permission and many Permission combinations
this test fails for now and will be fixed with the next commit

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-05 07:14:50 +02:00
Dietmar Maurer
de2354bc3c bump version to 0.1.38-1 2020-05-28 09:51:42 +02:00
Dietmar Maurer
7b24c384b1 proxmox/src/tools/fs.rs: add additional helpers to get file contents 2020-05-28 09:49:45 +02:00
Dietmar Maurer
f42c189ee7 bump version toö 0.1.37-1 2020-05-26 12:55:04 +02:00
Dominik Csapak
60335cded0 proxmox: add string_as_base64 serde (de)serializer
this can be used to automatically convert string fields to base64

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-26 12:53:52 +02:00