Commit Graph

147 Commits

Author SHA1 Message Date
Mira Limbeck
af6c02e658 cleanup: remove unused strftime function
since we switched to proxmox_time::strftime_local for printing the start
and end times using local time, the strftime functions in src/time.rs is
unused and can be removed

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2024-02-23 18:29:17 +01:00
Mira Limbeck
033d9fea42 tests: update for log tracker time handling changes
since we now calculate the time in UTC rather than local time, the time
values of each test had to be touched. those should differ by `E10`
(3600 seconds) in most cases since we set the TZ to Europe/Vienna for
the tests.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2024-02-23 18:29:17 +01:00
Mira Limbeck
a36803db4a tests: improve test output consistency
`expected` and `command` are more helpful than `new` and `old`.
the order of `expected` and `command` should now always be the same:
expected before command

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2024-02-23 18:29:17 +01:00
Mira Limbeck
8a5b28ff16 rfc3339: move timezone offset compatibility code to old time parser
The compatibility code was added to the new rfc3339 code path temporarily so
that the old code path would not be changed before the PMG 8 release.

Now move it to the old time format code to make sure the rfc3339 code path
works as expected. Since we have all the information we need (year, month,
day, hours, minutes, seconds, timezone), there's no need for a workaround in
this code path.

As a side effect of parsing the time format `YYYY-MM-DD HH:MM:SS` in
localtime, it's now possible to parse an rfc3339 compliant format
(except for fractional seconds).

The change needs to be accompanied by one in pmg-api MailTracker.pmg to
keep the time displayed in the GUI the same for the old time format, and
correct for the new rfc3339 format.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2024-02-23 18:29:17 +01:00
Dominik Csapak
e34f84b91f use pico-args instead of clap
Instead of upgrading from clap3 to clap4 (which seems to change their
interface every year or so), switch to the much smaller pico-args. (Same
as we did for termproxy recently, see [0])

It has almost all features we need (except producing help output) and
supports OsString, but wihout any dependencies. This decreases compile
time and reduces the size of the resulting binary. It also reduces the
lines of code.

The only difference is now the different output for errors, e.g. for
missing values of options.

Help output is copied from the old clap output.

0: https://git.proxmox.com/?p=pve-xtermjs.git;a=commitdiff;h=24d707d0506b120a085b06b5f2b6000696879a1e

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
2024-02-13 15:54:42 +01:00
Thomas Lamprecht
a1ebc0c6fe bump version to 2.4.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-28 13:07:30 +02:00
Mira Limbeck
4d645342e1 tests: update to match the compatibility changes
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2023-06-28 11:50:44 +02:00
Mira Limbeck
2742c7f849 add compatibility with API/Tracking Center
The API assumes the timestamps to be in the local timezone rather than
UTC. It then subtracts the timezone offset leading to wrong values when
timestamps are in UTC, but timezone is not.

For compatibility, add the local timezone to those timestamps.

Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2023-06-28 11:50:26 +02:00
Thomas Lamprecht
c195552948 buildsys: derive upload dist automatically
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 18:14:27 +02:00
Thomas Lamprecht
cdcc762692 bump version to 2.4.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 18:04:53 +02:00
Mira Limbeck
bc64fc8041 tests: add rfc3339 timestamp test
for this test `faketime` is not required since the year is part of the
timestamp

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 18:04:53 +02:00
Mira Limbeck
34c921addd add support for bookworm syslog time format
Adds `proxmox-time` as dependency to parse the timestamp

Since parse_rfc3339 can't handle microseconds, we try to remove the dot
followed by 6 digits of microseconds before passing it to parse_rfc3339.

A fallback to the previous format is used when when it fails to parse
the new format.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 18:04:53 +02:00
Thomas Lamprecht
c8d2476d05 buildsys: expand clean target
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 18:04:53 +02:00
Thomas Lamprecht
57628f9d59 buildsys: avoid no-pre-clean flag
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 17:55:34 +02:00
Thomas Lamprecht
f30c45b824 buildsys: use dpkg default makefile fragements
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 17:55:17 +02:00
Thomas Lamprecht
62a47d3493 buildsys: only get git revision if actually used
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 17:54:48 +02:00
Thomas Lamprecht
538968fdbe d/copyright: use machine readable format
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-26 17:54:27 +02:00
Stoiko Ivanov
f6ca4f6415 buildsys: re-add reference to GITVERSION
this was dropped when changing to debcargo, but d/docs still
references it.

Without this patch building with sbuild does not work.

Fixes: e029c60dff
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-06-26 13:01:35 +02:00
Stoiko Ivanov
b154004956 tests: explicitly set timezone for testcases with unix timestamps
noticed when building with sbuild, which uses UTC as timezone:
Due to the parsing of traditional syslog time information (which does
not contain timezone information) the testcases passing
unix-timestamps as arguments failed.

