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 1529470AAD for ; Fri, 14 May 2021 15:45:42 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 084FB17B55 for ; Fri, 14 May 2021 15:45:12 +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 4BA8F17AD2 for ; Fri, 14 May 2021 15:45:08 +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 1E9DB46552 for ; Fri, 14 May 2021 15:45:03 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Fri, 14 May 2021 15:44:39 +0200 Message-Id: <20210514134457.1447930-4-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210514134457.1447930-1-f.gruenbichler@proxmox.com> References: <20210514134457.1447930-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.014 Adjusted score from AWL reputation of From: address 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mod.rs, lib.rs, websocket.rs] Subject: [pbs-devel] [PATCH proxmox 03/13] http: takeover websocket feature from proxmox 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: Fri, 14 May 2021 13:45:42 -0000 adapted: use statements for proxmox::*, use statements for doctests Signed-off-by: Fabian Grünbichler --- Notes: BREAKING change! requires corresponding update in proxmox-backup proxmox-http/Cargo.toml | 10 ++++++- proxmox-http/src/lib.rs | 2 ++ .../src/websocket/mod.rs | 14 ++++----- proxmox/Cargo.toml | 3 +- proxmox/debian/control | 29 ++----------------- proxmox/src/tools/mod.rs | 3 -- 6 files changed, 21 insertions(+), 40 deletions(-) rename proxmox/src/tools/websocket.rs => proxmox-http/src/websocket/mod.rs (98%) diff --git a/proxmox-http/Cargo.toml b/proxmox-http/Cargo.toml index 9c2d3c5..641ace2 100644 --- a/proxmox-http/Cargo.toml +++ b/proxmox-http/Cargo.toml @@ -12,9 +12,17 @@ description = "Proxmox HTTP library" exclude = [ "debian" ] [dependencies] +anyhow = "1.0" +base64 = { version = "0.12", optional = true } +futures = { version = "0.3", optional = true } +hyper = { version = "0.14", features = [ "full" ], optional = true } +openssl = { version = "0.10", optional = true } +tokio = { version = "1.0", features = [], optional = true } + +proxmox = { path = "../proxmox", optional = true, version = "0.11.3", default-features = false } [features] default = [] client = [] -websocket = [] +websocket = [ "base64", "futures", "hyper", "openssl", "proxmox/tokio", "tokio/io-util", "tokio/sync" ] diff --git a/proxmox-http/src/lib.rs b/proxmox-http/src/lib.rs index e69de29..31e44af 100644 --- a/proxmox-http/src/lib.rs +++ b/proxmox-http/src/lib.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "websocket")] +pub mod websocket; diff --git a/proxmox/src/tools/websocket.rs b/proxmox-http/src/websocket/mod.rs similarity index 98% rename from proxmox/src/tools/websocket.rs rename to proxmox-http/src/websocket/mod.rs index 83679b6..aac7304 100644 --- a/proxmox/src/tools/websocket.rs +++ b/proxmox-http/src/websocket/mod.rs @@ -22,8 +22,8 @@ use tokio::sync::mpsc; use futures::future::FutureExt; use futures::ready; -use crate::sys::error::io_err_other; -use crate::tools::byte_buffer::ByteBuffer; +use proxmox::sys::error::io_err_other; +use proxmox::tools::byte_buffer::ByteBuffer; // see RFC6455 section 7.4.1 #[derive(Debug, Clone, Copy)] @@ -146,7 +146,7 @@ fn mask_bytes(mask: Option<[u8; 4]>, data: &mut [u8]) { /// /// A normal Frame /// ``` -/// # use proxmox::tools::websocket::*; +/// # use proxmox_http::websocket::*; /// # use std::io; /// # fn main() -> Result<(), WebSocketError> { /// let data = vec![0,1,2,3,4]; @@ -159,7 +159,7 @@ fn mask_bytes(mask: Option<[u8; 4]>, data: &mut [u8]) { /// /// A masked Frame /// ``` -/// # use proxmox::tools::websocket::*; +/// # use proxmox_http::websocket::*; /// # use std::io; /// # fn main() -> Result<(), WebSocketError> { /// let data = vec![0,1,2,3,4]; @@ -172,7 +172,7 @@ fn mask_bytes(mask: Option<[u8; 4]>, data: &mut [u8]) { /// /// A ping Frame /// ``` -/// # use proxmox::tools::websocket::*; +/// # use proxmox_http::websocket::*; /// # use std::io; /// # fn main() -> Result<(), WebSocketError> { /// let data = vec![0,1,2,3,4]; @@ -233,7 +233,7 @@ pub fn create_frame( /// /// Example usage: /// ``` -/// # use proxmox::tools::websocket::*; +/// # use proxmox_http::websocket::*; /// # use std::io; /// # use tokio::io::{AsyncWrite, AsyncWriteExt}; /// async fn code(writer: I) -> io::Result<()> { @@ -352,7 +352,7 @@ impl FrameHeader { /// /// Example: /// ``` - /// # use proxmox::tools::websocket::*; + /// # use proxmox_http::websocket::*; /// # use std::io; /// # fn main() -> Result<(), WebSocketError> { /// let frame = create_frame(None, &[0,1,2,3], OpCode::Ping)?; diff --git a/proxmox/Cargo.toml b/proxmox/Cargo.toml index da46e74..5698969 100644 --- a/proxmox/Cargo.toml +++ b/proxmox/Cargo.toml @@ -50,7 +50,7 @@ proxmox-api-macro = { path = "../proxmox-api-macro", optional = true, version = proxmox-sortable-macro = { path = "../proxmox-sortable-macro", optional = true, version = "0.1.1" } [features] -default = [ "cli", "router", "tfa", "u2f", "websocket" ] +default = [ "cli", "router", "tfa", "u2f" ] sortable-macro = ["proxmox-sortable-macro"] # api: @@ -58,7 +58,6 @@ api-macro = ["proxmox-api-macro"] test-harness = [] cli = [ "router", "hyper", "tokio" ] router = [ "futures", "hyper", "tokio" ] -websocket = [ "futures", "hyper", "openssl", "tokio/sync", "tokio/io-util", "openssl" ] tfa = [ "openssl" ] u2f = [ "base32" ] diff --git a/proxmox/debian/control b/proxmox/debian/control index 9091cb8..0ba2bc9 100644 --- a/proxmox/debian/control +++ b/proxmox/debian/control @@ -28,15 +28,12 @@ Build-Depends: debhelper (>= 11), librust-serde-json-1+default-dev , librust-textwrap-0.11+default-dev , librust-tokio-1+default-dev , - librust-tokio-1+io-util-dev , - librust-tokio-1+sync-dev , librust-url-2+default-dev (>= 2.1-~~) , uuid-dev , uuid-dev , uuid-dev , uuid-dev , uuid-dev , - uuid-dev , uuid-dev Maintainer: Proxmox Support Team Standards-Version: 4.4.1 @@ -79,8 +76,7 @@ Suggests: librust-proxmox+proxmox-sortable-macro-dev (= ${binary:Version}), librust-proxmox+router-dev (= ${binary:Version}), librust-proxmox+tokio-dev (= ${binary:Version}), - librust-proxmox+tokio-stream-dev (= ${binary:Version}), - librust-proxmox+websocket-dev (= ${binary:Version}) + librust-proxmox+tokio-stream-dev (= ${binary:Version}) Provides: librust-proxmox+test-harness-dev (= ${binary:Version}), librust-proxmox-0-dev (= ${binary:Version}), @@ -162,8 +158,7 @@ Depends: librust-proxmox+cli-dev (= ${binary:Version}), librust-proxmox+router-dev (= ${binary:Version}), librust-proxmox+tfa-dev (= ${binary:Version}), - librust-proxmox+u2f-dev (= ${binary:Version}), - librust-proxmox+websocket-dev (= ${binary:Version}) + librust-proxmox+u2f-dev (= ${binary:Version}) Provides: librust-proxmox-0+default-dev (= ${binary:Version}), librust-proxmox-0.11+default-dev (= ${binary:Version}), @@ -308,23 +303,3 @@ Provides: Description: Proxmox library - feature "tokio-stream" This metapackage enables feature "tokio-stream" for the Rust proxmox crate, by pulling in any additional dependencies needed by that feature. - -Package: librust-proxmox+websocket-dev -Architecture: any -Multi-Arch: same -Depends: - ${misc:Depends}, - librust-proxmox-dev (= ${binary:Version}), - librust-futures-0.3+default-dev, - librust-hyper-0.14+default-dev, - librust-hyper-0.14+full-dev, - librust-openssl-0.10+default-dev, - librust-tokio-1+io-util-dev, - librust-tokio-1+sync-dev -Provides: - librust-proxmox-0+websocket-dev (= ${binary:Version}), - librust-proxmox-0.11+websocket-dev (= ${binary:Version}), - librust-proxmox-0.11.4+websocket-dev (= ${binary:Version}) -Description: Proxmox library - feature "websocket" - This metapackage enables feature "websocket" for the Rust proxmox crate, by - pulling in any additional dependencies needed by that feature. diff --git a/proxmox/src/tools/mod.rs b/proxmox/src/tools/mod.rs index 45f46f9..b172b09 100644 --- a/proxmox/src/tools/mod.rs +++ b/proxmox/src/tools/mod.rs @@ -21,9 +21,6 @@ pub mod time; pub mod uuid; pub mod vec; -#[cfg(feature = "websocket")] -pub mod websocket; - #[cfg(feature = "tfa")] pub mod tfa; -- 2.20.1