fix relaying with subdomain #5394

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Jan 16, 2024 at 15:57 UTC 0d7564d845c182f84c8acfabb1d37196770d4cb4
1 file changed +4 -4
apprelays.js
+4 -4
@@ -458,7 +458,7 @@ module.exports.CreateWebRelay = function (parent, db, args, domain, mtype) {
458 const protocol = (args.tlsoffload) ? 'ws' : 'wss';
459 var domainadd = '';
460 if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' }
461 - const url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=14&auth=' + cookie; // Protocol 14 is Web-TCP
461 + var url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=14&auth=' + cookie; // Protocol 14 is Web-TCP
462 if (domain.id != '') { url += '&domainid=' + domain.id; } // Since we are using "localhost", we are going to signal what domain we are on using a URL argument.
463 parent.parent.parent.debug('relay', 'TCP: Connection websocket to ' + url);
464 obj.wsClient = new WebSocket(url, options);
@@ -1210,7 +1210,7 @@ module.exports.CreateSshRelay = function (parent, db, ws, req, args, domain) {
1210 const protocol = (args.tlsoffload) ? 'ws' : 'wss';
1211 var domainadd = '';
1212 if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' }
1213 - const url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=11&auth=' + obj.xcookie; // Protocol 11 is Web-SSH
1213 + var url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=11&auth=' + obj.xcookie; // Protocol 11 is Web-SSH
1214 if (domain.id != '') { url += '&domainid=' + domain.id; } // Since we are using "localhost", we are going to signal what domain we are on using a URL argument.
1215 parent.parent.debug('relay', 'SSH: Connection websocket to ' + url);
1216 obj.wsClient = new WebSocket(url, options);
@@ -1549,7 +1549,7 @@ module.exports.CreateSshTerminalRelay = function (parent, db, ws, req, domain, u
1549 const protocol = (args.tlsoffload) ? 'ws' : 'wss';
1550 var domainadd = '';
1551 if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' }
1552 - const url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=11&auth=' + authCookie // Protocol 11 is Web-SSH
1552 + var url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=11&auth=' + authCookie // Protocol 11 is Web-SSH
1553 if (domain.id != '') { url += '&domainid=' + domain.id; } // Since we are using "localhost", we are going to signal what domain we are on using a URL argument.
1554 parent.parent.debug('relay', 'SSH: Connection websocket to ' + url);
1555 obj.wsClient = new WebSocket(url, options);
@@ -1903,7 +1903,7 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
1903 const protocol = (args.tlsoffload) ? 'ws' : 'wss';
1904 var domainadd = '';
1905 if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' }
1906 - const url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=13&auth=' + authCookie // Protocol 13 is Web-SSH-Files
1906 + var url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=13&auth=' + authCookie // Protocol 13 is Web-SSH-Files
1907 if (domain.id != '') { url += '&domainid=' + domain.id; } // Since we are using "localhost", we are going to signal what domain we are on using a URL argument.
1908 parent.parent.debug('relay', 'SSH: Connection websocket to ' + url);
1909 obj.wsClient = new WebSocket(url, options);