Commit Graph

2405 Commits

Author SHA1 Message Date
Fabian Grünbichler
28aef354ca don't truncate DateTime nanoseconds
where we don't care about them anyway..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-11 15:48:10 +02:00
Thomas Lamprecht
1b79d5d5a5 ui: add translation support
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-08 08:54:33 +02:00
Thomas Lamprecht
7917e89426 tools: rename extract_auth_cookie to extract_cookie
It does nothing specific to authentication..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-08 08:54:33 +02:00
Dietmar Maurer
dcf220db80 bump proxmox version to 0.3.5-1 2020-09-04 06:37:16 +02:00
Dominik Csapak
db1da0f645 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>
2020-09-04 06:27:58 +02:00
Wolfgang Bumiller
c0d2165d75 and run rustfmt over another big chunk of code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-28 08:59:26 +02:00
Wolfgang Bumiller
ba7c389142 more formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-28 08:56:54 +02:00
Wolfgang Bumiller
bbc94222f5 formatting fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-28 08:55:16 +02:00
Dietmar Maurer
001f2525fa bump proxmox to 0.3.4-1 2020-08-28 06:25:36 +02:00
Hannes Laimer
66004f22c6 email: add small function to send multi-part emails using sendmail
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2020-08-28 06:23:54 +02:00
Wolfgang Bumiller
3c8cb5129e replace and remove old ticket functions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-12 14:28:21 +02:00
Wolfgang Bumiller
906ea7a45b introduce Username, Realm and Userid api types
and begin splitting up types.rs as it has grown quite large
already

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-10 12:05:01 +02:00
Wolfgang Bumiller
aef02efce3 bump proxmox to 0.3.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-10 11:30:49 +02:00
Wolfgang Bumiller
6cd1aac558 add serde forwarding convenience macros
* forward_deserialize_to_from_str
* forward_serialize_to_display

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-10 09:38:50 +02:00
Wolfgang Bumiller
6da4dd5bbb clippy: use matches for if let -> bool
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 16:24:13 +02:00
Wolfgang Bumiller
66ae742cb3 bump proxmox dep to 0.3.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 11:12:11 +02:00
Wolfgang Bumiller
9da029a8c3 tools/mod.rs: sort modules
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 10:29:03 +02:00
Wolfgang Bumiller
570f89f6a5 add lock_file and open_file_locked
to proxmox::tools::fs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 09:31:15 +02:00
Wolfgang Bumiller
401ba6f927 add proxmox::sys::timer module (moved from proxmox-backup)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-08-04 09:27:59 +02:00
Wolfgang Bumiller
d34e00af0c 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>
2020-08-03 11:25:25 +02:00
Dietmar Maurer
f2230ad2ab bump version to 0.3.1-1 2020-08-02 11:52:25 +02:00
Dietmar Maurer
a7390a3d0e Uuid: implement Serlialize/Deserialize 2020-08-02 11:50:26 +02:00
Wolfgang Bumiller
df9109d493 bump proxmox to 0.3, cleanup http_err macro usage
Also swap the order of a couple of `.map_err().await` to
`.await.map_err()` since that's generally more efficient.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-29 09:38:36 +02:00
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
67294d4796 followup: server/state: rename task_count to internal_task_count
so that the relation with spawn_internal_task is made more clear

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-24 12:11:39 +02:00
Dominik Csapak
8588c41f3c server/state: add spawn_internal_task and use it for websockets
is a helper to spawn an internal tokio task without it showing up
in the task list

it is still tracked for reload and notifies the last_worker_listeners

this enables the console to survive a reload of proxmox-backup-proxy

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-24 11:17:33 +02:00
Dominik Csapak
054951682d server/rest: add console to index
register the console template and render it when the 'console' parameter
is given

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-23 12:06:38 +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
9993f4d099 server/config: add mechanism to update template
instead of exposing handlebars itself, offer a register_template and
a render_template ourselves.

render_template checks if the template file was modified since
the last render and reloads it when necessary

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-07-23 11:55:00 +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
Thomas Lamprecht
ab08bd7f39 server: add path value to NOT_FOUND http error
Especially helpful for requests not coming from browsers (where the
URL is normally easy to find out).

Makes it easier to detect if one triggered a request with an old
client, or so..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-16 12:46:51 +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