]> git.proxmox.com Git - proxmox.git/log
proxmox.git
2 years agouse new proxmox-sys crate
Dietmar Maurer [Fri, 19 Nov 2021 09:51:41 +0000 (10:51 +0100)]
use new proxmox-sys crate

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agouse proxmox::tools::fd::fd_change_cloexec from proxmox 0.15.3
Dietmar Maurer [Thu, 18 Nov 2021 12:43:41 +0000 (13:43 +0100)]
use proxmox::tools::fd::fd_change_cloexec from proxmox 0.15.3

Depend on proxmox 0.15.3

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agorest: make successful-ticket auth log a debug one to avoid syslog
Thomas Lamprecht [Wed, 10 Nov 2021 16:05:09 +0000 (17:05 +0100)]
rest: make successful-ticket auth log a debug one to avoid syslog

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoimplement Servive for RateLimitedStream
Dietmar Maurer [Thu, 4 Nov 2021 12:42:30 +0000 (13:42 +0100)]
implement Servive for RateLimitedStream

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agouse new fsync parameter to replace_file and atomic_open_or_create
Dietmar Maurer [Wed, 20 Oct 2021 12:56:15 +0000 (14:56 +0200)]
use new fsync parameter to replace_file and atomic_open_or_create

Depend on proxmox 0.15.0 and proxmox-openid 0.8.1

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2 years agorest-server: use hashmap for parameter errors
Dominik Csapak [Tue, 19 Oct 2021 11:09:27 +0000 (13:09 +0200)]
rest-server: use hashmap for parameter errors

our ui expects a map here with 'field: "error"'. This way it can mark
the relevant field as invalid and correctly shows the complete error
message

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agouse complete_file_name from proxmox-router 1.1
Dietmar Maurer [Wed, 13 Oct 2021 10:55:51 +0000 (12:55 +0200)]
use complete_file_name from proxmox-router 1.1

2 years agoupdate to first proxmox crate split
Wolfgang Bumiller [Fri, 8 Oct 2021 09:19:37 +0000 (11:19 +0200)]
update to first proxmox crate split

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump proxmox dependency to 0.14.0 and proxmox-http to 0.5.0
Wolfgang Bumiller [Fri, 8 Oct 2021 09:18:22 +0000 (11:18 +0200)]
bump proxmox dependency to 0.14.0 and proxmox-http to 0.5.0

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agorest-server: add cleanup_old_tasks
Dominik Csapak [Thu, 7 Oct 2021 12:03:36 +0000 (14:03 +0200)]
rest-server: add cleanup_old_tasks

this is a helper that removes task log files that are not referenced
by the task archive anymore

it gets the oldest task archive file, gets the first endtime (the
oldest) and removes all files in the taskdir where the mtime is older
than that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoproxmox-rest-server: use new ServerAdapter trait instead of callbacks
Dietmar Maurer [Tue, 5 Oct 2021 09:01:05 +0000 (11:01 +0200)]
proxmox-rest-server: use new ServerAdapter trait instead of callbacks

Async callbacks are a PITA, so we now pass a single trait object which
implements check_auth and get_index.

2 years agoproxmox-rest-server: pass owned RestEnvironment to get_index
Dietmar Maurer [Mon, 4 Oct 2021 12:49:25 +0000 (14:49 +0200)]
proxmox-rest-server: pass owned RestEnvironment to get_index

This way we avoid pointers with lifetimes.

2 years agoproxmox-rest-server: cleanup, access api_auth using a method
Dietmar Maurer [Mon, 4 Oct 2021 11:32:19 +0000 (13:32 +0200)]
proxmox-rest-server: cleanup, access api_auth using a method

