Added mobile site SSH integration for agent devices, #3969
Ylian Saint-Hilaire committed
May 13, 2022 at 13:46 UTC
1703eedd93d643115e9f80cef2bbdb500cc17f10
1 file changed
+9
-6
views/default-mobile.handlebars
+9
-6
@@ -919,7 +919,8 @@
919
<div id="terminalCustomUpperRight" style="float:left;margin-right:6px"></div>
920
</div>
921
<div>
922
- <span id="connectbutton2span" style="margin-left:3px"><input type="button" id="connectbutton2" cmenu="termConnectButton" value="Connect" style="height:28px" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
922
+ <span id="connectbutton2span" style="margin-left:3px"><input type="button" id="connectbutton2" value="Connect" style="height:28px" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
923
+ <span id="connectbutton2sspan" style="margin-right:4px"><input type="button" id="connectbutton2s" value="SSH Connect" style="height:28px" onclick=connectTerminal(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
924
<span id="disconnectbutton2span" style="margin-left:3px"><input type="button" id="disconnectbutton2" value="Disconnect" style="height:28px" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false" /></span>
925
<span id="termstatus" style="line-height:22px">Disconnected</span><span id="termtitle"></span>
926
</div>
@@ -4685,15 +4686,17 @@
4686
4687
// Show the right buttons
4688
QV('disconnectbutton2span', (termState == true));
4688
- QV('connectbutton2span', (termState == false) && (currentNode.agent != null) && (currentNode.agent.caps & 2));
4689
+ QV('connectbutton2span', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.mtype != 3));
4690
+ QV('connectbutton2sspan', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.agent.id != 3) && (terminalNode.agent.id != 4));
4691
4692
// Enable buttons
4693
var online = ((terminalNode.conn & 1) != 0) || (terminalNode.mtype == 3); // If Agent (1) connected, enable Terminal
4694
QE('connectbutton2', online);
4695
+ QE('connectbutton2s', online);
4696
4697
// Enable action button if mesh type is not "local devices"
4698
QV('termActionsBtn', terminalNode.mtype != 3);
4696
- if (terminalNode.mtype != 3) {
4699
+ if (((termState == true) && (terminal.contype != 3)) || (terminalNode.agent.id == 3) || (terminalNode.agent.id == 4)) {
4700
QH('terminalCustomUpperRight', '');
4701
} else {
4702
QH('terminalCustomUpperRight', '<a style=cursor:pointer onclick=cmsshportaction(1,event)>' + format("SSH Port {0}", (terminalNode.sshport ? terminalNode.sshport : 22)) + '</a>');
@@ -4977,8 +4980,8 @@
4980
document.getElementsByClassName('xterm-viewport')[0].style.overflow = 'hidden';
4981
4982
// Setup a terminal tunnel to the agent
4980
- terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel((currentNode.mtype == 3) ? sshTunnelUpdate : tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
4981
- if (currentNode.mtype == 3) { terminal.urlname = 'sshterminalrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
4983
+ terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel((contype == 3) ? sshTunnelUpdate : tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
4984
+ if (contype == 3) { terminal.urlname = 'sshterminalrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
4985
terminal.debugmode = debugmode;
4986
terminal.m.debugmode = debugmode;
4987
terminal.options = termoptions;
@@ -4986,7 +4989,7 @@
4989
if (termoptions.requireLogin) { terminal.options.requireLogin = true; }
4990
terminal.Start(terminalNode._id);
4991
terminal.onStateChanged = onTerminalStateChange;
4989
- terminal.contype = 1;
4992
+ terminal.contype = contype;
4993
terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it.
4994
terminal.onConsoleMessageChange = function () { p12setConsoleMsg(terminal.consoleMessage ? formatAgentConsoleMessage(terminal.consoleMessage, terminal.consoleMessageId, terminal.consoleMessageArgs) : null, terminal.consoleMessageTimeout); }
4995
} else {