public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH http-server 1/2] AnyEvent/websocket_proxy: remove 'base64' handling
Date: Mon, 17 May 2021 15:07:34 +0200	[thread overview]
Message-ID: <20210517130735.17568-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210517130735.17568-1-d.csapak@proxmox.com>

novnc does not support this anymore since 2015, and neither does
our xtermjs client. it is also not listed in IANAs list of websocket
protocols [0].

so simply drop it and only send out binary frames and don't decode text frames

0: https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PVE/APIServer/AnyEvent.pm | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index f0e2e68..a7d31cc 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -496,15 +496,6 @@ sub websocket_proxy {
 
 	my $max_payload_size = 128*1024;
 
-	my $binary;
-	if ($wsproto eq 'binary') {
-	    $binary = 1;
-	} elsif ($wsproto eq 'base64') {
-	    $binary = 0;
-	} else {
-	    die "websocket_proxy: unsupported protocol '$wsproto'\n";
-	}
-
 	if ($param->{port}) {
 	    $remhost = 'localhost';
 	    $remport = $param->{port};
@@ -520,13 +511,9 @@ sub websocket_proxy {
 
 	    my $string;
 	    my $payload;
-	    if ($binary) {
-		$string = $opcode ? $opcode : "\x82"; # binary frame
-		$payload = $$data;
-	    } else {
-		$string = $opcode ? $opcode : "\x81"; # text frame
-		$payload = encode_base64($$data, '');
-	    }
+
+	    $string = $opcode ? $opcode : "\x82"; # binary frame
+	    $payload = $$data;
 
 	    my $payload_len = length($payload);
 	    if ($payload_len <= 125) {
@@ -635,8 +622,6 @@ sub websocket_proxy {
 			$payload ^= $mask;
 		    }
 
-		    $payload = decode_base64($payload) if !$binary;
-
 		    if ($opcode == 1 || $opcode == 2) {
 			$reqstate->{proxyhdl}->push_write($payload) if $reqstate->{proxyhdl};
 		    } elsif ($opcode == 8) {
-- 
2.20.1





  reply	other threads:[~2021-05-17 13:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 13:07 [pve-devel] [PATCH http-server 0/2] remove unnecessary websocket code Dominik Csapak
2021-05-17 13:07 ` Dominik Csapak [this message]
2021-05-17 13:07 ` [pve-devel] [PATCH http-server 2/2] AnyEvent/websocket_proxy: drop handling of websocket subprotocols Dominik Csapak
2021-05-18  8:33 ` [pve-devel] applied-series: [PATCH http-server 0/2] remove unnecessary websocket code Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210517130735.17568-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal