From e45c411490987325733d1d3021916ee96d9581d9 Mon Sep 17 00:00:00 2001 From: Moe Alam Date: Fri, 2 Oct 2020 21:27:29 -0700 Subject: [PATCH] Add Production P2P Servers to list in Super User Panel --- languages/en_CA.json | 3 ++ libs/commander.js | 48 ++++++++++++++++++++++----- libs/commander/worker.js | 1 - web/libs/js/super.easyRemoteAccess.js | 19 ++++++++++- web/pages/blocks/easyRemoteAccess.ejs | 18 +++++++--- 5 files changed, 73 insertions(+), 16 deletions(-) diff --git a/languages/en_CA.json b/languages/en_CA.json index 8f10cd23..ad8aebf5 100644 --- a/languages/en_CA.json +++ b/languages/en_CA.json @@ -192,6 +192,7 @@ "Filter Name": "Filter Name", "Find Where": "Find Where", "Reason": "Reason", + "Open Dashboard Remotely": "Open Dashboard Remotely", "Detection Engine": "Detection Engine", "X Point": "X Point", "Y Point": "Y Point", @@ -210,6 +211,8 @@ "Easy Remote Access (P2P)": "Easy Remote Access (P2P)", "P2P Settings Applied": "P2P Settings Applied", "p2pSettingsText1": "You will need to refresh this page for changes to be applied.", + "P2P Server Not Selected": "P2P Server Not Selected", + "p2pServerNotSelectedText": "Select a server from the list and press Save. Wait 10 seconds then attempt to open the dashboard remotely.", "P2P Host": "P2P Host", "P2P API Key": "P2P API Key", "Preferences": "Preferences", diff --git a/libs/commander.js b/libs/commander.js index deb9238b..56a2061a 100644 --- a/libs/commander.js +++ b/libs/commander.js @@ -5,6 +5,36 @@ module.exports = function(s,config,lang,app){ config.machineId = config.p2pApiKey + '' + config.p2pGroupId config.p2pTargetAuth = config.p2pTargetAuth || s.gid(30) if(!config.p2pServerList)config.p2pServerList = { + "vancouver-1": { + name: 'Vancouver-1', + host: '104.218.61.236', + p2pPort: '8084', + webPort: '8000', + maxNetworkSpeed: { + up: 5000, + down: 5000, + shared: true + }, + location: { + lat: 49.284966, + lon: -123.1140607 + } + }, + "toronto-1": { + name: 'Toronto-1', + host: '104.218.60.72', + p2pPort: '8084', + webPort: '8000', + maxNetworkSpeed: { + up: 5000, + down: 5000, + shared: true + }, + location: { + lat: 43.644773, + lon: -79.3862837 + } + }, "paris-1": { name: 'Paris-1', host: '163.172.180.205', @@ -18,22 +48,22 @@ module.exports = function(s,config,lang,app){ location: { lat: 48.873877, lon: 2.295533 - }, + } }, - "paris-2": { - name: 'Paris-2', - host: '163.172.180.205', + "amsterdam-1": { + name: 'Amsterdam-1', + host: '51.15.43.80', p2pPort: '8084', webPort: '8000', maxNetworkSpeed: { - up: 200, - down: 200, + up: 500, + down: 500, shared: true }, location: { - lat: 48.873877, - lon: 2.295533 - }, + lat: 52.348773, + lon: 4.8846043 + } }, } if(!config.p2pHostSelected)config.p2pHostSelected = 'paris-1' diff --git a/libs/commander/worker.js b/libs/commander/worker.js index b68474f7..e9e3408c 100644 --- a/libs/commander/worker.js +++ b/libs/commander/worker.js @@ -131,7 +131,6 @@ const initialize = (config,lang) => { // }) connectionToP2PServer.on('wsInit',(rawRequest) => { - s.debugLog('p2pWsInit',rawRequest) const user = rawRequest.user const clientConnectionToMachine = createShinobiSocketConnection(rawRequest.cnid) connectedUserWebSockets[user.auth_token] = user; diff --git a/web/libs/js/super.easyRemoteAccess.js b/web/libs/js/super.easyRemoteAccess.js index 06ff2fc0..e25fb47a 100644 --- a/web/libs/js/super.easyRemoteAccess.js +++ b/web/libs/js/super.easyRemoteAccess.js @@ -2,7 +2,6 @@ $(document).ready(function(){ var easyRemoteAccessTab = $('#easyRemoteAccess') var p2pHostSelectedContainer = $('#p2pHostSelected') var easyRemoteAccessForm = easyRemoteAccessTab.find('form') - var currentlySelectedP2PServerId = p2pHostSelectedContainer.find('.active').attr('drawn-id') easyRemoteAccessTab.find('.submit').click(function(){ easyRemoteAccessForm.submit() }) @@ -32,4 +31,22 @@ $(document).ready(function(){ el.addClass('active') currentlySelectedP2PServerId = p2pServerId }) + easyRemoteAccessTab.on('click','.remote-dashboard-link',function(e){ + e.preventDefault() + var apiKey = easyRemoteAccessForm.find('[name="p2pApiKey"]').val() + var selectedServer = p2pServerList[currentlySelectedP2PServerId] + console.log(selectedServer,currentlySelectedP2PServerId,p2pServerList) + if(selectedServer && selectedServer.host){ + var href = `http://${selectedServer.host}:${selectedServer.webPort}/s/${apiKey}?p2p=1` + var win = window.open(href, '_blank'); + win.focus(); + }else{ + new PNotify({ + type: 'warning', + title: lang['P2P Server Not Selected'], + text: lang.p2pServerNotSelectedText, + }) + } + return false; + }) }) diff --git a/web/pages/blocks/easyRemoteAccess.ejs b/web/pages/blocks/easyRemoteAccess.ejs index 72bba21e..2994f483 100644 --- a/web/pages/blocks/easyRemoteAccess.ejs +++ b/web/pages/blocks/easyRemoteAccess.ejs @@ -1,7 +1,15 @@ +<% const p2pServerList = config.p2pServerList || {} + const selectedServer = p2pServerList[config.p2pHostSelected] + %> +
-
- <%- lang.Save %> +