fix
This commit is contained in:
Namhyeon Go 2020-08-04 08:42:17 +09:00
parent ad2d3fc9b7
commit 5e44bd11e7
8 changed files with 102 additions and 52 deletions

3
.gitignore vendored
View File

@ -57,7 +57,7 @@ typings/
.rpt2_cache/ .rpt2_cache/
.rts2_cache_cjs/ .rts2_cache_cjs/
.rts2_cache_es/ .rts2_cache_es/
.rts2_cache_umd/ .rts2_cache_umd/package
# Optional REPL history # Optional REPL history
.node_repl_history .node_repl_history
@ -105,3 +105,4 @@ dist
# Custom directories and files # Custom directories and files
bin/ bin/
packages/

View File

@ -1 +0,0 @@

33
build.bat Normal file
View File

@ -0,0 +1,33 @@
@echo off
REM set required build-tools
set PATH=%WINDIR%\System32
set PATH=%PATH%;%CD%\packages\go1.14.6.windows-amd64\go\bin
set PATH=%PATH%;%CD%\packages\git-2.28.0-64-bit\bin
set PATH=%PATH%;%CD%\packages\winlibs-x86_64-posix-seh-gcc-10.2.0-llvm-10.0.0-mingw-w64-7.0.0-r2\mingw64\bin
set GOPATH=%CD%\packages\build\go
REM check a PATH variable
echo %PATH%
REM check a GOPATH variable
echo %GOPATH%
REM build a WinDivert handler
go get -v -ldflags="-s -w" -trimpath -tags=wintun github.com/gnh1201/shadow/executive/shadow
REM set destination folder
set BINPATH=%CD%\bin
rmdir %BINPATH% /s /q
mkdir %BINPATH%
REM copy required files
copy %CD%\packages\shadowsocks-libev-mingw-x86_64\ss-local.exe %BINPATH%\ss-local.exe
copy %CD%\packages\shadowsocks-libev-mingw-x86_64\*.dll %BINPATH%\
copy %CD%\packages\WinDivert-2.2.0-A\x64\WinDivert.dll %BINPATH%\WinDivert.dll
copy %CD%\packages\WinDivert-2.2.0-A\x64\WinDivert64.sys %BINPATH%\WinDivert64.sys
copy %CD%\packages\tun2socks-windows-4.0-amd64.exe %BINPATH%\tun2socks.exe
copy %CD%\packages\tap-windows-9.24.2-I601-Win10.exe %BINPATH%\tap-windows-9.24.2-I601-Win10.exe
copy %GOPATH%\bin\shadow.exe %BINPATH%\shadow.exe
echo done

View File

@ -8,13 +8,7 @@ var SYS = require("lib/system");
exports.VERSIONINFO = "Shadowsocks Lib (shadowsocks.js) version 0.1"; exports.VERSIONINFO = "Shadowsocks Lib (shadowsocks.js) version 0.1";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;
exports.binPath = "bin/ss-local.exe";
var arch = SYS.getArch();
if(arch.indexOf("64") > -1) {
exports.binPath = "bin/shadowsocks-libev-mingw-x86_64/ss-local.exe";
} else {
exports.binPath = "bin/shadowsocks-libev-mingw-x86/ss-local.exe";
}
exports.getRandomInt = function(min, max) { exports.getRandomInt = function(min, max) {
var x = Math.random(); var x = Math.random();

View File

@ -124,25 +124,21 @@ exports.getNetworkInterfaces = function() {
var wbemFlagForwardOnly = 0x20; var wbemFlagForwardOnly = 0x20;
var rows = []; var rows = [];
try { var colItems = WMI.ExecQuery(
var colItems = WMI.ExecQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration",
"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL",
"WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly
wbemFlagReturnImmediately | wbemFlagForwardOnly );
);
var enumItems = new Enumerator(colItems); var enumItems = new Enumerator(colItems);
for (; !enumItems.atEnd(); enumItems.moveNext()) { for (; !enumItems.atEnd(); enumItems.moveNext()) {
var objItem = enumItems.item(); var objItem = enumItems.item();
try { rows.push({
rows.push({ Caption: (objItem.Caption || ""),
Caption: objItem.Caption, IPAddress: (objItem.IPAddress || []).join(','),
IPAddress: objItem.IPAddress.toArray().join(','), MACAddress: (objItem.MACAddress || "")
MACAddress: objItem.MACAddress });
}); }
} catch(e) {}
}
} catch(e) {}
return rows; return rows;
}; };