2 years agorest: daemon: group systemd FFI together
Thomas Lamprecht [Fri, 1 Oct 2021 14:46:59 +0000 (16:46 +0200)]
rest: daemon: group systemd FFI together

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: sd notify: code cleanup
Thomas Lamprecht [Fri, 1 Oct 2021 14:45:19 +0000 (16:45 +0200)]
rest: daemon: sd notify: code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: sd notify barrier: avoid barging in between SystemdNotify enum and...
Thomas Lamprecht [Fri, 1 Oct 2021 14:44:28 +0000 (16:44 +0200)]
rest: daemon: sd notify barrier: avoid barging in between SystemdNotify enum and systemd_notify

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: sd notify barrier: allow caller to set timeout
Thomas Lamprecht [Fri, 1 Oct 2021 13:27:46 +0000 (15:27 +0200)]
rest: daemon: sd notify barrier: allow caller to set timeout

else it's rather to subtle and not a nice interface considering that
we only want to have a thin wrapper for sd_notify_barrier..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest: daemon: comment why using a systemd barrier is important for main PID handover
Thomas Lamprecht [Fri, 1 Oct 2021 13:04:58 +0000 (15:04 +0200)]
rest: daemon: comment why using a systemd barrier is important for main PID handover

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest-server/daemon: use sd_notify_barrier for service reloading
Dominik Csapak [Thu, 30 Sep 2021 07:18:58 +0000 (09:18 +0200)]
rest-server/daemon: use sd_notify_barrier for service reloading

until now, we manually polled the systemd service state during a reload
so that the sd_notify messages get processed in the correct order
(RELOAD(old) -> MAINPID(old) -> READY(new))

with systemd >= 246 there is now 'sd_notify_barrier' which
blocks until systemd processed all prior messages

with that change, the daemon does not need to know the service name anymore

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoproxmox-rest-server: make get_index async
Dietmar Maurer [Fri, 1 Oct 2021 07:38:10 +0000 (09:38 +0200)]
proxmox-rest-server: make get_index async

2 years agoproxmox-rest-server: add comment why ApiService needs to be 'pub'
Dietmar Maurer [Fri, 1 Oct 2021 06:35:51 +0000 (08:35 +0200)]
proxmox-rest-server: add comment why ApiService needs to be 'pub'

2 years agoproxmox-rest-server: make check_auth async
Dietmar Maurer [Fri, 1 Oct 2021 05:29:11 +0000 (07:29 +0200)]
proxmox-rest-server: make check_auth async

2 years agoproxmox-rest-server: fix spelling errors
Dietmar Maurer [Fri, 1 Oct 2021 04:43:30 +0000 (06:43 +0200)]
proxmox-rest-server: fix spelling errors

2 years agoproxmox-rest-server: improve ApiService docs
Dietmar Maurer [Thu, 30 Sep 2021 15:18:47 +0000 (17:18 +0200)]
proxmox-rest-server: improve ApiService docs

2 years agoproxmox-rest-server: start module docs
Dietmar Maurer [Thu, 30 Sep 2021 11:49:29 +0000 (13:49 +0200)]
proxmox-rest-server: start module docs

2 years agorename CommandoSocket to CommandSocket
Dietmar Maurer [Thu, 30 Sep 2021 10:31:38 +0000 (12:31 +0200)]
rename CommandoSocket to CommandSocket

2 years agodrop fd_change_cloexec from proxmox-rest-server
Wolfgang Bumiller [Thu, 30 Sep 2021 10:42:28 +0000 (12:42 +0200)]
drop fd_change_cloexec from proxmox-rest-server

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoproxmox-rest-server: improve docs
Dietmar Maurer [Thu, 30 Sep 2021 09:59:21 +0000 (11:59 +0200)]
proxmox-rest-server: improve docs

And rename enable_file_log to enable_access_log.

2 years agoproxmox-rest-server: improve docs
Dietmar Maurer [Thu, 30 Sep 2021 08:33:57 +0000 (10:33 +0200)]
proxmox-rest-server: improve docs

And renames abort_worker_async to abort_worker_nowait (avoid confusion,
because the function itself is not async).

2 years agoproxmox-rest-server: cleanup FileLogger docs
Dietmar Maurer [Thu, 30 Sep 2021 06:51:23 +0000 (08:51 +0200)]
proxmox-rest-server: cleanup FileLogger docs