Explicitly setting TZ to Europe/Vienna fixes the tests (and makes the
assumption visible)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-06-26 13:01:27 +02:00
Stoiko Ivanov
5ed9f5caa5 buildsys: add sbuild convenience target
and only call lintian on the source-package for the phony dsc target,
as sbuild calls it anyways

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-06-16 17:51:57 +02:00
Stoiko Ivanov
1bd7041278 d/s/format: mark package as native
and adapt makefile variables

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-06-16 17:51:57 +02:00
Thomas Lamprecht
39b57008f7 d/control: update generated meta data from newer debcargo
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-12-02 11:26:53 +01:00
Thomas Lamprecht
41d4b6dd8e bump version to 2.3.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-25 11:38:14 +01:00
Thomas Lamprecht
fa2e785d2b cli opts: use get_count for "verbose" flag
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-25 11:36:30 +01:00
Thomas Lamprecht
0809816451 update clap to 0.3.23
to get some convenience things like the get_count helper

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-25 11:35:25 +01:00
Thomas Lamprecht
3e6542d819 update clap from 2 to 3
only relevant change is the assertion that multiple(true) takes a
value, so we need to change to the new actions system.

Note that with 3.2.20+ we could switch to args.get_count("verbose")
saving us the unwrap/dereference dance.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-24 18:47:12 +01:00
Thomas Lamprecht
38ad688ccd cargo fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-24 18:46:49 +01:00
Thomas Lamprecht
c8de75201b code cleanup: avoid some bload on match return
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-13 11:46:19 +02:00
Thomas Lamprecht
f3f09b97fd clippy fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-13 11:42:00 +02:00
Thomas Lamprecht
ac32804169 cargo: relaxe libc dependency to minor 0.2 version
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-13 11:35:04 +02:00
Thomas Lamprecht
915a5aa7f8 cargo: update clap to 2.33
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-13 11:34:44 +02:00
Thomas Lamprecht
ddaa372402 tree wide cargo fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-13 11:30:26 +02:00
Wolfgang Bumiller
8f1719eebe drop 'time' dependency
We're using a very old version of it and the functions we
actually use are available in glibc anyway.

The only difference I found was that the result of
glibc's `strptime()`'s `%s` does *not* want an additional
`.to_local()` call anymore...

... which was weird anyway.

As a minor optimization I pass the format string as `&CStr`
to avoid the memcpy.

(The CString::new() call in `strptime()` only happens during
parameter parsing)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
[dropped left-over and fixed FIXME]
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-02-14 19:05:47 +01:00
Stoiko Ivanov
a4d769405c add tests for DST change and year change
based on our outbound production logs but anonymized

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-02-14 14:43:55 +01:00
Thomas Lamprecht
cc80c54de8 buildsys: fix reference to DBG_DEB
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-01 14:06:28 +01:00
Thomas Lamprecht
71e42fc1f8 buildsys: use only one parenthesis style
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-01 14:06:11 +01:00
Thomas Lamprecht
4b388f8d40 bump version to 2.3.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-01 13:32:06 +01:00
Stoiko Ivanov
17ec304fea fix logfile counting in months != january
the changes introduced in 1cdbebe57b

changed the date handling to have current_month and current_year
represent the month and year at time of invocation.
This change was not carried over to the logfile collecting, which set
the current month to january.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
2022-02-01 13:29:26 +01:00
Wolfgang Bumiller
b24a352a5d bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-04 16:02:18 +01:00
Wolfgang Bumiller
daec25d33f bump version to 2.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-04 15:55:53 +01:00
Wolfgang Bumiller
2fbb2ab3c6 stick to time_t for time
especially those u32 conversions are simply completely wrong

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
[rebased]
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-01-04 14:07:23 +01:00
Stoiko Ivanov
1cdbebe57b do not assume constant year based on file index
rather start with the current time at invocation and if the month in
the log is larger assume a year-wrap happened between logwriting and
invocation.

the old logic is flawed (but that can be said about parsing
traditional syslog timestamps (w/o year) in general) - it got worse
with the change in bullseye of rotating syslog weekly by default -
resulting in users losing one week of logs per day in the new year as
reported in https://forum.proxmox.com/threads/.102322/

Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2022-01-04 13:55:49 +01:00
Wolfgang Bumiller
6d693ce164 add .gitignore file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 14:56:17 +01:00
Wolfgang Bumiller
821c09bd9f bump edition to 2021
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 13:22:16 +01:00
Wolfgang Bumiller
f9d4bdda8b switch to anyhow, don't use old style imports
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 13:21:18 +01:00
Wolfgang Bumiller
6e63fa58ee clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-03 11:46:13 +01:00
Stoiko Ivanov
b87d0b0583 add test for empty to (dnsbl reject)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-12-01 19:02:30 +01:00
Mira Limbeck
cab179a921 fix #3758: fix to filter with empty NoqueueEntry to field
We only compared the filter `to` with the Noqueue `to` when both were
not empty, and in turn set the nq.dstatus to DStatus::Invalid when they
didn't match.
But in the case of an empty Noqueue `to`, we have to skip it as well if
the filter `to` is not empty.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2021-12-01 18:57:15 +01:00
Thomas Lamprecht
40d978e67b debcargo: track updates
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-28 17:04:06 +02:00
Thomas Lamprecht
3f12c7fed7 buildsys: upload to bullseye
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-06-28 17:00:36 +02:00