Update apprelays.js

if header is not null for websockets
This commit is contained in:
Simon Smith 2022-07-03 18:29:46 +01:00 committed by GitHub
parent 5ba9d7e503
commit 0f85b186cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -638,6 +638,7 @@ module.exports.CreateWebRelay = function (parent, db, args, domain) {
}
} else {
// Tunnel is now in web socket pass-thru mode
if (header != null) {
if ((typeof header.connection == 'string') && (header.connection.toLowerCase() == 'upgrade')) {
// Websocket upgrade succesful
obj.socketParseState = 2;
@ -647,6 +648,7 @@ module.exports.CreateWebRelay = function (parent, db, args, domain) {
}
}
}
}
// Send data thru the relay tunnel. Written to use TLS if needed.
function send(data) { try { if (obj.tls) { obj.tls.write(data); } else { obj.wsClient.send(data); } } catch (ex) { } }