Skip to content

Commit

Permalink
bugfix in WS upgrade logic
Browse files Browse the repository at this point in the history
  • Loading branch information
thelamer committed May 25, 2019
1 parent 68819ae commit 423a793
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -110,9 +110,9 @@ proxyServer.on('upgrade', function (req, socket) {
}
}
else{
res.statusCode = 401;
res.setHeader('WWW-Authenticate', 'Basic realm="Login"');
res.end('<html><body>You shall not pass</body></html>');
socket.statusCode = 401;
socket.setHeader('WWW-Authenticate', 'Basic realm="Login"');
socket.end('<html><body>You shall not pass</body></html>');
}
});

Expand Down

0 comments on commit 423a793

Please sign in to comment.