mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 04:31:04 +00:00
fix
This commit is contained in:
parent
22e3fb277e
commit
386dca5107
3
app.js
3
app.js
|
@ -44,8 +44,9 @@ var console = {
|
||||||
_echo: function(msg, type) {
|
_echo: function(msg, type) {
|
||||||
msg = (typeof(type) !== "undefined" ? type + ": " : "") + msg;
|
msg = (typeof(type) !== "undefined" ? type + ": " : "") + msg;
|
||||||
if (typeof(WScript) !== "undefined") {
|
if (typeof(WScript) !== "undefined") {
|
||||||
WScript.echo(msg);
|
WScript.echo(" * " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._messages.push(msg);
|
this._messages.push(msg);
|
||||||
},
|
},
|
||||||
log: function(msg) {
|
log: function(msg) {
|
||||||
|
|
34
app/index.js
34
app/index.js
|
@ -12,6 +12,36 @@ var token, userId;
|
||||||
|
|
||||||
var servers = [];
|
var servers = [];
|
||||||
|
|
||||||
|
var getApplications = function() {
|
||||||
|
var applications = [], xmlStrings = [];
|
||||||
|
|
||||||
|
var req = HTTP.get(apiUrl + "/netsolid/items/applications", "", {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Authorization": "bearer " + token,
|
||||||
|
//"Pragma": "no-cache",
|
||||||
|
//"Cache-Control": "no-cache",
|
||||||
|
"If-Modified-Since": "Sat, 1 Jan 2000 00:00:00 GMT"
|
||||||
|
});
|
||||||
|
var res = JSON.parse(req.responseText);
|
||||||
|
|
||||||
|
xmlStrings.push('<?xml version="1.0" encoding="UTF-8"?>');
|
||||||
|
xmlStrings.push("<StaticIP>");
|
||||||
|
for (var i = 0; i < res.data.length; i++) {
|
||||||
|
xmlStrings.push("<Item>");
|
||||||
|
xmlStrings.push("<Name>" + res.data[i].name + "</Name>");
|
||||||
|
xmlStrings.push("<UniqueID>" + res.data[i].unique_id + "</UniqueID>");
|
||||||
|
for (var k = 0; k < servers.length; k++) {
|
||||||
|
if (servers[k].data.id == res.data[i].server) {
|
||||||
|
xmlStrings.push("<IPAddress>" + servers[k].data.ipaddress + "</IPAddress>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlStrings.push("</Item>");
|
||||||
|
}
|
||||||
|
xmlStrings.push("</StaticIP>");
|
||||||
|
|
||||||
|
FILE.writeFile("staticip.xml", xmlStrings.join("\r\n"), "utf-8");
|
||||||
|
};
|
||||||
|
|
||||||
var getAssignedServers = function() {
|
var getAssignedServers = function() {
|
||||||
var assignedServers = [];
|
var assignedServers = [];
|
||||||
|
|
||||||
|
@ -76,12 +106,14 @@ var showServers = function() {
|
||||||
var pingTest = function() {
|
var pingTest = function() {
|
||||||
for (var i = 0; i < servers.length; i++) {
|
for (var i = 0; i < servers.length; i++) {
|
||||||
var responseTime = SYS.pingTest(servers[i].data.ipaddress);
|
var responseTime = SYS.pingTest(servers[i].data.ipaddress);
|
||||||
servers[i].entry.find("span.ping").text("Speed: " + responseTime + " ms");
|
servers[i].entry.find("span.ping").text(responseTime + " ms");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.getElementById("btn_pingtest").onclick = pingTest;
|
document.getElementById("btn_pingtest").onclick = pingTest;
|
||||||
setInterval(pingTest, 5000);
|
setInterval(pingTest, 5000);
|
||||||
pingTest();
|
pingTest();
|
||||||
|
|
||||||
|
getApplications();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<span class="ping text">
|
<span class="ping text">
|
||||||
N/A
|
N/A
|
||||||
</span>
|
</span>
|
||||||
<span class="icon icon-star color-yellow"></span>
|
<span class="icon icon-bolt color-yellow"></span>
|
||||||
</span>
|
</span>
|
||||||
<div class="col width-fill mobile-width-fill">
|
<div class="col width-fill mobile-width-fill">
|
||||||
<a class="title fatty" href="#">Repo 1</a>
|
<a class="title fatty" href="#">Repo 1</a>
|
||||||
|
|
27
shadow.js
27
shadow.js
|
@ -3,12 +3,10 @@
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var SS = require("lib/shadowsocks");
|
var SS = require("lib/shadowsocks");
|
||||||
var SYS = require("lib/system");
|
|
||||||
var FILE = require("lib/file");
|
|
||||||
var SHELL = require("lib/shell");
|
var SHELL = require("lib/shell");
|
||||||
var LDPlayer = require("lib/ldplayer");
|
var LDPlayer = require("lib/ldplayer");
|
||||||
var NoxPlayer = require("lib/noxplayer");
|
var NoxPlayer = require("lib/noxplayer");
|
||||||
var JSON = require("lib/json");
|
var XML = require("lib/xml");
|
||||||
|
|
||||||
var PIDList = [];
|
var PIDList = [];
|
||||||
|
|
||||||
|
@ -17,6 +15,21 @@ var _NumSessions = 0;
|
||||||
var NumBridges = 0;
|
var NumBridges = 0;
|
||||||
var _NumBridges = 0;
|
var _NumBridges = 0;
|
||||||
|
|
||||||
|
var _config = {
|
||||||
|
StaticIP: {
|
||||||
|
LDPlayer: {},
|
||||||
|
NoxPlayer: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var items = XML.loadXMLFile("staticip.xml").select("/StaticIP/Item").all();
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
var Name = items[i].selectSingleNode("Name").text;
|
||||||
|
var UniqueID = items[i].selectSingleNode("UniqueID").text;
|
||||||
|
var IPAddress = items[i].selectSingleNode("IPAddress").text;
|
||||||
|
_config.StaticIP[Name] = IPAddress;
|
||||||
|
}
|
||||||
|
|
||||||
exports.main = function() {
|
exports.main = function() {
|
||||||
console.info("Waiting new launched");
|
console.info("Waiting new launched");
|
||||||
sleep(10000);
|
sleep(10000);
|
||||||
|
@ -38,11 +51,11 @@ exports.main = function() {
|
||||||
PIDList.push(pid);
|
PIDList.push(pid);
|
||||||
|
|
||||||
var listenPort;
|
var listenPort;
|
||||||
if (!(title in __config.StaticIP.LDPlayer)) {
|
if (!(title in _config.StaticIP.LDPlayer)) {
|
||||||
console.error("Not assigned static IP: " + title);
|
console.error("Not assigned static IP: " + title);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
listenPort = SS.connect(__config.StaticIP.LDPlayer[title]);
|
listenPort = SS.connect(_config.StaticIP.LDPlayer[title]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELL.run([
|
SHELL.run([
|
||||||
|
@ -85,11 +98,11 @@ exports.main = function() {
|
||||||
PIDList.push(pid);
|
PIDList.push(pid);
|
||||||
|
|
||||||
var listenPort;
|
var listenPort;
|
||||||
if (!(hostname in __config.StaticIP.NoxPlayer)) {
|
if (!(hostname in _config.StaticIP.NoxPlayer)) {
|
||||||
console.error("Not assigned static IP: " + hostname);
|
console.error("Not assigned static IP: " + hostname);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
listenPort = SS.connect(__config.StaticIP.NoxPlayer[hostname]);
|
listenPort = SS.connect(_config.StaticIP.NoxPlayer[hostname]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELL.run([
|
SHELL.run([
|
||||||
|
|
8
staticip.xml
Normal file
8
staticip.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<StaticIP>
|
||||||
|
<Item>
|
||||||
|
<Name>LDPlayer</Name>
|
||||||
|
<UniqueID>demo</UniqueID>
|
||||||
|
<IPAddress>211.238.32.2</IPAddress>
|
||||||
|
</Item>
|
||||||
|
</StaticIP>
|
Loading…
Reference in New Issue
Block a user