Add Production P2P Servers to list in Super User Panel

fix-non-showing-inputs
Moe Alam 2020-10-02 21:27:29 -07:00
parent ec2544b887
commit e45c411490
5 changed files with 73 additions and 16 deletions

View File

@ -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",

View File

@ -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'

View File

@ -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;

View File

@ -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;
})
})

View File

@ -1,7 +1,15 @@
<% const p2pServerList = config.p2pServerList || {}
const selectedServer = p2pServerList[config.p2pHostSelected]
%>
<script>
window.p2pServerList = <%- JSON.stringify(p2pServerList) %>
window.currentlySelectedP2PServerId = `<%- config.p2pHostSelected %>`
</script>
<link rel="stylesheet" href="<%-window.libURL%>libs/css/super.easyRemoteAccess.css">
<form>
<div class="mb-4">
<a href="#" class="submit btn btn-block btn-default"><i class="fa fa-check"></i> <%- lang.Save %></a>
<div class="mb-4 btn-group" style="display:flex">
<a style="flex:6" href="#" class="submit btn btn-default"><i class="fa fa-check"></i> <%- lang.Save %></a>
<a style="flex:6" target="_blank" href="#" class="btn btn-info remote-dashboard-link"><i class="fa fa-external-link"></i> <%- lang['Open Dashboard Remotely'] %></a>
</div>
<div class="form-group">
<label>
@ -15,13 +23,13 @@
<div class="form-group">
<label>
<div><span><%-lang['P2P API Key']%></span></div>
<div><input class="form-control" type="password" name="p2pApiKey" value="<%- config.p2pApiKey %>"></div>
<div><input class="form-control" type="text" name="p2pApiKey" value="<%- config.p2pApiKey %>"></div>
</label>
</div>
<div class="form-group">
<div class="row" id="p2pServerList">
<% Object.keys(config.p2pServerList).forEach((key) => {
const details = config.p2pServerList[key]
<% Object.keys(p2pServerList).forEach((key) => {
const details = p2pServerList[key]
%>
<div class="col-md-3 mt-2">
<div class="card <% if(config.p2pHostSelected === key){ %>active<% } %>" drawn-id="<%- key %>">