Update lib/tun2socks.js, lib/winlibs.js, lib/wintap.js

This commit is contained in:
Namhyeon Go 2020-07-29 13:17:48 +09:00
parent 73fe0e8402
commit d29bd6c515
3 changed files with 79 additions and 3 deletions

50
lib/tun2socks.js Normal file
View File

@ -0,0 +1,50 @@
////////////////////////////////////////////////////////////////////////
// TUN2SOCKS API
////////////////////////////////////////////////////////////////////////
var SHELL = require("lib/shell");
var SYS = require("lib/system");
exports.VERSIONINFO = "TUN2SOCKS Lib (tun2socks.js) version 0.1";
exports.global = global;
exports.require = global.require;
var arch = SYS.getArch();
if(arch.indexOf("64")) {
exports.binPath = "bin/tun2socks-windows-4.0-amd64.exe";
} else {
exports.binPath = "bin/tun2socks-windows-4.0-386.exe";
}
/**
* @param {string} name
* @param {Object} options
*/
exports.assign = function(name, options) {
var defaultOptions = {
tunAddr: "10.0.0.2",
tunGw: "10.0.0.1",
proxyType: "socks",
proxyServer: "127.0.0.1:1080",
tunDns: "8.8.8.8,8.8.4.4", // Cloudflare DNS
tunName: name
}, _options = options, cmd = [];
// fill with default options
for (var k in defaultOptions) {
if (!(k in _options)) {
_options[k] = defaultOptions[k];
}
}
// make command
cmd.push("tun2socks");
for (var k in _options) {
cmd.push('-' + k);
cmd.push(_options[k]);
}
// return
SHELL.run(cmd);
};

View File

@ -9,6 +9,10 @@ exports.require = global.require;
var SHELL = require("lib/shell");
var FILE = require("lib/file");
/**
* @param {string} LIB
* @return {function}
*/
exports.loadLibrary = function(LIB) {
var dllManifest = LIB + ".manifest";
@ -44,10 +48,16 @@ exports.loadLibrary = function(LIB) {
}
};
exports.SHELL32 = (function() {
return exports.loadLibrary("SHELL32");
})();
/**
*/
exports.SHELL32 = exports.loadLibrary("SHELL32");
/**
* @param {string} name
* @param {Object} applets
* @param {Array} applets
* @return {string}
*/
exports.showControlPanel = function(name, applets, args) {
var _applets = [];
var _args = [];
@ -67,10 +77,14 @@ exports.showControlPanel = function(name, applets, args) {
return exports.SHELL32.call("Control_runDLL", _args);
};
/**
*/
exports.showNetworkAdapters = function() {
return exports.openControlPanel("ncpa", ["@0", 3]);
};
/**
*/
exports.showWindowsCopyright = function() {
return exports.SHELL32.call("ShellAboutW");
};

View File

@ -24,21 +24,33 @@ exports.before = function() {
}
};
/**
* @param {string} id
*/
exports.install = function(id) {
exports.before();
return SHELL.exec([exports.binPath, "install", exports.infPath, id]);
};
/**
* @param {string} id
*/
exports.update = function(id) {
exports.before();
return SHELL.exec([exports.binPath, "update", exports.infPath, id]);
};
/**
* @param {string} id
*/
exports.query = function(id) {
exports.before();
return SHELL.exec([exports.binPath, "hwids", id]);
};
/**
* @param {string} id
*/
exports.remove = function(id) {
exports.before();
return SHELL.exec([exports.binPath, "remove", id]);