From b1e0ccbcb63599b1f0bcd6cf92c02c471b85ab62 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 23 May 2022 11:08:11 -0700 Subject: [PATCH] Added user consent context menu options for terminal and files, #4032 --- views/default.handlebars | 54 +++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/views/default.handlebars b/views/default.handlebars index 1116e4e4..d28b41ca 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -72,20 +72,27 @@ --> +
- + Disconnected @@ -5833,6 +5840,13 @@ var cmenu = elem.attributes.cmenu.value; switch (cmenu) { + case 'filesConnectButton': { + // Files connect button context menu + if ((currentNode == null) || (currentNode.agent == null)) return true; + contextelement = elem; + showContextMenuDiv(document.getElementById('filesShellContextMenu'), event.pageX, event.pageY); + break; + } case 'termConnectButton': { // Terminal connect button context menu if ((currentNode == null) || (currentNode.agent == null) || (currentNode.mtype == 3)) return true; @@ -5984,11 +5998,15 @@ p1updateInfo(); } - function cmtermaction(action) { + function cmconnectfilesaction() { + connectFiles(null, 1, 0x0020); + } + + function cmtermaction(action, consent) { if (action < 100) { - connectTerminal(null, 1, { protocol: action }); + connectTerminal(null, 1, { protocol: action, consent: consent }); } else if (action == 100) { - connectTerminal(null, 1, { protocol: 1, requireLogin: true }); + connectTerminal(null, 1, { protocol: 1, requireLogin: true, consent: consent }); } } @@ -6119,6 +6137,7 @@ function hideContextMenu() { QV('contextMenu', false); QV('meshContextMenu', false); + QV('filesShellContextMenu', false); QV('termShellContextMenu', false); QV('termShellContextMenu2', false); QV('termShellContextMenuLinux', false); @@ -9864,6 +9883,7 @@ // Terminal setup var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number'))?options.protocol:1 }; if (options && options.requireLogin) { termoptions.requireLogin = true; } + if (options && options.consent) { termoptions.consent = options.consent; } if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) { if (Q('termSizeList').value == 1) { termoptions.cols = 80; termoptions.rows = 25; termoptions.xterm = true; } else if (Q('termSizeList').value == 2) { termoptions.cols = 100; termoptions.rows = 30; termoptions.xterm = true; } @@ -9912,12 +9932,13 @@ }); // Setup a terminal tunnel to the agent + termoptions.cols = xterm.cols; + termoptions.rows = xterm.rows; 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; - terminal.options = { cols: xterm.cols, rows: xterm.rows }; if (termoptions.requireLogin) { terminal.options.requireLogin = true; } terminal.Start(terminalNode._id); terminal.onStateChanged = onTerminalStateChange; @@ -10102,13 +10123,15 @@ function autoConnectFiles(e) { if (autoConnectFilesTimer == null) { autoConnectFilesTimer = setInterval(connectFiles, 100); } else { clearInterval(autoConnectFilesTimer); autoConnectFilesTimer = null; } } // 1 = Agent, 2 = SFTP - function connectFiles(e, contype) { + function connectFiles(e, contype, consent) { + console.log('connectFiles', contype, consent); p13clearConsoleMsg(); if (!files) { // Setup a mesh agent files files = CreateAgentRedirect(meshserver, CreateRemoteFiles(p13gotFiles), serverPublicNamePort, authCookie, authRelayCookie, domainUrl); if (contype == 2) { files.urlname = 'sshfilesrelay.ashx'; } // If this is a SSH session, change the URL to the SSH application relay. files.contype = contype; + files.options = { consent: consent } files.attemptWebRTC = attemptWebRTC; files.onStateChanged = onFilesStateChange; files.onConsoleMessageChange = function () { @@ -10122,6 +10145,7 @@ } } files.Start(filesNode._id); + console.log(files.options); } else { //QH('Term', ''); files.Stop();