From 1703eedd93d643115e9f80cef2bbdb500cc17f10 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 13 May 2022 13:46:38 -0700 Subject: [PATCH] Added mobile site SSH integration for agent devices, #3969 --- views/default-mobile.handlebars | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 39296086..8e480ac4 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -919,7 +919,8 @@
- + + Disconnected
@@ -4685,15 +4686,17 @@ // Show the right buttons QV('disconnectbutton2span', (termState == true)); - QV('connectbutton2span', (termState == false) && (currentNode.agent != null) && (currentNode.agent.caps & 2)); + QV('connectbutton2span', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.mtype != 3)); + QV('connectbutton2sspan', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.agent.id != 3) && (terminalNode.agent.id != 4)); // Enable buttons var online = ((terminalNode.conn & 1) != 0) || (terminalNode.mtype == 3); // If Agent (1) connected, enable Terminal QE('connectbutton2', online); + QE('connectbutton2s', online); // Enable action button if mesh type is not "local devices" QV('termActionsBtn', terminalNode.mtype != 3); - if (terminalNode.mtype != 3) { + if (((termState == true) && (terminal.contype != 3)) || (terminalNode.agent.id == 3) || (terminalNode.agent.id == 4)) { QH('terminalCustomUpperRight', ''); } else { QH('terminalCustomUpperRight', '' + format("SSH Port {0}", (terminalNode.sshport ? terminalNode.sshport : 22)) + ''); @@ -4977,8 +4980,8 @@ document.getElementsByClassName('xterm-viewport')[0].style.overflow = 'hidden'; // Setup a terminal tunnel to the agent - terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel((currentNode.mtype == 3) ? sshTunnelUpdate : tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl); - if (currentNode.mtype == 3) { terminal.urlname = 'sshterminalrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay. + terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel((contype == 3) ? sshTunnelUpdate : tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl); + if (contype == 3) { terminal.urlname = 'sshterminalrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay. terminal.debugmode = debugmode; terminal.m.debugmode = debugmode; terminal.options = termoptions; @@ -4986,7 +4989,7 @@ if (termoptions.requireLogin) { terminal.options.requireLogin = true; } terminal.Start(terminalNode._id); terminal.onStateChanged = onTerminalStateChange; - terminal.contype = 1; + terminal.contype = contype; terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it. terminal.onConsoleMessageChange = function () { p12setConsoleMsg(terminal.consoleMessage ? formatAgentConsoleMessage(terminal.consoleMessage, terminal.consoleMessageId, terminal.consoleMessageArgs) : null, terminal.consoleMessageTimeout); } } else {