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 330F671044 for ; Mon, 17 May 2021 15:11:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 30CA72C24A for ; Mon, 17 May 2021 15:11:07 +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 5D4282C235 for ; Mon, 17 May 2021 15:11:02 +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 356BB465C0 for ; Mon, 17 May 2021 15:11:02 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 17 May 2021 15:11:00 +0200 Message-Id: <20210517131101.23490-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210517131101.23490-1-d.csapak@proxmox.com> References: <20210517131101.23490-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.015 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 Subject: [pbs-devel] [PATCH proxmox 1/2] proxmox-http/websocket: remove code for 'text' frames 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, 17 May 2021 13:11:07 -0000 we never actually sent text frames, nor did any client request them. Also, no validity check ever ocurred, so technically it was against the spec. Simply remove the code handling sending out text frames. If we need to actually handle that, we can always create a 'WebSocketStringWriter' or similar. Signed-off-by: Dominik Csapak --- proxmox-http/src/websocket/mod.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/proxmox-http/src/websocket/mod.rs b/proxmox-http/src/websocket/mod.rs index b8f31dc..e6ab998 100644 --- a/proxmox-http/src/websocket/mod.rs +++ b/proxmox-http/src/websocket/mod.rs @@ -243,7 +243,6 @@ pub fn create_frame( /// ``` pub struct WebSocketWriter { writer: W, - text: bool, mask: Option<[u8; 4]>, frame: Option<(Vec, usize, usize)>, } @@ -251,10 +250,9 @@ pub struct WebSocketWriter { impl WebSocketWriter { /// Creates a new WebSocketWriter which will use the given mask (if any), /// and mark the frames as either 'Text' or 'Binary' - pub fn new(mask: Option<[u8; 4]>, text: bool, writer: W) -> WebSocketWriter { + pub fn new(mask: Option<[u8; 4]>, writer: W) -> WebSocketWriter { WebSocketWriter { writer, - text, mask, frame: None, } @@ -275,11 +273,7 @@ impl AsyncWrite for WebSocketWriter { fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll> { let this = Pin::get_mut(self); - let frametype = if this.text { - OpCode::Text - } else { - OpCode::Binary - }; + let frametype = OpCode::Binary; if this.frame.is_none() { // create frame buf @@ -656,9 +650,7 @@ impl AsyncRead for WebSocketReader { pub const MAGIC_WEBSOCKET_GUID: &str = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; /// Provides methods for connecting a WebSocket endpoint with another -pub struct WebSocket { - text: bool, -} +pub struct WebSocket; impl WebSocket { /// Returns a new WebSocket instance and the generates the correct @@ -709,7 +701,7 @@ impl WebSocket { .header(SEC_WEBSOCKET_PROTOCOL, ws_proto) .body(Body::empty())?; - Ok((Self { text }, response)) + Ok((Self, response)) } async fn handle_channel_message( @@ -798,7 +790,7 @@ impl WebSocket { let (tx, mut rx) = mpsc::unbounded_channel(); let mut wsreader = WebSocketReader::new(usreader, tx); - let mut wswriter = WebSocketWriter::new(None, self.text, uswriter); + let mut wswriter = WebSocketWriter::new(None, uswriter); let ws_future = tokio::io::copy(&mut wsreader, &mut dswriter); let term_future = Self::copy_to_websocket(&mut dsreader, &mut wswriter, &mut rx); -- 2.20.1