2 years agocleanup: move use clause to top
Dietmar Maurer [Thu, 30 Sep 2021 06:40:55 +0000 (08:40 +0200)]
cleanup: move use clause to top

2 years agoproxmox-rest-server: allow to catch SIGINT and SIGHUP separately
Dietmar Maurer [Thu, 30 Sep 2021 06:03:34 +0000 (08:03 +0200)]
proxmox-rest-server: allow to catch SIGINT and SIGHUP separately

And make ServerState private.

2 years agoproxmox-rtest-server: make Reloader and Reloadable private
Dietmar Maurer [Thu, 30 Sep 2021 05:37:16 +0000 (07:37 +0200)]
proxmox-rtest-server: make Reloader and Reloadable private

2 years agoproxmox-rest-server: improve logging
Dietmar Maurer [Wed, 29 Sep 2021 12:34:25 +0000 (14:34 +0200)]
proxmox-rest-server: improve logging

And rename server_state_init() into catch_shutdown_and_reload_signals().

2 years agoproxmox-rest-server: avoid useless call to request_shutdown
Dietmar Maurer [Wed, 29 Sep 2021 10:46:00 +0000 (12:46 +0200)]
proxmox-rest-server: avoid useless call to request_shutdown

Also avoid unsafe code.

2 years agodaemon: simlify code (make it easier to use)
Dietmar Maurer [Wed, 29 Sep 2021 09:21:32 +0000 (11:21 +0200)]
daemon: simlify code (make it easier to use)

2 years agocleanup: make BoxedStoreFunc private
Dietmar Maurer [Wed, 29 Sep 2021 07:40:56 +0000 (09:40 +0200)]
cleanup: make BoxedStoreFunc private

There is no need to export this type.

2 years agoexamples: add example for a simple rest server with a small api
Dominik Csapak [Wed, 29 Sep 2021 07:04:19 +0000 (09:04 +0200)]
examples: add example for a simple rest server with a small api

show how to generally start a daemon that serves a rest api + index page

api calls are (prefixed with either /api2/json or /api2/extjs):
/ GET listing
/ping GET returns "pong"
/items GET lists existing items
POST lets user create new items
/items/{id} GET returns the content of a single item
PUT updates an item
DELETE deletes an item

Contains a small dummy user/authinfo

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest-server: use hypers AddrIncoming for proxmox-backup-api
Dominik Csapak [Wed, 29 Sep 2021 07:04:17 +0000 (09:04 +0200)]
rest-server: use hypers AddrIncoming for proxmox-backup-api

this has a 'from_listener' (tokio::net::TcpListener) since hyper 0.14.5 in
the 'tcp' feature (we use 'full', which includes that; since 0.14.13
it is not behind a feature flag anymore).

this makes it possible to create a hyper server without our
'StaticIncoming' wrapper and thus makes it unnecessary.

The only other thing we have to do is to change the Service impl from
tokio::net::TcpStream to hyper::server::conn::AddStream to fulfill the trait
requirements.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoExtJsFormatter: use ParameterError to correctly compute 'errors'
Dietmar Maurer [Tue, 28 Sep 2021 08:11:56 +0000 (10:11 +0200)]
ExtJsFormatter: use ParameterError to correctly compute 'errors'

By default, 'errors' is now empty.

Depend on proxmox 0.13.5.

2 years agoproxmox-rest-server: cleanup formatter, improve docs
Dietmar Maurer [Mon, 27 Sep 2021 10:59:06 +0000 (12:59 +0200)]
proxmox-rest-server: cleanup formatter, improve docs

Use trait for OutputFormatter. This is functionally equivalent,
but more rust-like...

2 years agoWorkerTaskContext: add shutdown_requested() and fail_on_shutdown()
Dietmar Maurer [Fri, 24 Sep 2021 09:56:53 +0000 (11:56 +0200)]
WorkerTaskContext: add shutdown_requested() and fail_on_shutdown()

2 years agocleanup WorkerTaskContext
Dietmar Maurer [Fri, 24 Sep 2021 09:39:30 +0000 (11:39 +0200)]
cleanup WorkerTaskContext

