Re: relayd(8) websockets proxy broken after adding websockets support

2019-04-12 Thread Rivo Nurges
Hi!

I previously proposed following.

https://marc.info/?l=openbsd-tech=155190594005692=2

Rivo

On 4/10/19 2:38 PM, Pavel Korovin wrote:
> Dear all,
> 
> After websockets support was added in relayd(8),
> https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/relayd/relay_http.c.diff?r1=1.71=1.72=h
> the connections to services usging websockets are broken.
> 
> I checked what caused this breakage, and found that the check for the
> "Connection" HTTP request header strictly checks for "Upgrade" value (line 
> 402):
> 
> if (cre->dir == RELAY_DIR_REQUEST) {
>   if (strcasecmp("Connection", key) == 0 &&
>   strcasecmp("Upgrade", value) == 0)
>   priv->http_upgrade_req |=
>   HTTP_CONNECTION_UPGRADE;
> 
> while the browser can also send (and sends)
>   Connection: keep-alive, Upgrade
> 
> Websockets work fine if I add keep-alive to the list of values, but I'm sure
> this must be fixed in some other way,
> 
> --- usr.sbin/relayd/relay_http.c.orig   Wed Apr  3 17:41:00 2019
> +++ usr.sbin/relayd/relay_http.cWed Apr  3 21:31:37 2019
> @@ -400,7 +400,8 @@
>  if (cre->line != 1) {
>  if (cre->dir == RELAY_DIR_REQUEST) {
>  if (strcasecmp("Connection", key) == 0 &&
> -   strcasecmp("Upgrade", value) == 0)
> +  (strcasecmp("Upgrade", value) == 0 ||
> +  strcasecmp("keep-alive, Upgrade", value) 
> == 0))
>  priv->http_upgrade_req |=
>  HTTP_CONNECTION_UPGRADE;
>  if (strcasecmp("Upgrade", key) == 0 &&
> 



relayd(8) websockets proxy broken after adding websockets support

2019-04-10 Thread Pavel Korovin
Dear all,

After websockets support was added in relayd(8),
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/relayd/relay_http.c.diff?r1=1.71=1.72=h
the connections to services usging websockets are broken.

I checked what caused this breakage, and found that the check for the
"Connection" HTTP request header strictly checks for "Upgrade" value (line 402):

   if (cre->dir == RELAY_DIR_REQUEST) {
if (strcasecmp("Connection", key) == 0 &&
strcasecmp("Upgrade", value) == 0)
priv->http_upgrade_req |=
HTTP_CONNECTION_UPGRADE;

while the browser can also send (and sends)
Connection: keep-alive, Upgrade

Websockets work fine if I add keep-alive to the list of values, but I'm sure
this must be fixed in some other way,

--- usr.sbin/relayd/relay_http.c.orig   Wed Apr  3 17:41:00 2019

+++ usr.sbin/relayd/relay_http.cWed Apr  3 21:31:37 2019

@@ -400,7 +400,8 @@ 

if (cre->line != 1) {   

if (cre->dir == RELAY_DIR_REQUEST) {

if (strcasecmp("Connection", key) == 0 &&   

-   strcasecmp("Upgrade", value) == 0)  

+  (strcasecmp("Upgrade", value) == 0 ||

+  strcasecmp("keep-alive, Upgrade", value) == 
0))  
priv->http_upgrade_req |=   

HTTP_CONNECTION_UPGRADE;

if (strcasecmp("Upgrade", key) == 0 &&

-- 
With best regards,
Pavel Korovin