From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E4DE56B273 for ; Mon, 20 Sep 2021 11:13:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3AE811E478 for ; Mon, 20 Sep 2021 11:13:51 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C09961E3EF for ; Mon, 20 Sep 2021 11:13:46 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9A9C0449A5; Mon, 20 Sep 2021 11:13:46 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Mon, 20 Sep 2021 11:13:38 +0200 Message-Id: <20210920091340.3251578-13-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210920091340.3251578-1-dietmar@proxmox.com> References: <20210920091340.3251578-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.630 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup rebase 13/15] move src/server/rest.rs to pbs-server crate X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Sep 2021 09:13:51 -0000 --- pbs-server/Cargo.toml | 4 ++++ pbs-server/src/lib.rs | 3 +++ {src/server => pbs-server/src}/rest.rs | 6 +++--- src/bin/proxmox-backup-api.rs | 3 +-- src/bin/proxmox-backup-proxy.rs | 3 +-- src/bin/proxmox-restore-daemon.rs | 4 +--- src/server/h2service.rs | 2 +- src/server/mod.rs | 3 --- 8 files changed, 14 insertions(+), 14 deletions(-) rename {src/server => pbs-server/src}/rest.rs (99%) diff --git a/pbs-server/Cargo.toml b/pbs-server/Cargo.toml index 581016c8..7b2d54c1 100644 --- a/pbs-server/Cargo.toml +++ b/pbs-server/Cargo.toml @@ -16,9 +16,13 @@ libc = "0.2" log = "0.4" nix = "0.19.1" percent-encoding = "2.1" +regex = "1.2" serde = { version = "1.0", features = [] } serde_json = "1.0" tokio = { version = "1.6", features = ["signal", "process"] } +tokio-openssl = "0.6.1" +tower-service = "0.3.0" +url = "2.1" proxmox = { version = "0.13.2", features = [ "router"] } diff --git a/pbs-server/src/lib.rs b/pbs-server/src/lib.rs index 55a10ca6..2f29f9cd 100644 --- a/pbs-server/src/lib.rs +++ b/pbs-server/src/lib.rs @@ -26,6 +26,9 @@ pub use file_logger::{FileLogger, FileLogOptions}; mod api_config; pub use api_config::ApiConfig; +mod rest; +pub use rest::{RestServer, handle_api_request}; + pub enum AuthError { Generic(Error), NoData, diff --git a/src/server/rest.rs b/pbs-server/src/rest.rs similarity index 99% rename from src/server/rest.rs rename to pbs-server/src/rest.rs index 0f367a48..dde47b55 100644 --- a/src/server/rest.rs +++ b/pbs-server/src/rest.rs @@ -32,11 +32,11 @@ use proxmox::http_err; use pbs_tools::compression::{DeflateEncoder, Level}; use pbs_tools::stream::AsyncReaderStream; -use pbs_server::{ + +use crate::{ ApiConfig, FileLogger, AuthError, RestEnvironment, CompressionMethod, - extract_cookie, normalize_uri_path, + extract_cookie, normalize_uri_path, formatter::*, }; -use pbs_server::formatter::*; extern "C" { fn tzset(); diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs index f9f82ee8..b8b64dc4 100644 --- a/src/bin/proxmox-backup-api.rs +++ b/src/bin/proxmox-backup-api.rs @@ -10,12 +10,11 @@ use proxmox::api::RpcEnvironmentType; use proxmox::tools::fs::CreateOptions; use pbs_tools::auth::private_auth_key; -use pbs_server::ApiConfig; +use pbs_server::{ApiConfig, RestServer}; use proxmox_backup::server::{ self, auth::default_api_auth, - rest::*, }; use pbs_server::daemon; diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index f9277644..48407ce5 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -19,14 +19,13 @@ use proxmox::api::RpcEnvironmentType; use proxmox::sys::linux::socket::set_tcp_keepalive; use proxmox::tools::fs::CreateOptions; -use pbs_server::ApiConfig; +use pbs_server::{ApiConfig, RestServer}; use proxmox_backup::{ backup::DataStore, server::{ auth::default_api_auth, WorkerTask, - rest::*, jobstate::{ self, Job, diff --git a/src/bin/proxmox-restore-daemon.rs b/src/bin/proxmox-restore-daemon.rs index 38c96194..92562415 100644 --- a/src/bin/proxmox-restore-daemon.rs +++ b/src/bin/proxmox-restore-daemon.rs @@ -21,9 +21,7 @@ use hyper::header; use proxmox::api::RpcEnvironmentType; use pbs_client::DEFAULT_VSOCK_PORT; -use pbs_server::ApiConfig; - -use proxmox_backup::server::rest::*; +use pbs_server::{ApiConfig, RestServer}; mod proxmox_restore_daemon; use proxmox_restore_daemon::*; diff --git a/src/server/h2service.rs b/src/server/h2service.rs index 9b473bbf..0d2e0ece 100644 --- a/src/server/h2service.rs +++ b/src/server/h2service.rs @@ -61,7 +61,7 @@ impl H2Service { future::ok((formatter.format_error)(err)).boxed() } Some(api_method) => { - crate::server::rest::handle_api_request( + pbs_server::handle_api_request( self.rpcenv.clone(), api_method, formatter, parts, body, uri_param).boxed() } } diff --git a/src/server/mod.rs b/src/server/mod.rs index fe6463b9..481a7d52 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -55,9 +55,6 @@ pub use worker_task::*; mod h2service; pub use h2service::*; -#[macro_use] -pub mod rest; - pub mod jobstate; mod verify_job; -- 2.30.2