2 years agocleanup worker task logging
Dietmar Maurer [Fri, 24 Sep 2021 07:30:00 +0000 (09:30 +0200)]
cleanup worker task logging

In order to avoid name conflicts with WorkerTaskContext

- renamed WorkerTask::log to WorkerTask::log_message

Note: Methods have different fuction signatures

Also renamed WorkerTask::warn to WorkerTask::log_warning for
consistency reasons.

Use the task_log!() and task_warn!() macros more often.

2 years agorename TaskState to WorkerTaskContext
Dietmar Maurer [Fri, 24 Sep 2021 05:40:49 +0000 (07:40 +0200)]
rename TaskState to WorkerTaskContext

2 years agomove src/server/h2service.rs into proxmox-rest-server crate
Dietmar Maurer [Thu, 23 Sep 2021 10:38:09 +0000 (12:38 +0200)]
move src/server/h2service.rs into proxmox-rest-server crate

2 years agomove worker_task.rs into proxmox-rest-server crate
Dietmar Maurer [Thu, 23 Sep 2021 08:09:19 +0000 (10:09 +0200)]
move worker_task.rs into proxmox-rest-server crate

Also moved pbs-datastore/src/task.rs to pbs-tools, which now depends on 'log'.

2 years agouse UPID and systemd helpers from proxmox 0.13.4
Dietmar Maurer [Wed, 22 Sep 2021 10:46:44 +0000 (12:46 +0200)]
use UPID and systemd helpers from proxmox 0.13.4

2 years agomove src/server/rest.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:51 +0000 (07:58 +0200)]
move src/server/rest.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: cleanup auth-log handling
Dietmar Maurer [Tue, 21 Sep 2021 05:58:50 +0000 (07:58 +0200)]
rest server: cleanup auth-log handling

Handle auth logs the same way as access log.
- Configure with ApiConfig
- CommandoSocket command to reload auth-logs "api-auth-log-reopen"

Inside API calls, we now access the ApiConfig using the RestEnvironment.

The openid_login api now also logs failed logins and return http_err!(UNAUTHORIZED, ..)
on failed logins.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: do not use pbs_api_types::Authid
Dietmar Maurer [Tue, 21 Sep 2021 05:58:49 +0000 (07:58 +0200)]
rest server: do not use pbs_api_types::Authid

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: return UserInformation from ApiAuth::check_auth
Dietmar Maurer [Tue, 21 Sep 2021 05:58:48 +0000 (07:58 +0200)]
rest server: return UserInformation from ApiAuth::check_auth

This need impl UserInformation for Arc<CachedUserInfo> which is implemented
with proxmox 0.13.2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomake get_index and ApiConfig property (callback)
Dietmar Maurer [Tue, 21 Sep 2021 05:58:47 +0000 (07:58 +0200)]
make get_index and ApiConfig property (callback)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorest server: simplify get_index() method signature
Dietmar Maurer [Tue, 21 Sep 2021 05:58:46 +0000 (07:58 +0200)]
rest server: simplify get_index() method signature

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove normalize_uri_path and extract_cookie to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:45 +0000 (07:58 +0200)]
move normalize_uri_path and extract_cookie to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/tools/compression.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:44 +0000 (07:58 +0200)]
move src/tools/compression.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/server/formatter.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:43 +0000 (07:58 +0200)]
move src/server/formatter.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/server/environment.rs to proxmox-rest-server crate
Dietmar Maurer [Tue, 21 Sep 2021 05:58:42 +0000 (07:58 +0200)]
move src/server/environment.rs to proxmox-rest-server crate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove src/tools/daemon.rs to proxmox-rest-server workspace
Dietmar Maurer [Tue, 21 Sep 2021 05:58:41 +0000 (07:58 +0200)]
move src/tools/daemon.rs to proxmox-rest-server workspace

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomove ApiConfig, FileLogger and CommandoSocket to proxmox-rest-server workspace
Dietmar Maurer [Tue, 21 Sep 2021 05:58:40 +0000 (07:58 +0200)]
move ApiConfig, FileLogger and CommandoSocket to proxmox-rest-server workspace

