fix lib/hosts.js, lib/shadowsocks.js, lib/shell.js

This commit is contained in:
Namhyeon Go 2020-07-30 11:53:45 +09:00
parent 069282035f
commit 0f4161d360
3 changed files with 11 additions and 11 deletions

View File

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

View File

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

View File

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