Commit Graph

758 Commits

Author SHA1 Message Date
Wolfgang Bumiller
c8e6462cc7 bump proxmox version to 0.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 09:37:02 +02:00
Wolfgang Bumiller
7d3ffe9b8d add http_bail macro
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 09:34:25 +02:00
Wolfgang Bumiller
c4febcd773 http_err macro: imply format!()
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 09:26:22 +02:00
Wolfgang Bumiller
f165dee496 switch to using mod.rs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-28 15:11:38 +02:00
Stefan Reiter
0c868c7dd9 fix #2882: correctly parse optional fields from mountinfo
As per the linux kernel documentation[0], the "optional fields" (called
"tags" in our parser) are not comma-separated, but are a variable number
(0 or more) of space-separated fields, always followed by a dash to mark
the end.

Fix the /proc/<pid>/mountinfo parser to correctly parse these and add
test cases (l3 is the line that produced the original warning from the
bug report).

[0] https://www.kernel.org/doc/html/latest/filesystems/proc.html#proc-pid-mountinfo-information-about-mounts

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-07-28 07:20:43 +02:00
Thomas Lamprecht
459a99d150 bump proxmox version to 0.2.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-23 12:04:12 +02:00
Dominik Csapak
78a0a0ee1d proxmox/tools/byte_buffer: improve read_from example
'norun' was not a valid attribute, so cargo doc ignored it completely

instead, write a proper example that can be compiled

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-17 14:35:02 +02:00
Dominik Csapak
6f125bc70b proxmox/tools/websocket: fix some clippy warnings
* reformat docs
* use &mut [u8] instead of Box<[u8]> (conversion can be done automatically)
* use:
    let foo = if condition { A } else { B };
  instead of matching on a boolean condition
* rename WaitingForData to Receiving so that not all
  variants of the enum end with Data

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-17 14:35:00 +02:00
Dominik Csapak
eebacab282 proxmox/tools/websocket: improve error handling
use io_err_other instead of io_format_err and change the Error type
of create_frame from io::Error to WebSocketError

it is not good to redefine the ErrorKinds of io::Error, since
the caller probably is not aware of that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-17 14:34:56 +02:00
Dominik Csapak
62461aac4a proxmox/tools/websocket: introduce WebSocketError and use it
this patch introduces a custom WebSocketError, so that we can
detect errors in the websocket protocol and react to it in the
right way

the channel now sends a Result<(OpCode, Box<[u8]>), WebSocketError>
so that we can either react to a control frame, or react to an
errornous data stream (which means sending a close frame
with the appropriate error code)

while at it, change FrameHeader::try_from_bytes to return
Result<Option<FrameHeader>, WebSocketError> instead of a nested
Result with the *guessed* remaining size. This was neither used by
us, nor was it really meaningful, since this can change during the
decode every time new data is read (extensions, mask, payload length, etc.)
so simply returning an Option is enough information for us

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-17 14:34:52 +02:00
Wolfgang Bumiller
a4abaa8b17 api-macro: formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-16 14:13:14 +02:00
Wolfgang Bumiller
debd9f9f4f a lot more clippy lint fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-16 14:11:01 +02:00
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