Added SSH,SFTP to agent devices, #3969
Ylian Saint-Hilaire committed
May 13, 2022 at 13:06 UTC
e2bcfc96db16492070733404f1b33f4373e4fe3c
1 file changed
+35
-15
views/default.handlebars
+35
-15
@@ -743,7 +743,7 @@
743
<div id="terminalCustomUiButtons" style="float:left"></div>
744
</div>
745
<div>
746
- <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick=autoConnectTerminal(event) onkeypress="return false" onkeydown="return false" style="display:none" /><span id="connectbutton2span" style="margin-right:4px"><input type="button" id="connectbutton2" cmenu="termConnectButton" value="Connect" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span><span id="connectbutton2hspan" style="margin-right:4px"><input type="button" id="connectbutton2h" value="HW Connect" title="Connect using Intel® AMT hardware KVM" onclick=connectTerminal(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span><span id="disconnectbutton2span" style="margin-right:4px"><input type="button" id="disconnectbutton2" value="Disconnect" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false" /></span>
746
+ <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick=autoConnectTerminal(event) onkeypress="return false" onkeydown="return false" style="display:none" /><span id="connectbutton2span" style="margin-right:4px"><input type="button" id="connectbutton2" cmenu="termConnectButton" value="Connect" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span><span id="connectbutton2sspan" style="margin-right:4px"><input type="button" id="connectbutton2s" cmenu=sshPortContextMenu value="SSH Connect" onclick=connectTerminal(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span><span id="connectbutton2hspan" style="margin-right:4px"><input type="button" id="connectbutton2h" value="HW Connect" title="Connect using Intel® AMT hardware KVM" onclick=connectTerminal(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span><span id="disconnectbutton2span" style="margin-right:4px"><input type="button" id="disconnectbutton2" value="Disconnect" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false" /></span>
747
<span id="termstatus" style="line-height:22px">Disconnected</span><span id="termtitle"></span>
748
</div>
749
</td>
@@ -801,7 +801,9 @@
801
</div>
802
<div>
803
<input id=p13AutoConnect value="AutoConnect" onclick=autoConnectFiles(event) type="button" style="display:none" />
804
- <input id=p13Connect value="Connect" onclick=connectFiles(event) type="button" />
804
+ <input id=p13Connect value="Connect" onclick=connectFiles(event,1) type="button" />
805
+ <input id=p13Connects value="SFTP Connect" cmenu=sshPortContextMenu onclick=connectFiles(event,2) type="button" />
806
+ <input id=p13Disconnect value="Disconnect" onclick=connectFiles(event) type="button" />
807
<span id=p13Status>Disconnected</span>
808
</div>
809
</td>
@@ -2722,7 +2724,6 @@
2724
if (message.localport) { url += '&localport=' + message.localport; }
2725
if (message.ip != null) { url += ('&remoteip=' + message.ip); }
2726
url += ('&appid=' + message.protocol + '&autoexit=1'); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP, 6 = MCRDesktop, 7 = MCRFiles
2725
- console.log(url);
2727
downloadFile(url, '');
2728
} else if (message.tag == 'novnc') {
2729
var vncurl = window.location.origin + domainUrl + 'novnc/vnc.html?ws=wss%3A%2F%2F' + window.location.host + encodeURIComponentEx(domainUrl) + (message.localRelay?'local':'mesh') + 'relay.ashx%3Fauth%3D' + message.cookie + '&show_dot=1' + (urlargs.key?('&key=' + urlargs.key):'') + '&l={{{lang}}}';
@@ -9557,7 +9558,8 @@
9558
9559
// Show the right buttons
9560
QV('disconnectbutton2span', (termState == true));
9560
- QV('connectbutton2span', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2));
9561
+ QV('connectbutton2span', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.mtype != 3));
9562
+ QV('connectbutton2sspan', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.agent.id != 3) && (terminalNode.agent.id != 4));
9563
if (terminalNode.mtype == 1) {
9564
QV('connectbutton2hspan', (termState == false) && (terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2));
9565
QV('terminalSizeDropDown', (termState == false) && (terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2));
@@ -9568,7 +9570,7 @@
9570
9571
// Enable action button if mesh type is not "local devices"
9572
QV('termActionsBtn', terminalNode.mtype != 3);
9571
- if (terminalNode.mtype != 3) {
9573
+ if (((termState == true) && (terminal.contype != 3)) || (terminalNode.agent.id == 3) || (terminalNode.agent.id == 4)) {
9574
QH('terminalCustomUpperRight', '');
9575
} else {
9576
QH('terminalCustomUpperRight', '<a style=cursor:pointer onclick=cmsshportaction(1,event)>' + format("SSH Port {0}", (terminalNode.sshport?terminalNode.sshport:22)) + '</a>');
@@ -9577,6 +9579,7 @@
9579
// Enable buttons
9580
var online = ((terminalNode.conn & 1) != 0) || (terminalNode.mtype == 3); // If Agent (1) connected, enable Terminal
9581
QE('connectbutton2', online);
9582
+ QE('connectbutton2s', online);
9583
var hwonline = ((terminalNode.conn & 6) != 0); // If CIRA (2) or AMT (4) connected, enable hardware terminal
9584
QE('connectbutton2h', hwonline);
9585
@@ -9612,7 +9615,10 @@
9615
var xstate = state;
9616
if ((xstate == 3) && (xterminal.contype == 2)) { xstate++; }
9617
var str = StatusStrs[xstate];
9615
- if (terminal.webRtcActive == true) { str += ", WebRTC"; }
9618
+ if (xstate == 3) {
9619
+ if (terminal.contype == 3) { str += ", SSH"; }
9620
+ if (terminal.webRtcActive == true) { str += ", WebRTC"; }
9621
+ }
9622
QH('termstatus', str);
9623
switch (state) {
9624
case 0:
@@ -9777,6 +9783,7 @@
9783
}
9784
}
9785
9786
+ // contype: 1 = Agent, 2 = AMT, 3 = SSH
9787
function connectTerminal(e, contype, options) {
9788
p12clearConsoleMsg();
9789
if (!terminal) {
@@ -9853,8 +9860,8 @@
9860
});
9861
9862
// Setup a terminal tunnel to the agent
9856
- terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel((currentNode.mtype == 3)? sshTunnelUpdate : tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
9857
- if (currentNode.mtype == 3) { terminal.urlname = 'sshterminalrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
9863
+ terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel((contype == 3)? sshTunnelUpdate : tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
9864
+ if (contype == 3) { terminal.urlname = 'sshterminalrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
9865
terminal.debugmode = debugmode;
9866
terminal.m.debugmode = debugmode;
9867
terminal.options = termoptions;
@@ -9862,7 +9869,7 @@
9869
if (termoptions.requireLogin) { terminal.options.requireLogin = true; }
9870
terminal.Start(terminalNode._id);
9871
terminal.onStateChanged = onTerminalStateChange;
9865
- terminal.contype = 1;
9872
+ terminal.contype = contype;
9873
terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it.
9874
terminal.onConsoleMessageChange = function () { p12setConsoleMsg(terminal.consoleMessage ? formatAgentConsoleMessage(terminal.consoleMessage, terminal.consoleMessageId, terminal.consoleMessageArgs) : null, terminal.consoleMessageTimeout); }
9875
} else {
@@ -9880,7 +9887,7 @@
9887
terminal.onStateChanged = onTerminalStateChange;
9888
terminal.onConsoleMessageChange = function () { p12setConsoleMsg(terminal.consoleMessage ? formatAgentConsoleMessage(terminal.consoleMessage, terminal.consoleMessageId, terminal.consoleMessageArgs) : null, terminal.consoleMessageTimeout); }
9889
terminal.Start(terminalNode._id);
9883
- terminal.contype = 1;
9890
+ terminal.contype = contype;
9891
terminal.m.terminalEmulation = 0;
9892
terminal.m.fxEmulation = 0;
9893
Q('id_ttypebutton').value = terminalEmulations[0];
@@ -9980,14 +9987,24 @@
9987
filesNode = currentNode;
9988
var online = ((filesNode.conn & 1) != 0) || (filesNode.mtype == 3); // If Agent (1) connected, enable Terminal
9989
QE('p13Connect', online);
9990
+ QE('p13Connects', online);
9991
+ QV('p13Connect', files == null);
9992
+ QV('p13Connects', (files == null) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4));
9993
+ QV('p13Disconnect', files != null);
9994
if (((samenode == false) || (online == false)) && files) { files.Stop(); files = null; }
9995
p13setActions();
9996
}
9997
9998
function onFilesStateChange(xfiles, state) {
9988
- p13Connect.value = (state == 0) ? "Connect" : "Disconnect";
9999
+ QV('p13Connect', state == 0);
10000
+ QV('p13Connects', state == 0);
10001
+ QV('p13Disconnect', state != 0);
10002
+ //p13Connect.value = (state == 0) ? "Connect" : "Disconnect";
10003
var str = StatusStrs[state];
9990
- if (files.webRtcActive == true) { str += ", WebRTC"; }
10004
+ if (state == 3) {
10005
+ if (files.contype == 2) { str += ", SFTP"; }
10006
+ if (files.webRtcActive == true) { str += ", WebRTC"; }
10007
+ }
10008
Q('p13Status').textContent = str;
10009
switch (state) {
10010
case 0:
@@ -10033,12 +10050,14 @@
10050
var autoConnectFilesTimer = null;
10051
function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } }
10052
10036
- function connectFiles(e) {
10053
+ // 1 = Agent, 2 = SFTP
10054
+ function connectFiles(e, contype) {
10055
p13clearConsoleMsg();
10056
if (!files) {
10057
// Setup a mesh agent files
10058
files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
10041
- if (filesNode.mtype == 3) { files.urlname = 'sshfilesrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
10059
+ if (contype == 2) { files.urlname = 'sshfilesrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay.
10060
+ files.contype = contype;
10061
files.attemptWebRTC = attemptWebRTC;
10062
files.onStateChanged = onFilesStateChange;
10063
files.onConsoleMessageChange = function () {
@@ -10340,7 +10359,8 @@
10359
QE('p13ZipButton', advancedFeatures && (cc > 0) && ((p13filetreelocation.length > 0) || (winAgent == false)));
10360
QE('p13PasteButton', advancedFeatures && ((p13filetreelocation.length > 0) || (winAgent == false)) && ((p13clipboard != null) && (p13clipboard.length > 0)));
10361
}
10343
- if (filesNode.mtype != 3) {
10362
+ var filesState = ((files != null) && (files.state != 0));
10363
+ if (((filesState == true) && (files.contype != 2)) || (filesNode.agent.id == 3) || (filesNode.agent.id == 4)) {
10364
QH('filesCustomUpperRight', '');
10365
} else {
10366
QH('filesCustomUpperRight', '<a style=cursor:pointer onclick=cmsshportaction(1,event)>' + format("SSH Port {0}", (filesNode.sshport?filesNode.sshport:22)) + '</a>');