From 423a793cf417ea7bb2248d4032254f1784d8cac3 Mon Sep 17 00:00:00 2001 From: thelamer Date: Fri, 24 May 2019 23:55:03 -0700 Subject: [PATCH] bugfix in WS upgrade logic --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 1352fd6..8aca03a 100644 --- a/index.js +++ b/index.js @@ -100,7 +100,7 @@ proxyServer.on('upgrade', function (req, socket) { var subdomain = req.headers.host.split('.')[0]; // make sure port is ok if(isNaN(parseFloat(subdomain)) || parseInt(subdomain) <= 0 || parseInt(subdomain) >= 65536){ - res.end('Not a valid SubDomain'); + socket.end('Not a valid SubDomain'); } else{ var endpoint = 'http://' + ip + ':' + subdomain; @@ -110,9 +110,9 @@ proxyServer.on('upgrade', function (req, socket) { } } else{ - res.statusCode = 401; - res.setHeader('WWW-Authenticate', 'Basic realm="Login"'); - res.end('You shall not pass'); + socket.statusCode = 401; + socket.setHeader('WWW-Authenticate', 'Basic realm="Login"'); + socket.end('You shall not pass'); } });