]>
git.proxmox.com Git - proxmox.git/log
Wolfgang Bumiller [Thu, 19 Nov 2020 08:13:06 +0000 (09:13 +0100)]
tools: refactor hex parsing
deduplicate parsing into a `hex_to_bin_exact`
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Mon, 16 Nov 2020 13:21:45 +0000 (14:21 +0100)]
formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 10 Nov 2020 12:53:06 +0000 (13:53 +0100)]
api-macro: support raw method parameters
Support raw parameter name identifiers (eg. `r#type`)
#[api(
input: {
properties: {
type: {
type: String,
description: "Foo",
},
},
},
)]
fn foo(r#type: String) { code... }
The "r#type" parameter in the fn decl will match the "type"
parameter name in the input property list.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Thomas Lamprecht [Sat, 31 Oct 2020 07:39:17 +0000 (08:39 +0100)]
bump proxmox-api-macro version to 0.2.3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Thu, 5 Nov 2020 11:10:01 +0000 (12:10 +0100)]
proxmox: loosen version requirement to api macro crate
allow updates of minor api-macro releases, breaking ones should get
the first or second version tuple bumped anyway.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Fabian Ebner [Thu, 5 Nov 2020 10:03:01 +0000 (11:03 +0100)]
fix prefix for nested commands
Fixes a regression from commit
f50a627f340ca2ae018079e431edd5a127638458
which resulted in re-using the prefix without sub-commands when calling
handle_simple_command(_future)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Wed, 4 Nov 2020 12:21:41 +0000 (13:21 +0100)]
tfa: make AuthResponse fields public
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Mon, 2 Nov 2020 12:07:38 +0000 (13:07 +0100)]
make u2f registration challenge Deserialize
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Mon, 2 Nov 2020 11:49:47 +0000 (12:49 +0100)]
make u2f attestation certificate optional
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Fri, 30 Oct 2020 14:15:32 +0000 (15:15 +0100)]
bump proxmox to 0.7.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Fri, 30 Oct 2020 14:13:40 +0000 (15:13 +0100)]
totp: rename step to period
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Thu, 29 Oct 2020 14:04:07 +0000 (15:04 +0100)]
bump proxmox to 0.6.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 4 Aug 2020 09:12:14 +0000 (11:12 +0200)]
add proxmox::tools::tfa
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Thu, 29 Oct 2020 13:51:06 +0000 (14:51 +0100)]
test fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fabian Grünbichler [Wed, 28 Oct 2020 11:36:24 +0000 (12:36 +0100)]
rpcenv: rename user to auth_id
since it does no longer store just a userid, but potentially an API
token identifier as well
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Thomas Lamprecht [Mon, 26 Oct 2020 17:29:27 +0000 (18:29 +0100)]
api macro: reuse generated default const for "unwrap_or"
Instead of setting a default value to a const and inside an
.unwrap_or_else closure, lets set it only to the const and reuse that
later in .unwrap_or
To achieve that we move the "unrwap_or" code for param plumbing code generation
a bit later so that we have easy access to the generated const name.
As all this code is related to optional/default-value stuff it does read still
relatively OK with that change, IMO.
This has the advantage of not getting a warning like:
> warning: constant is never used: `API_METHOD_EXAMPLE_FOO_PARAM_DEFAULT_FORCE`
> --> src/api2/node/foo.rs
> |
> XY | force: {
> | ^^^^^
> = note: `#[warn(dead_code)]` on by default
When one has a API endpoint like:
> #[api(
> input: {
> properties: {
> force: {
> type: bool,
> optional: true,
> default: false,
> },
> },
> },
> ...
> )]
> /// Example
> fn example_foo(force: bool) -> Result<(), Error> {
> if force {
> // do something
> }
> Ok(())
> }
It effectively changes the output for optional parameters with a default set
and no Option<T> from
> let p = p.unwrap_or_else(|| #default_value);
to
> let p = p.unwrap_or(#const_name_for_default);
where the "#const_name_for_default" is a pub const with value
"#default_value"
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Tue, 20 Oct 2020 16:46:50 +0000 (18:46 +0200)]
tools fs: fix comment typo and strange glyph
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Wolfgang Bumiller [Mon, 19 Oct 2020 10:32:51 +0000 (12:32 +0200)]
bump proxmox version to 0.5.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Mon, 19 Oct 2020 10:32:37 +0000 (12:32 +0200)]
proxmox::tools::fs: remove deprecated functions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fabian Grünbichler [Mon, 19 Oct 2020 10:11:50 +0000 (12:11 +0200)]
proxmox: bump nix dependency
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Dietmar Maurer [Fri, 16 Oct 2020 08:30:22 +0000 (10:30 +0200)]
bump proxmox version to 0.4.4-1
Thomas Lamprecht [Tue, 13 Oct 2020 09:25:37 +0000 (11:25 +0200)]
api: RPC environment: add client IP getter/setter to trait
This is similar to what we have in PVE and PMG now. Will be used to
set the real client IP for proxied connections.
with a dummy implementation, which avoids the need to implement it
for the CLI or Backup environments, which do not have or care for a
client IP
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Wolfgang Bumiller [Wed, 14 Oct 2020 09:12:30 +0000 (11:12 +0200)]
clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Dietmar Maurer [Thu, 8 Oct 2020 07:00:22 +0000 (09:00 +0200)]
bump proxmox version to 0.4.3-1
Thomas Lamprecht [Tue, 6 Oct 2020 10:08:52 +0000 (12:08 +0200)]
tools: change constnamemap to a more automatic constnamedbitmap
We only used this for the privileges for now, and there it's a
nuisance to alter all bit definitions manually if something is added.
This change makes it count the bits up automatically.
Rename the macro to indicate that this is not a generic name map but
a more specific named bit mapping.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Wolfgang Bumiller [Mon, 5 Oct 2020 10:04:22 +0000 (12:04 +0200)]
formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Mon, 5 Oct 2020 07:16:25 +0000 (09:16 +0200)]
improve error messages in parse_rfc3339
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Fri, 2 Oct 2020 08:00:03 +0000 (10:00 +0200)]
big formatting cleanup
had to be done, sorry not sorry
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Fri, 2 Oct 2020 07:59:52 +0000 (09:59 +0200)]
formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Dominik Csapak [Tue, 29 Sep 2020 14:05:18 +0000 (16:05 +0200)]
proxmox/tools/common_regex: improve IPRE_BRACKET
by disallowing [] around ipv4 adresses (which is not very common)
we did not use this anywhere, so there should not be any compatibility
problem
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Dietmar Maurer [Mon, 28 Sep 2020 08:06:28 +0000 (10:06 +0200)]
bump version to 0.4.2-1
Dietmar Maurer [Mon, 28 Sep 2020 07:16:53 +0000 (09:16 +0200)]
simplify open_file_locked
Dominik Csapak [Fri, 25 Sep 2020 14:13:15 +0000 (16:13 +0200)]
proxmox/tools/fs: create tmpfile helper
by factoring out the code we had in 'replace_file'
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Dominik Csapak [Fri, 25 Sep 2020 14:13:14 +0000 (16:13 +0200)]
proxmox/tools/fs: add shared lock helper
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Wolfgang Bumiller [Tue, 22 Sep 2020 07:01:38 +0000 (09:01 +0200)]
module consistency
tools/time.rs -> tools/time/mod.rs
sys/linux/procfs.rs -> sys/linux/procfs/mod.rs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Thomas Lamprecht [Mon, 21 Sep 2020 14:52:50 +0000 (16:52 +0200)]
d/changelog: fixup email address
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Dietmar Maurer [Mon, 21 Sep 2020 08:22:52 +0000 (10:22 +0200)]
bump version to 0.4.1-1
Dietmar Maurer [Mon, 21 Sep 2020 08:03:48 +0000 (10:03 +0200)]
proxmox/src/tools/email.rs: use slice instead of Vec
Dietmar Maurer [Sat, 19 Sep 2020 04:32:06 +0000 (06:32 +0200)]
bump versions to proxmox 0.4.0 and proxmox-api-macro 0.2.2
Dominik Csapak [Thu, 17 Sep 2020 09:21:05 +0000 (11:21 +0200)]
api-macro: replace ident hashmap with simple find
after benchmarking (again), i found that doing a simple find instead
of saving the inidices for the ident strings in a hashmap has
no real performance impact (the max list size for the properties
are max ~25 at the moment, so this should not be impacting compile
times much) but it is much simpler
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Fabian Grünbichler [Fri, 18 Sep 2020 13:01:07 +0000 (15:01 +0200)]
permissions: introduce UserParam permission
to safely differentiate between checking
- the current user matches some static string
- the current user matches the value in some (path) parameter.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Dietmar Maurer [Thu, 17 Sep 2020 06:33:17 +0000 (08:33 +0200)]
bump version to 0.3.9, api-macro dependency to 0.2.1
Dietmar Maurer [Thu, 17 Sep 2020 06:26:25 +0000 (08:26 +0200)]
bump proxmox-api-macro version to 0.2.1-1
Dominik Csapak [Wed, 16 Sep 2020 12:09:45 +0000 (14:09 +0200)]
api-macro: relax Fieldname rules
by replacing more characters ('.','+') by '_' and prefix them when
it starts with a number
we sometimes need to parse such fields, e.g in serde attributes like
#[serde(rename = "802.3ad")]
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Dominik Csapak [Wed, 16 Sep 2020 12:09:44 +0000 (14:09 +0200)]
api-macro: fix broken binary ident search
the 'properties_' list is sorted by the the literal string of a
fieldname, but we binary-search for the 'ident_str' (which may be
different, since we map '-' to '_' for example)
by creating a hashmap to map from ident to index, we can do a simple
lookup in that case that will work
benchmarks showed no measurable performance difference
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Fabian Grünbichler [Tue, 15 Sep 2020 10:20:54 +0000 (12:20 +0200)]
time: add tests for gmtime range
mainly so we notice if this assumption does not hold for some platform
or changes in the future.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Fabian Grünbichler [Tue, 15 Sep 2020 10:20:53 +0000 (12:20 +0200)]
time/rfc3339: add leading zeroes for years < 1000
strftime(3) does not mention this explicitly, but years before 1000 have
their leading zero(es) stripped, which is not valid according to either
ISO-8601 or its profile RFC3339.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Fabian Grünbichler [Tue, 15 Sep 2020 10:20:52 +0000 (12:20 +0200)]
time: add tests for RFC3339 corner cases
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Fabian Grünbichler [Tue, 15 Sep 2020 10:20:51 +0000 (12:20 +0200)]
time: allow leap seconds when parsing RFC3339
we don't ever produce those, but they are valid RFC3339 strings
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Fabian Grünbichler [Tue, 15 Sep 2020 10:20:50 +0000 (12:20 +0200)]
time: add test for leap second parsing/converting
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Dietmar Maurer [Mon, 14 Sep 2020 11:41:14 +0000 (13:41 +0200)]
bump proxmox version to 0.3.8-1
Dietmar Maurer [Mon, 14 Sep 2020 11:38:53 +0000 (13:38 +0200)]
remove chrono dependency and related code
Dietmar Maurer [Mon, 14 Sep 2020 10:42:23 +0000 (12:42 +0200)]
check year in epoch_to_rfc3339, new helpers strftime_local and strftime_utc
Dietmar Maurer [Mon, 14 Sep 2020 08:38:09 +0000 (10:38 +0200)]
new helpers epoch_i64 and epoch_f64
These helpers use rust std SystemTime. Removed the libc time() binding.
Dietmar Maurer [Sun, 13 Sep 2020 14:20:56 +0000 (16:20 +0200)]
proxmox/src/tools/serde.rs: fix epoch_as_rfc3339 doctest
Dietmar Maurer [Sun, 13 Sep 2020 14:15:59 +0000 (16:15 +0200)]
bump proxmox version to 0.3.7
Dietmar Maurer [Sun, 13 Sep 2020 14:13:19 +0000 (16:13 +0200)]
fix epoch_as_rfc3339 serializer
Dietmar Maurer [Sun, 13 Sep 2020 09:52:46 +0000 (11:52 +0200)]
src/tools/serde.rs: implement epoch_as_rfc3339 serializer
Dietmar Maurer [Sun, 13 Sep 2020 09:42:15 +0000 (11:42 +0200)]
src/tools/time.rs: rename rfc_3339 to rfc3339
Dietmar Maurer [Sun, 13 Sep 2020 09:31:31 +0000 (11:31 +0200)]
src/tools/email.rs: avoid chrono dependency
Dietmar Maurer [Sun, 13 Sep 2020 09:09:20 +0000 (11:09 +0200)]
src/tools/time.rs: add parse_rfc_3339
Dietmar Maurer [Sun, 13 Sep 2020 09:02:52 +0000 (11:02 +0200)]
src/tools/time/tm_editor.rs: copied from proxmox backup
Dietmar Maurer [Sun, 13 Sep 2020 08:51:27 +0000 (10:51 +0200)]
proxmox/src/tools/time.rs: add epoch_to_rfc_3339
Dietmar Maurer [Sat, 12 Sep 2020 13:07:12 +0000 (15:07 +0200)]
proxmox/src/tools/time.rs: fix previous commit
Dietmar Maurer [Sat, 12 Sep 2020 13:01:46 +0000 (15:01 +0200)]
bump proxmox version to 0.3.6-1
Dietmar Maurer [Sat, 12 Sep 2020 12:59:31 +0000 (14:59 +0200)]
proxmox/src/tools/time.rs: add strftime bindings
Dietmar Maurer [Fri, 4 Sep 2020 04:36:55 +0000 (06:36 +0200)]
bump proxmox version to 0.3.5-1
Dominik Csapak [Thu, 3 Sep 2020 11:37:59 +0000 (13:37 +0200)]
tools/time: give tm struct as mut reference
mktime/timegm can modify the timestruct (to normalize the time, e.g.
convert the january 40 to february 9)
to use that feature, we have to give a mutable reference, else the
struct will be copied and the original left untouched
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Wolfgang Bumiller [Fri, 28 Aug 2020 06:59:25 +0000 (08:59 +0200)]
and run rustfmt over another big chunk of code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Fri, 28 Aug 2020 06:56:54 +0000 (08:56 +0200)]
more formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Fri, 28 Aug 2020 06:55:16 +0000 (08:55 +0200)]
formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Dietmar Maurer [Fri, 28 Aug 2020 04:25:36 +0000 (06:25 +0200)]
bump proxmox to 0.3.4-1
Hannes Laimer [Thu, 27 Aug 2020 10:00:36 +0000 (12:00 +0200)]
email: add small function to send multi-part emails using sendmail
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
Wolfgang Bumiller [Mon, 10 Aug 2020 09:30:49 +0000 (11:30 +0200)]
bump proxmox to 0.3.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Thu, 6 Aug 2020 09:16:04 +0000 (11:16 +0200)]
add serde forwarding convenience macros
* forward_deserialize_to_from_str
* forward_serialize_to_display
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 4 Aug 2020 14:24:13 +0000 (16:24 +0200)]
clippy: use matches for if let -> bool
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 4 Aug 2020 09:12:11 +0000 (11:12 +0200)]
bump proxmox dep to 0.3.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 4 Aug 2020 08:29:03 +0000 (10:29 +0200)]
tools/mod.rs: sort modules
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 4 Aug 2020 07:31:14 +0000 (09:31 +0200)]
add lock_file and open_file_locked
to proxmox::tools::fs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 4 Aug 2020 07:27:59 +0000 (09:27 +0200)]
add proxmox::sys::timer module (moved from proxmox-backup)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Mon, 3 Aug 2020 09:10:59 +0000 (11:10 +0200)]
move uuid serde code to uuid.rs
And avoid the temporary string allocation where possible.
Implementing foreign traits in external modules is bad
practice. The `serde` module is for implementations which
deviate from the expected default.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Dietmar Maurer [Sun, 2 Aug 2020 09:52:25 +0000 (11:52 +0200)]
bump version to 0.3.1-1
Dietmar Maurer [Sun, 2 Aug 2020 09:49:36 +0000 (11:49 +0200)]
Uuid: implement Serlialize/Deserialize
Wolfgang Bumiller [Wed, 29 Jul 2020 07:37:02 +0000 (09:37 +0200)]
bump proxmox version to 0.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Wed, 29 Jul 2020 07:28:59 +0000 (09:28 +0200)]
add http_bail macro
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Wed, 29 Jul 2020 07:25:46 +0000 (09:25 +0200)]
http_err macro: imply format!()
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Tue, 28 Jul 2020 13:11:38 +0000 (15:11 +0200)]
switch to using mod.rs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Stefan Reiter [Mon, 27 Jul 2020 15:28:40 +0000 (17:28 +0200)]
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>
Thomas Lamprecht [Thu, 23 Jul 2020 10:04:12 +0000 (12:04 +0200)]
bump proxmox version to 0.2.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Dominik Csapak [Fri, 17 Jul 2020 12:17:10 +0000 (14:17 +0200)]
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>
Dominik Csapak [Fri, 17 Jul 2020 12:17:09 +0000 (14:17 +0200)]
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>
Dominik Csapak [Fri, 17 Jul 2020 12:17:08 +0000 (14:17 +0200)]
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>
Dominik Csapak [Fri, 17 Jul 2020 12:17:07 +0000 (14:17 +0200)]
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>
Wolfgang Bumiller [Thu, 16 Jul 2020 12:13:13 +0000 (14:13 +0200)]
api-macro: formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Thu, 16 Jul 2020 12:11:01 +0000 (14:11 +0200)]
a lot more clippy lint fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Thu, 16 Jul 2020 11:44:42 +0000 (13:44 +0200)]
various clippy lint fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Wolfgang Bumiller [Wed, 15 Jul 2020 12:59:39 +0000 (14:59 +0200)]
websocket feature dependency fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Dominik Csapak [Tue, 14 Jul 2020 11:09:57 +0000 (13:09 +0200)]
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>
Dominik Csapak [Tue, 14 Jul 2020 11:09:56 +0000 (13:09 +0200)]
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>
Dominik Csapak [Tue, 14 Jul 2020 11:09:55 +0000 (13:09 +0200)]
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>