mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-11 09:24:58 +00:00
fix lib/hosts.js, lib/shadowsocks.js, lib/shell.js
This commit is contained in:
parent
069282035f
commit
0f4161d360
|
@ -7,7 +7,7 @@ var FILE = require("lib/file");
|
|||
|
||||
exports.getHosts = function() {
|
||||
var hosts = [];
|
||||
|
||||
|
||||
var filePath = SYS.getEnvString("windir") + "\\System32\\\drivers\\etc\\hosts";
|
||||
var fileContent = FILE.readFile(filePath, "utf-8");
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ exports.require = global.require;
|
|||
|
||||
var arch = SYS.getArch();
|
||||
if(arch.indexOf("64") > -1) {
|
||||
exports.binPath = "bin/shadowsocks-lib-mingw-x86_64/ss-local.exe";
|
||||
exports.binPath = "bin/shadowsocks-libev-mingw-x86_64/ss-local.exe";
|
||||
} else {
|
||||
exports.binPath = "bin/shadowsocks-lib-mingw-x86/ss-local.exe";
|
||||
exports.binPath = "bin/shadowsocks-libev-mingw-x86/ss-local.exe";
|
||||
}
|
||||
|
||||
exports.getRandomInt = function(min, max) {
|
||||
|
@ -22,9 +22,7 @@ exports.getRandomInt = function(min, max) {
|
|||
};
|
||||
|
||||
exports.connect = function() {
|
||||
return;
|
||||
|
||||
var port = exports.getRandomInt(49152, 65535);
|
||||
var listenPort = exports.getRandomInt(49152, 65535);
|
||||
|
||||
SHELL.run([
|
||||
exports.binPath,
|
||||
|
@ -33,12 +31,12 @@ exports.connect = function() {
|
|||
"-p",
|
||||
__config.shadowsocks.port,
|
||||
"-l",
|
||||
port,
|
||||
listenPort,
|
||||
"-k",
|
||||
__config.shadowsocks.password,
|
||||
"-m",
|
||||
__config.shadowsocks.cipher
|
||||
], true);
|
||||
|
||||
return port;
|
||||
return listenPort;
|
||||
};
|
||||
|
|
|
@ -8,8 +8,8 @@ exports.VERSIONINFO = "Shell Lib (shell.js) version 0.1";
|
|||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
||||
exports.addslashes = function(string) {
|
||||
return string.replace(/\\/g, '\\\\').
|
||||
exports.addslashes = function(s) {
|
||||
return s.toString().replace(/\\/g, '\\\\').
|
||||
replace(/\u0008/g, '\\b').
|
||||
replace(/\t/g, '\\t').
|
||||
replace(/\n/g, '\\n').
|
||||
|
@ -39,6 +39,7 @@ exports.exec = function(cmd, stdOutPath) {
|
|||
var c = "%comspec% /c (" + exports.makeCmdLine(cmd) + ") 1> " + stdOutPath;
|
||||
c += " 2>&1";
|
||||
WSH.Run(c, 0, true);
|
||||
console.info("exec() -> " + c);
|
||||
data = FILE.readFile(stdOutPath, "utf-8");
|
||||
|
||||
if (FILE.fileExists(stdOutPath)) {
|
||||
|
@ -51,6 +52,7 @@ exports.exec = function(cmd, stdOutPath) {
|
|||
exports.run = function(cmd, fork) {
|
||||
var WSH = CreateObject("WScript.Shell");
|
||||
var fork = (typeof(fork) !== "undefined") ? fork : true;
|
||||
var c = "%comspec% /q /c " + exports.makeCmdLine(cmd);
|
||||
var c = "%comspec% /q /c (" + exports.makeCmdLine(cmd) + ")";
|
||||
console.info("run() -> " + c);
|
||||
WSH.Run(c, 0, !fork);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user