Skip to content

Commit 423a793

Browse files
committed
bugfix in WS upgrade logic
1 parent 68819ae commit 423a793

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ proxyServer.on('upgrade', function (req, socket) {
100100
var subdomain = req.headers.host.split('.')[0];
101101
// make sure port is ok
102102
if(isNaN(parseFloat(subdomain)) || parseInt(subdomain) <= 0 || parseInt(subdomain) >= 65536){
103-
res.end('Not a valid SubDomain');
103+
socket.end('Not a valid SubDomain');
104104
}
105105
else{
106106
var endpoint = 'http://' + ip + ':' + subdomain;
@@ -110,9 +110,9 @@ proxyServer.on('upgrade', function (req, socket) {
110110
}
111111
}
112112
else{
113-
res.statusCode = 401;
114-
res.setHeader('WWW-Authenticate', 'Basic realm="Login"');
115-
res.end('<html><body>You shall not pass</body></html>');
113+
socket.statusCode = 401;
114+
socket.setHeader('WWW-Authenticate', 'Basic realm="Login"');
115+
socket.end('<html><body>You shall not pass</body></html>');
116116
}
117117
});
118118

0 commit comments

Comments
 (0)