From cd99f810648d1e6b00776a1a8f86a1707e9108f8 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 15 Jul 2022 13:24:30 -0700 Subject: [PATCH] Fixed SFTP Connect button and SSH/SFTP connection on non-default domains. --- apprelays.js | 4 ++++ views/default.handlebars | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apprelays.js b/apprelays.js index b899a58c..39ac108f 100644 --- a/apprelays.js +++ b/apprelays.js @@ -414,6 +414,7 @@ module.exports.CreateWebRelay = function (parent, db, args, domain) { var domainadd = ''; if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' } 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 + 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. parent.parent.parent.debug('relay', 'TCP: Connection websocket to ' + url); obj.wsClient = new WebSocket(url, options); obj.wsClient.on('open', function () { parent.parent.parent.debug('relay', 'TCP: Relay websocket open'); }); @@ -1156,6 +1157,7 @@ module.exports.CreateSshRelay = function (parent, db, ws, req, args, domain) { var domainadd = ''; if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' } 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 + 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. parent.parent.debug('relay', 'SSH: Connection websocket to ' + url); obj.wsClient = new WebSocket(url, options); obj.wsClient.on('open', function () { parent.parent.debug('relay', 'SSH: Relay websocket open'); }); @@ -1494,6 +1496,7 @@ module.exports.CreateSshTerminalRelay = function (parent, db, ws, req, domain, u var domainadd = ''; if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' } 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 + 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. parent.parent.debug('relay', 'SSH: Connection websocket to ' + url); obj.wsClient = new WebSocket(url, options); obj.wsClient.on('open', function () { parent.parent.debug('relay', 'SSH: Relay websocket open'); }); @@ -1847,6 +1850,7 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user var domainadd = ''; if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' } 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 + 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. parent.parent.debug('relay', 'SSH: Connection websocket to ' + url); obj.wsClient = new WebSocket(url, options); obj.wsClient.on('open', function () { parent.parent.debug('relay', 'SSH: Relay websocket open'); }); diff --git a/views/default.handlebars b/views/default.handlebars index b4e8c9fd..fa11d10f 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -10182,7 +10182,7 @@ QE('p13Connect', online); QE('p13Connects', online); QV('p13Connect', (files == null) && (filesNode.mtype == 2)); - QV('p13Connects', (features2 & 0x200) && (files == null) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4) && ((features2 & 0x800000) == 0)); + QV('p13Connects', ((features2 & 0x200) != 0) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4) && ((features2 & 0x800000) == 0)); QV('p13Disconnect', files != null); if (((samenode == false) || (online == false)) && files) { files.Stop(); files = null; } p13setActions(); @@ -10190,7 +10190,7 @@ function onFilesStateChange(xfiles, state) { QV('p13Connect', (state == 0) && (files == null) && (filesNode.mtype == 2)); - QV('p13Connects', (state == 0) && (files == null) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4)); + QV('p13Connects', (state == 0) && (features2 & 0x200) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4) && ((features2 & 0x800000) == 0)); QV('p13Disconnect', state != 0); var str = StatusStrs[state]; if (state == 3) {