ApiConfig: avoid using  pbs_config::backup_user()
CommandoSocket: avoid using  pbs_config::backup_user()
FileLogger: avoid using  pbs_config::backup_user()
- use atomic_open_or_create_file()

Auth Trait: moved definitions to proxmox-rest-server/src/lib.rs
- removed CachedUserInfo patrameter
- return user as String (not Authid)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agostart new proxmox-rest-server workspace
Dietmar Maurer [Tue, 21 Sep 2021 05:58:39 +0000 (07:58 +0200)]
start new proxmox-rest-server workspace

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoavoid type re-exports
Dietmar Maurer [Tue, 14 Sep 2021 06:35:43 +0000 (08:35 +0200)]
avoid type re-exports

2 years agomore api type cleanups: avoid re-exports
Dietmar Maurer [Fri, 10 Sep 2021 10:25:32 +0000 (12:25 +0200)]
more api type cleanups: avoid re-exports

2 years agomove user configuration to pbs_config workspace
Dietmar Maurer [Fri, 10 Sep 2021 04:53:53 +0000 (06:53 +0200)]
move user configuration to pbs_config workspace

Also moved memcom.rs and cached_user_info.rs

2 years agostart new pbs-config workspace
Dietmar Maurer [Thu, 2 Sep 2021 10:47:11 +0000 (12:47 +0200)]
start new pbs-config workspace

moved src/config/domains.rs

2 years agomove channel/stream helpers to pbs-tools
Wolfgang Bumiller [Tue, 20 Jul 2021 09:26:29 +0000 (11:26 +0200)]
move channel/stream helpers to pbs-tools

pbs_tools
  ::blocking: std/async wrapping with block_in_place
  ::stream: stream <-> AsyncRead/AsyncWrite wrapping

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agomove client to pbs-client subcrate
Wolfgang Bumiller [Mon, 19 Jul 2021 08:50:18 +0000 (10:50 +0200)]
move client to pbs-client subcrate

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agorest: log response: avoid unnecessary mut on variable
Thomas Lamprecht [Sun, 11 Jul 2021 11:05:16 +0000 (13:05 +0200)]
rest: log response: avoid unnecessary mut on variable

a match expresses the fallback slightly nicer and needs no mut,
which is always nice to avoid.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotest fixups
Wolfgang Bumiller [Wed, 7 Jul 2021 10:14:07 +0000 (12:14 +0200)]
test fixups

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agosplit out pbs-buildcfg module
Wolfgang Bumiller [Tue, 6 Jul 2021 09:56:35 +0000 (11:56 +0200)]
split out pbs-buildcfg module

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoREST: set error message extenesion for bad-request response log
Thomas Lamprecht [Sat, 3 Jul 2021 18:49:16 +0000 (20:49 +0200)]
REST: set error message extenesion for bad-request response log

We send it already to the user via the response body, but the
log_response does not has, nor wants to have FWIW, access to the
async body stream, so pass it through the ErrorMessageExtension
mechanism like we do else where.

Note that this is not only useful for PBS API proxy/daemon but also
the REST server of the file-restore daemon running inside the restore
VM, and it really is *very* helpful to debug things there..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoREST: rust fmt
Thomas Lamprecht [Sat, 3 Jul 2021 19:05:25 +0000 (21:05 +0200)]
REST: rust fmt

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agorefactor send_command
Wolfgang Bumiller [Tue, 11 May 2021 13:53:59 +0000 (15:53 +0200)]
refactor send_command

- refactor the combinators,
- make it take a `&T: Serialize` instead of a Value, and
  allow sending the raw string via `send_raw_command`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoserver/rest: fix new type ambiguity
Thomas Lamprecht [Thu, 22 Apr 2021 19:24:40 +0000 (21:24 +0200)]
server/rest: fix new type ambiguity