View File

@ -8,14 +8,7 @@ var SYS = require("lib/system");
exports.VERSIONINFO = "TUN2SOCKS Lib (tun2socks.js) version 0.1"; exports.VERSIONINFO = "TUN2SOCKS Lib (tun2socks.js) version 0.1";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;
exports.binPath = "bin/tun2socks.exe";
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 {string} name

View File

@ -10,8 +10,6 @@ exports.VERSIONINFO = "WindowsTAP Lib (wintap.js) version 0.1";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;
var arch = SYS.getArch();
exports.infPath = SYS.getEnvString("PROGRAMFILES") + "/TAP-Windows/driver/OemVista.inf"; exports.infPath = SYS.getEnvString("PROGRAMFILES") + "/TAP-Windows/driver/OemVista.inf";
exports.binPath = SYS.getEnvString("PROGRAMFILES") + "/TAP-Windows/bin/tapinstall.exe"; exports.binPath = SYS.getEnvString("PROGRAMFILES") + "/TAP-Windows/bin/tapinstall.exe";

View File

@ -6,27 +6,63 @@ var SS = require("lib/shadowsocks");
var WINTAP = require("lib/wintap"); var WINTAP = require("lib/wintap");
var SYS = require("lib/system"); var SYS = require("lib/system");
var HOSTS = require("lib/hosts"); var HOSTS = require("lib/hosts");
var JSON = require("lib/json");
var ssConfig = {
Server: [],
NameServer: "https://1.1.1.1/dns-query",
FilterString: "outbound and (ip ? ip.DstAddr != 1.1.1.1 : true)",
TunName: "",
TunAddr: [
"192.168.0.11/24"
],
IPCIDRRules: {
Proxy: [
"198.18.0.0/16",
"8.8.8.8/32"
]
},
AppRules: {
Proxy: []
},
DomainRules: {
Proxy: [
"**.google.com",
"**.google.*",
"**.google.*.*",
"**.youtube.com",
"*.twitter.com",
"www.facebook.com",
"bing.com",
"**.amazon.*"
],
Direct: [
"**.baidu.*",
"**.youku.*",
"**.*"
],
Blocked: [
"ad.blocked.com"
]
}
};
exports.main = function() { exports.main = function() {
console.log("Connecting to shadowsocks..."); console.log("* Connecting to shadowsocks...");
var listenPort = SS.connect(); var listenPort = SS.connect();
console.log("Local listening port: " + listenPort); ssConfig.Server.push("socks://localhost:" + listenPort);
console.log("* Local listening port: " + listenPort);
console.log("Gethering network interfaces..."); console.log("* Gethering network interfaces...");
var inets = SYS.getNetworkInterfaces(); var inets = SYS.getNetworkInterfaces();
for (var i in inets) { for (var i = 0; i < inets.length; i++) {
console.log("Caption > " + inets[i].Caption); console.log(" > " + inets[i].Caption);
console.log(" > IPAddress > " + inets[i].IPAddress);
console.log(" > MACAddress > " + inets[i].MACAddress);
} }
console.log("Gethering hosts..."); console.log("* Gethering WindowsTAP interfaces...");
var hosts = HOSTS.getHosts();
for (var i = 0; i < hosts.length; i++) {
console.log(hosts[i].domain + " -> " + hosts[i].host);
}
console.log("Gethering WindowsTAP interfaces...");
console.log(WINTAP.query("tap0901")); console.log(WINTAP.query("tap0901"));
console.log("Done"); ssConfig.TunName = "TAP-Windows Adapter V9";
console.log(JSON.stringify(ssConfig));
}; };