Commit Graph

796 Commits

Author SHA1 Message Date
Fabian Grünbichler
94c96348a7 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>
2020-09-15 13:13:40 +02:00
Fabian Grünbichler
0830d33e99 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>
2020-09-15 13:13:29 +02:00
Fabian Grünbichler
c698d4b889 time: add tests for RFC3339 corner cases
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-15 13:13:17 +02:00
Fabian Grünbichler
ceefaa8095 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>
2020-09-15 13:12:58 +02:00
Fabian Grünbichler
ed7c58cf47 time: add test for leap second parsing/converting
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-09-15 13:12:23 +02:00
Dietmar Maurer
8cb07ac905 bump proxmox version to 0.3.8-1 2020-09-14 13:41:14 +02:00
Dietmar Maurer
c295aa961c remove chrono dependency and related code 2020-09-14 13:38:53 +02:00
Dietmar Maurer
3efc4d244b check year in epoch_to_rfc3339, new helpers strftime_local and strftime_utc 2020-09-14 12:43:49 +02:00
Dietmar Maurer
557cce7ae0 new helpers epoch_i64 and epoch_f64
These helpers use rust std SystemTime. Removed the libc time() binding.
2020-09-14 10:45:34 +02:00
Dietmar Maurer
e3b62ae3b2 proxmox/src/tools/serde.rs: fix epoch_as_rfc3339 doctest 2020-09-13 16:20:56 +02:00
Dietmar Maurer
99351a7752 bump proxmox version to 0.3.7 2020-09-13 16:16:37 +02:00
Dietmar Maurer
b975317a47 fix epoch_as_rfc3339 serializer 2020-09-13 16:13:19 +02:00
Dietmar Maurer
d42fc47c4d src/tools/serde.rs: implement epoch_as_rfc3339 serializer 2020-09-13 11:52:46 +02:00
Dietmar Maurer
b164904a4f src/tools/time.rs: rename rfc_3339 to rfc3339 2020-09-13 11:42:15 +02:00
Dietmar Maurer
317d1a78fb src/tools/email.rs: avoid chrono dependency 2020-09-13 11:31:31 +02:00
Dietmar Maurer
8405dd740c src/tools/time.rs: add parse_rfc_3339 2020-09-13 11:09:20 +02:00
Dietmar Maurer
11ef587edd src/tools/time/tm_editor.rs: copied from proxmox backup 2020-09-13 11:02:52 +02:00
Dietmar Maurer
3aa8e22b0c proxmox/src/tools/time.rs: add epoch_to_rfc_3339 2020-09-13 10:51:27 +02:00
Dietmar Maurer
fb4e426a0a proxmox/src/tools/time.rs: fix previous commit 2020-09-12 15:07:12 +02:00
Dietmar Maurer
5eb5b21044 bump proxmox version to 0.3.6-1 2020-09-12 15:01:46 +02:00
Dietmar Maurer
9f837a4333 proxmox/src/tools/time.rs: add strftime bindings 2020-09-12 14:59:31 +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
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
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