basically the same as commit 5fb15b781ef48bce2aa4d5f590e1f93155318f67
Will be required once we get to use a newer rustc, at least the
client build for archlinux was broken due to this.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoenable tape backup by default
Thomas Lamprecht [Mon, 12 Apr 2021 10:31:56 +0000 (12:31 +0200)]
enable tape backup by default

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoserver/rest: add ApiAuth trait to make user auth generic
Stefan Reiter [Wed, 31 Mar 2021 10:21:51 +0000 (12:21 +0200)]
server/rest: add ApiAuth trait to make user auth generic

This allows switching the base user identification/authentication method
in the rest server. Will initially be used for single file restore VMs,
where authentication is based on a ticket file, not the PBS user
backend (PAM/local).

To avoid putting generic types into the RestServer type for this, we
merge the two calls "extract_auth_data" and "check_auth" into a single
one, which can use whatever type it wants internally.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoserver: rest: collapse nested if for less indentation
Thomas Lamprecht [Wed, 7 Apr 2021 15:57:19 +0000 (17:57 +0200)]
server: rest: collapse nested if for less indentation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoserver: rest: switch from fastest to default deflate compression level
Thomas Lamprecht [Wed, 7 Apr 2021 15:12:01 +0000 (17:12 +0200)]
server: rest: switch from fastest to default deflate compression level

I made some comparision with bombardier[0], the one listed here are
30s looped requests with two concurrent clients:

[ static download of ext-all.js ]:
  lvl                              avg /   stdev  / max
 none        1.98 MiB  100 %    5.17ms /  1.30ms / 32.38ms
 fastest   813.14 KiB   42 %   20.53ms /  2.85ms / 58.71ms
 default   626.35 KiB   30 %   39.70ms /  3.98ms / 85.47ms

[ deterministic (pre-defined data), but real API call ]:
  lvl                              avg /   stdev  / max
 none      129.09 KiB  100 %    2.70ms / 471.58us / 26.93ms
 fastest    42.12 KiB   33 %    3.47ms / 606.46us / 32.42ms
 default    34.82 KiB   27 %    4.28ms / 737.99us / 33.75ms

The reduction is quite better with default, but it's also slower, but
only when testing over unconstrained network. For real world
scenarios where compression actually matters, e.g., when using a
spotty train connection, we will be faster again with better
compression.

A GPRS limited connection (Firefox developer console) requires the
following load (until the DOMContentLoaded event triggered) times:
  lvl        t      x faster
 none      9m 18.6s   x 1.0
 fastest   3m 20.0s   x 2.8
 default   2m 30.0s   x 3.7

So for worst case using sligthly more CPU time on the server has a
tremendous effect on the client load time.

Using a more realistical example and limiting for "Good 2G" gives:

 none      1m  1.8s   x 1.0
 fastest      22.6s   x 2.7
 default      16.6s   x 3.7

16s is somewhat OK, >1m just isn't...

So, use default level to ensure we get bearable load times on
clients, and if we want to improve transmission size AND speed then
we could always use a in-memory cache, only a few MiB would be
required for the compressable static files we server.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoserver/rest: compress static files
Dominik Csapak [Tue, 6 Apr 2021 09:03:45 +0000 (11:03 +0200)]
server/rest: compress static files

compress them on the fly
and refactor the size limit for chunking files

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agoserver/rest: compress api calls
Dominik Csapak [Tue, 6 Apr 2021 09:03:44 +0000 (11:03 +0200)]
server/rest: compress api calls

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agoserver/rest: add helper to extract compression headers
Dominik Csapak [Tue, 6 Apr 2021 09:03:43 +0000 (11:03 +0200)]
server/rest: add helper to extract compression headers

for now we only extract 'deflate'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agotools/compression: add DeflateEncoder and helpers
Dominik Csapak [Tue, 6 Apr 2021 09:03:42 +0000 (11:03 +0200)]
tools/compression: add DeflateEncoder and helpers

implements a deflate encoder that can compress anything that implements
AsyncRead + Unpin into a file with the helper 'compress'

if the inner type is a Stream, it implements Stream itself, this way
some streaming data can be streamed compressed

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agotools: add compression module
Dominik Csapak [Tue, 6 Apr 2021 09:03:41 +0000 (11:03 +0200)]
tools: add compression module

