mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 23:14:58 +00:00
Update lib/hosts.js, lib/system.js, ssloader.js
This commit is contained in:
parent
7574777c9c
commit
7556c0cce4
29
lib/hosts.js
Normal file
29
lib/hosts.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Hosts API
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
var SYS = require("lib/system");
|
||||||
|
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");
|
||||||
|
|
||||||
|
var lines = fileContent.split(/[\r\n]+/g).filter(function(s) {
|
||||||
|
return !(s.indexOf('#') == 0)
|
||||||
|
}).map(function(s) {
|
||||||
|
return s.replace(/\s\s/g, ' ');
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var i = 0; i < lines.length; i++) {
|
||||||
|
var col = lines[i].split(' ');
|
||||||
|
hosts.push({
|
||||||
|
host: col[0],
|
||||||
|
domain: col[1]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return hosts;
|
||||||
|
};
|
|
@ -137,7 +137,7 @@ exports.getNetworkInterfaces = function() {
|
||||||
try {
|
try {
|
||||||
rows.push({
|
rows.push({
|
||||||
Caption: objItem.Caption,
|
Caption: objItem.Caption,
|
||||||
IPAddresses: objItem.IPAddress.toArray(),
|
IPAddress: objItem.IPAddress.toArray().join(','),
|
||||||
MACAddress: objItem.MACAddress
|
MACAddress: objItem.MACAddress
|
||||||
});
|
});
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
|
|
19
ssloader.js
19
ssloader.js
|
@ -5,21 +5,28 @@
|
||||||
var SS = require("lib/shadowsocks");
|
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");
|
||||||
|
|
||||||
exports.main = function() {
|
exports.main = function() {
|
||||||
console.log("Connecting to shadowsocks...");
|
console.log("Connecting to shadowsocks...");
|
||||||
var proxyport = SS.connect();
|
var proxyport = SS.connect();
|
||||||
console.log(proxyport);
|
console.log(proxyport);
|
||||||
|
|
||||||
console.log("Gethering informations of network interfaces");
|
console.log("Gethering network interfaces...");
|
||||||
var inets = SYS.getNetworkInterfaces();
|
var inets = SYS.getNetworkInterfaces();
|
||||||
for(var i in inets) {
|
for (var i in inets) {
|
||||||
console.log(inets[i].Caption);
|
console.log("Caption > " + inets[i].Caption);
|
||||||
console.log(" > " + inets[i].IPAddresses.join(","));
|
console.log(" > IPAddress > " + inets[i].IPAddress);
|
||||||
console.log(" > " + inets[i].MACAddress);
|
console.log(" > MACAddress > " + inets[i].MACAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Installing new WindowsTAP...");
|
console.log("Gethering hosts...");
|
||||||
|
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");
|
console.log("Done");
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user