mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-06-18 02:59:04 +00:00
fix
This commit is contained in:
parent
187adf9b34
commit
3fb0613444
|
@ -125,10 +125,18 @@ exports.getPIDList = function() {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.isAlivePID = function(pid) {
|
||||||
|
if (!pid) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return (exports.getPIDList().indexOf(pid) > -1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
exports.getProcessListByName = function(name) {
|
exports.getProcessListByName = function(name) {
|
||||||
return exports.getProcessList().filter(function(s) {
|
return exports.getProcessList().filter(function(s) {
|
||||||
return (s.Caption === name);
|
return (s.Caption === name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.killProcess = function(pid) {
|
exports.killProcess = function(pid) {
|
||||||
|
|
156
shadow.js
156
shadow.js
|
@ -11,62 +11,64 @@ var NoxPlayer = require("lib/noxplayer");
|
||||||
var Chrome = require("lib/chrome");
|
var Chrome = require("lib/chrome");
|
||||||
|
|
||||||
var Apps = {
|
var Apps = {
|
||||||
LDPlayer: {},
|
LDPlayer: {},
|
||||||
NoxPlayer: {},
|
NoxPlayer: {},
|
||||||
Chrome: {},
|
Chrome: {},
|
||||||
ProcessName: {}
|
ProcessName: {}
|
||||||
};
|
};
|
||||||
var AppsMutex = [];
|
var AppsMutex = [];
|
||||||
var AppsPID = [];
|
var AppsPID = [];
|
||||||
|
|
||||||
var getAvailablePID = function() {
|
var getAvailablePID = function() {
|
||||||
var items = [];
|
var items = [];
|
||||||
var cmd = "tasklist | findstr .exe";
|
var cmd = "tasklist | findstr .exe";
|
||||||
var result = SHELL.exec(cmd);
|
var result = SHELL.exec(cmd);
|
||||||
var lines = result.split(/\r?\n/);
|
var lines = result.split(/\r?\n/);
|
||||||
for(var i = 0; i < lines.length; i++) {
|
for(var i = 0; i < lines.length; i++) {
|
||||||
var row = lines[i].split(/\s+/);
|
var row = lines[i].split(/\s+/);
|
||||||
items.push(row[1]);
|
items.push(row[1]);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
|
||||||
var items = XML.load("staticip.xml").select("/StaticIP/Item").toArray();
|
var items = XML.load("staticip.xml").select("/StaticIP/Item").toArray();
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
try {
|
try {
|
||||||
var name = items[i].getDOM().selectSingleNode("Name").text;
|
var name = items[i].getDOM().selectSingleNode("Name").text;
|
||||||
var uniqueId = items[i].getDOM().selectSingleNode("UniqueID").text;
|
var uniqueId = items[i].getDOM().selectSingleNode("UniqueID").text;
|
||||||
var ipAddress = items[i].getDOM().selectSingleNode("IPAddress").text;
|
var ipAddress = items[i].getDOM().selectSingleNode("IPAddress").text;
|
||||||
|
|
||||||
if (name in Apps) {
|
if (name in Apps) {
|
||||||
Apps[name][uniqueId] = ipAddress;
|
Apps[name][uniqueId] = ipAddress;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// App 1. LDPlayer
|
// App 1. LDPlayer
|
||||||
var check_LDPlayer = function() {
|
var check_LDPlayer = function() {
|
||||||
var ssPort, ssPID, shadowPID = 0;
|
var ssPort, ssPID, shadowPID = 0;
|
||||||
var items = LDPlayer.getList();
|
var items = LDPlayer.getList();
|
||||||
|
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
var pid = items[i].PIDVBox;
|
var pid = items[i].PIDVBox;
|
||||||
var title = items[i].title;
|
var title = items[i].title;
|
||||||
if (pid > 0 && AppsMutex.indexOf(pid) < 0) {
|
if (pid > 0 && AppsMutex.indexOf(pid) < 0) {
|
||||||
console.info("New launched LDPlayer: " + title);
|
console.info("New launched LDPlayer: " + title);
|
||||||
AppsMutex.push(pid);
|
AppsMutex.push(pid);
|
||||||
|
|
||||||
if (title in Apps.LDPlayer) {
|
if (title in Apps.LDPlayer) {
|
||||||
var ss = SS.connect(Apps.LDPlayer[title]);
|
while (!SYS.isAlivePID(ssPID)) {
|
||||||
ssPort = ss.listenPort;
|
var ss = SS.connect(Apps.LDPlayer[title]);
|
||||||
ssPID = ss.processID;
|
ssPort = ss.listenPort;
|
||||||
} else {
|
ssPID = ss.processID;
|
||||||
console.error("Not assigned static IP: " + title);
|
}
|
||||||
continue;
|
} else {
|
||||||
}
|
console.error("Not assigned static IP: " + title);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var process;
|
var process;
|
||||||
while (!(shadowPID > 0)) {
|
while (!SYS.isAlivePID(shadowPID)) {
|
||||||
process = SHELL.createProcess([
|
process = SHELL.createProcess([
|
||||||
SYS.getCurrentScriptDirectory() + "/bin/shadow.exe",
|
SYS.getCurrentScriptDirectory() + "/bin/shadow.exe",
|
||||||
"-c",
|
"-c",
|
||||||
|
@ -76,42 +78,44 @@ var check_LDPlayer = function() {
|
||||||
"-p",
|
"-p",
|
||||||
pid
|
pid
|
||||||
]);
|
]);
|
||||||
sleep(1000);
|
sleep(3000);
|
||||||
shadowPID = process.ProcessID;
|
shadowPID = process.ProcessID;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppsPID.push([pid, ssPID, shadowPID]);
|
AppsPID.push([pid, ssPID, shadowPID]);
|
||||||
|
|
||||||
console.info("Waiting new launched");
|
console.info("Waiting new launched");
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// App 2. NoxPlayer
|
// App 2. NoxPlayer
|
||||||
var check_NoxPlayer = function() {
|
var check_NoxPlayer = function() {
|
||||||
var ssPort, ssPID, shadowPID = 0;
|
var ssPort, ssPID, shadowPID = 0;
|
||||||
var items = NoxPlayer.getList();
|
var items = NoxPlayer.getList();
|
||||||
|
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
var pid = items[i].PID;
|
var pid = items[i].PID;
|
||||||
var hostname = items[i].hostname;
|
var hostname = items[i].hostname;
|
||||||
|
|
||||||
if (pid > 0 && AppsMutex.indexOf(pid) < 0) {
|
if (pid > 0 && AppsMutex.indexOf(pid) < 0) {
|
||||||
console.info("New launched NoxPlayer: " + hostname);
|
console.info("New launched NoxPlayer: " + hostname);
|
||||||
AppsMutex.push(pid);
|
AppsMutex.push(pid);
|
||||||
|
|
||||||
if (hostname in Apps.NoxPlayer) {
|
if (hostname in Apps.NoxPlayer) {
|
||||||
var ss = SS.connect(Apps.NoxPlayer[hostname]);
|
while (!SYS.isAlivePID(ssPID)) {
|
||||||
ssPort = ss.listenPort;
|
var ss = SS.connect(Apps.NoxPlayer[hostname]);
|
||||||
ssPID = ss.processID;
|
ssPort = ss.listenPort;
|
||||||
} else {
|
ssPID = ss.processID;
|
||||||
console.error("Not assigned static IP: " + hostname);
|
}
|
||||||
continue;
|
} else {
|
||||||
}
|
console.error("Not assigned static IP: " + hostname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var process;
|
var process;
|
||||||
while (!(shadowPID > 0)) {
|
while (!SYS.isAlivePID(shadowPID)) {
|
||||||
process = SHELL.createProcess([
|
process = SHELL.createProcess([
|
||||||
SYS.getCurrentScriptDirectory() + "/bin/shadow.exe",
|
SYS.getCurrentScriptDirectory() + "/bin/shadow.exe",
|
||||||
"-c",
|
"-c",
|
||||||
|
@ -121,29 +125,29 @@ var check_NoxPlayer = function() {
|
||||||
"-p",
|
"-p",
|
||||||
pid
|
pid
|
||||||
]);
|
]);
|
||||||
sleep(1000);
|
sleep(3000);
|
||||||
shadowPID = process.ProcessID;
|
shadowPID = process.ProcessID;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppsPID.push([pid, ssPID, shadowPID]);
|
AppsPID.push([pid, ssPID, shadowPID]);
|
||||||
|
|
||||||
console.info("Waiting new launched");
|
console.info("Waiting new launched");
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// App 3. Chrome
|
// App 3. Chrome
|
||||||
var check_Chrome = function() {
|
var check_Chrome = function() {
|
||||||
for (var uniqueId in Apps.Chrome) {
|
for (var uniqueId in Apps.Chrome) {
|
||||||
if (AppsMutex.indexOf("chrome_" + uniqueId) < 0) {
|
if (AppsMutex.indexOf("chrome_" + uniqueId) < 0) {
|
||||||
console.info("Creating Chrome Shoutcut: " + uniqueId);
|
console.info("Creating Chrome Shoutcut: " + uniqueId);
|
||||||
|
|
||||||
// 바탕화면에 바로가기만 생성
|
// 바탕화면에 바로가기만 생성
|
||||||
Chrome.create().setProfile(uniqueId, uniqueId).createShoutcut("https://google.com");
|
Chrome.create().setProfile(uniqueId, uniqueId).createShoutcut("https://google.com");
|
||||||
AppsMutex.push("chrome_" + uniqueId);
|
AppsMutex.push("chrome_" + uniqueId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// App 4. ProcessName
|
// App 4. ProcessName
|
||||||
|
@ -156,13 +160,15 @@ var check_ProcessName = function() {
|
||||||
AppsMutex.push("processName_" + uniqueId);
|
AppsMutex.push("processName_" + uniqueId);
|
||||||
|
|
||||||
// 소켓 연결
|
// 소켓 연결
|
||||||
var ss = SS.connect(Apps.ProcessName[uniqueId]);
|
while (!SYS.isAlivePID(ssPID)) {
|
||||||
ssPort = ss.listenPort;
|
var ss = SS.connect(Apps.ProcessName[uniqueId]);
|
||||||
ssPID = ss.processID;
|
ssPort = ss.listenPort;
|
||||||
|
ssPID = ss.processID;
|
||||||
|
}
|
||||||
|
|
||||||
// 프로세스 이름으로 실행
|
// 프로세스 이름으로 실행
|
||||||
var process;
|
var process;
|
||||||
while (!(shadowPID > 0)) {
|
while (!SYS.isAlivePID(shadowPID)) {
|
||||||
process = SHELL.createProcess([
|
process = SHELL.createProcess([
|
||||||
SYS.getCurrentScriptDirectory() + "/bin/shadow.exe",
|
SYS.getCurrentScriptDirectory() + "/bin/shadow.exe",
|
||||||
"-c",
|
"-c",
|
||||||
|
@ -172,7 +178,7 @@ var check_ProcessName = function() {
|
||||||
"-n",
|
"-n",
|
||||||
uniqueId
|
uniqueId
|
||||||
]);
|
]);
|
||||||
sleep(1000);
|
sleep(3000);
|
||||||
shadowPID = process.ProcessID;
|
shadowPID = process.ProcessID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,16 +232,16 @@ var check_Zombie = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
var main = function() {
|
var main = function() {
|
||||||
console.info("Waiting new launched");
|
console.info("Waiting new launched");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
check_LDPlayer();
|
check_LDPlayer();
|
||||||
|
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
check_NoxPlayer();
|
check_NoxPlayer();
|
||||||
|
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
check_Chrome();
|
check_Chrome();
|
||||||
|
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
|
@ -243,7 +249,7 @@ var main = function() {
|
||||||
|
|
||||||
sleep(3000);
|
sleep(3000);
|
||||||
check_Zombie();
|
check_Zombie();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.main = main;
|
exports.main = main;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user