only contains a basic enum for the different compresssion methods

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agoserver/rest: drop now unused imports
Thomas Lamprecht [Thu, 1 Apr 2021 09:53:13 +0000 (11:53 +0200)]
server/rest: drop now unused imports

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoserver/rest: extract auth to seperate module
Stefan Reiter [Wed, 31 Mar 2021 10:21:50 +0000 (12:21 +0200)]
server/rest: extract auth to seperate module

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoserver/rest: fix type ambiguity
Thomas Lamprecht [Mon, 29 Mar 2021 10:00:38 +0000 (12:00 +0200)]
server/rest: fix type ambiguity

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoserver/rest: rust format
Thomas Lamprecht [Mon, 29 Mar 2021 06:17:26 +0000 (08:17 +0200)]
server/rest: rust format

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoui: enable experimental tape UI if tape.cfg exists
Dietmar Maurer [Wed, 3 Mar 2021 07:27:54 +0000 (08:27 +0100)]
ui: enable experimental tape UI if tape.cfg exists

3 years agorest: implement tower service for UnixStream
Stefan Reiter [Tue, 16 Feb 2021 17:07:01 +0000 (18:07 +0100)]
rest: implement tower service for UnixStream

This allows anything that can be represented as a UnixStream to be used
as transport for an API server (e.g. virtio sockets).

A tower service expects an IP address as it's peer, which we can't
reliably provide for unix socket based transports, so just fake one.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoallow complex Futures in tower_service impl
Fabian Grünbichler [Mon, 25 Jan 2021 13:42:49 +0000 (14:42 +0100)]
allow complex Futures in tower_service impl

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoclippy: fix/allow needless_range_loop
Fabian Grünbichler [Tue, 19 Jan 2021 14:03:04 +0000 (15:03 +0100)]
clippy: fix/allow needless_range_loop

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoclippy: us *_or_else with function calls
Fabian Grünbichler [Tue, 19 Jan 2021 13:04:46 +0000 (14:04 +0100)]
clippy: us *_or_else with function calls

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoclippy: use strip_prefix instead of manual stripping
Fabian Grünbichler [Mon, 18 Jan 2021 12:50:28 +0000 (13:50 +0100)]
clippy: use strip_prefix instead of manual stripping

it's less error-prone (off-by-one!)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoclippy: remove unnecessary clones
Fabian Grünbichler [Fri, 15 Jan 2021 13:38:27 +0000 (14:38 +0100)]
clippy: remove unnecessary clones

and from::<T>(T)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoproxmox 0.10: adapt to moved ParameterSchema
Fabian Grünbichler [Wed, 13 Jan 2021 13:48:33 +0000 (14:48 +0100)]
proxmox 0.10: adapt to moved ParameterSchema

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agocleanup: remove unnecessary 'mut' and '.clone()'
Fabian Grünbichler [Fri, 4 Dec 2020 10:53:34 +0000 (11:53 +0100)]
cleanup: remove unnecessary 'mut' and '.clone()'

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agotokio 1.0: update to new tokio-openssl interface
Fabian Grünbichler [Mon, 11 Jan 2021 08:51:21 +0000 (09:51 +0100)]
tokio 1.0: update to new tokio-openssl interface

connect/accept are now happening on pinned SslStreams

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agotokio 1.0: delay -> sleep
Fabian Grünbichler [Thu, 3 Dec 2020 15:04:23 +0000 (16:04 +0100)]
tokio 1.0: delay -> sleep

almost the same thing, new name(s), no longer Unpin

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoapi: tfa management and login
Wolfgang Bumiller [Mon, 16 Nov 2020 13:37:22 +0000 (14:37 +0100)]
api: tfa management and login

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoadaptions for proxmox 0.9 and proxmox-api-macro 0.3
Wolfgang Bumiller [Fri, 18 Dec 2020 11:26:07 +0000 (12:26 +0100)]
adaptions for proxmox 0.9 and proxmox-api-macro 0.3

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>