Create shadowsocks.js

This commit is contained in:
Namhyeon Go 2020-07-25 18:10:43 +09:00 committed by GitHub
parent 8c7359f740
commit 80328196f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

34
lib/shadowsocks.js Normal file
View File

@ -0,0 +1,34 @@
////////////////////////////////////////////////////////////////////////
// Shadowsocks API
////////////////////////////////////////////////////////////////////////
var SHELL = require("lib/shell");
var SYS = require("lib/system");
exports.VERSIONINFO = "Shadowsocks Lib (shadowsocks.js) version 0.1";
exports.global = global;
exports.require = global.require;
var arch = SYS.getArch();
if(arch.indexOf("64") > -1)) {
exports.binPath = "bin/shadowsocks-lib-mingw-x86_64/ss-local";
} else {
exports.binPath = "bin/shadowsocks-lib-mingw-x86/ss-local";
}
exports.connect = function(host, remotePort, localPort, password, algorithm) {
var commandOptions = [];
commandOptions.push(binPath);
commandOptions.push("-s");
commandOptions.push(host);
commandOptions.push("-p");
commandOptions.push(remotePort);
commandOptions.push("-l");
commandOptions.push(localPorts);
commandOptions.push("-k");
commandOptions.push(password);
commandOptions.push("-m");
commandOptions.push(algoritm);
SHELL.run(commandOptions.join(' '), true);
};