mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-11 09:24:58 +00:00
update files
This commit is contained in:
parent
176938edc3
commit
054dcb27f8
13
app.js
13
app.js
|
@ -114,14 +114,15 @@ function require(FN) {
|
|||
var __dirname = getDirName(__filename);
|
||||
|
||||
// load script file
|
||||
var FSO = CreateObject("Scripting.FileSystemObject");
|
||||
// use ADODB.Stream instead of Scripting.FileSystemObject, because of UTF-8 (unicode)
|
||||
var objStream = CreateObject("ADODB.Stream");
|
||||
var T = null;
|
||||
try {
|
||||
TS = FSO.OpenTextFile(__filename, 1);
|
||||
if (TS.AtEndOfStream) return "";
|
||||
T = TS.ReadAll();
|
||||
TS.Close();
|
||||
TS = null;
|
||||
objStream.charSet = "utf-8";
|
||||
objStream.open();
|
||||
objStream.loadFromFile(__filename);
|
||||
T = objStream.readText();
|
||||
objStream.close();
|
||||
} catch (e) {
|
||||
console.error("LOAD ERROR! " + e.number + ", " + e.description + ", FN=" + FN, 1);
|
||||
return;
|
||||
|
|
|
@ -157,20 +157,44 @@ input.text {
|
|||
|
||||
#content .statusbox {
|
||||
width: 360px;
|
||||
margin: 60px auto;
|
||||
margin: 100px auto;
|
||||
}
|
||||
|
||||
#content .statusbox ul li {
|
||||
#content .statusbox .box1 ul li {
|
||||
float: left;
|
||||
width: 180px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
#content .statusbox ul li dl dt {
|
||||
#content .statusbox .box1 ul li dl dt {
|
||||
color: #616686;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#content .statusbox ul li dl dd {
|
||||
#content .statusbox .box1 ul li dl dd {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#content .statusbox .box1 button.connect {
|
||||
border: 0;
|
||||
background: none;
|
||||
background-color: #43a747;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
padding: 3px 15px;
|
||||
border-radius: 8px;
|
||||
font-size: 1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#content .statusbox .box1 button.disconnect {
|
||||
border: 0;
|
||||
background: none;
|
||||
background-color: #db0000;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
padding: 3px 15px;
|
||||
border-radius: 8px;
|
||||
font-size: 1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
BIN
app/assets/img/gear-2-16.png
Normal file
BIN
app/assets/img/gear-2-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 411 B |
BIN
app/assets/img/server-16.png
Normal file
BIN
app/assets/img/server-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 358 B |
|
@ -1,15 +1,20 @@
|
|||
<div id="aside">
|
||||
<div class="searchbox">
|
||||
<input id="keyword" class="text" type="text" placeholder="위치 찾아보기..."/>
|
||||
<input id="keyword" class="text" type="text" placeholder="찾아보기..."/>
|
||||
</div>
|
||||
|
||||
<div class="serverbox">
|
||||
<ul>
|
||||
<li>
|
||||
<span>모든 네트워크</span>
|
||||
<ul class="sub">
|
||||
<span>할당된 서버</span>
|
||||
<ul id="userServers" class="sub">
|
||||
<li class="show-no-logged"><span><img src="app/assets/img/iconfinder_Caution_53013.png" alt="Caution" /> 로그인하세요</span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span>할당된 프로세스</span>
|
||||
<ul id="userProcesses" class="sub">
|
||||
<li class="show-no-logged"><span><img src="app/assets/img/iconfinder_Caution_53013.png" alt="Caution" /> 로그인하세요</span></li>
|
||||
<server-item v-for="item in servers" v-bind:item="item" v-bind:key="item.id"></server-item>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -58,46 +63,24 @@
|
|||
<button id="btn_logout" class="logout" type="button">로그아웃</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="statusbox">
|
||||
<ul>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>서버:</dt>
|
||||
<dd>-</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>상태:</dt>
|
||||
<dd><span style="font-weight: bold;">연결 안됨</span></dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>IP:</dt>
|
||||
<dd>-</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>업타임:</dt>
|
||||
<dd>-</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>보냄:</dt>
|
||||
<dd>-</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>받음: <a onclick="javascript:console.log('test');">test</a></dt>
|
||||
<dd>-</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="box1">
|
||||
<ul>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>상태:</dt>
|
||||
<dd>
|
||||
<span id="textbox_status">연결 안됨</span>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>
|
||||
<button id="btn_connect" class="connect" type="button">연결</button>
|
||||
<button id="btn_disconnect" class="disconnect" type="button">종료</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
113
app/index.js
113
app/index.js
|
@ -1,32 +1,43 @@
|
|||
var global = {};
|
||||
|
||||
var FILE = require("lib/file");
|
||||
var SSLoader = require("ssloader");
|
||||
|
||||
Vue.component("server-item", {
|
||||
props: ['item'],
|
||||
template: '<li class="show-logged"><a href="#"><span><img :src="item.icon"> {{item.title}}</span></a></li>'
|
||||
});
|
||||
global.processNames = [];
|
||||
global.serverNames = [];
|
||||
|
||||
var app = new Vue({
|
||||
el: "#app",
|
||||
data: {
|
||||
servers: [
|
||||
{
|
||||
icon: "app/assets/img/flags/shiny/16/United-States.png",
|
||||
country: "United States",
|
||||
title: "US 1"
|
||||
},
|
||||
{
|
||||
icon: "app/assets/img/flags/shiny/16/United-States.png",
|
||||
country: "United States",
|
||||
title: "US 2"
|
||||
},
|
||||
{
|
||||
icon: "app/assets/img/flags/shiny/16/United-States.png",
|
||||
country: "United States",
|
||||
title: "US 3"
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
var loginSuccess = function(res) {
|
||||
// 성공하면 아이디 표시
|
||||
$("#logged_username").text(res.data.username);
|
||||
|
||||
// 서버 및 프로세스 정보 수신
|
||||
var token = FILE.readFile("token.txt", "utf-8");
|
||||
$.get(__config.webapp.baseURL, {
|
||||
route: "detail.user",
|
||||
action: "api",
|
||||
token: token
|
||||
}, function(res) {
|
||||
// 사용자 프로세스 조회
|
||||
var $userProcesses = $("#userProcesses");
|
||||
for (var i in res.processes) {
|
||||
var row = res.processes[i];
|
||||
$userProcesses.append('<li class="show-logged remove-when-logout"><span><img src="app/assets/img/gear-2-16.png" alt="Process" /> ' + row.processname + '</span></li>');
|
||||
global.processNames.push(row.processname);
|
||||
}
|
||||
|
||||
// 사용자 서버 조회
|
||||
var $userServers = $("#userServers");
|
||||
for (var i in res.serverusers) {
|
||||
var row = res.serverusers[i];
|
||||
$userServers.append('<li class="show-logged remove-when-logout"><span><img src="app/assets/img/server-16.png" alt="Server" /> ' + row.servername + '</span></li>');
|
||||
global.serverNames.push(row.servername);
|
||||
}
|
||||
});
|
||||
|
||||
// 화면 전환
|
||||
$(".show-no-logged").css("display", "none");
|
||||
$(".show-logged").css("display", "");
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".show-logged").css("display", "none");
|
||||
|
@ -34,11 +45,11 @@ $(document).ready(function() {
|
|||
$("#loginform").attr("action", __config.webapp.baseURL);
|
||||
$("#loginform").ajaxForm({
|
||||
beforeSubmit: function() {
|
||||
console.log("로그인을 시도합니다. 잠시만 기다려 주세요.");
|
||||
console.info("로그인을 시도합니다. 잠시만 기다려 주세요.");
|
||||
},
|
||||
success: function(res) {
|
||||
if(res.success === false) {
|
||||
console.log("로그인에 실패하였습니다. 다시 시도하여 주세요");
|
||||
console.info("로그인에 실패하였습니다. 다시 시도하여 주세요");
|
||||
} else {
|
||||
// 로그인 사용자의 토큰을 저장
|
||||
FILE.writeFile("token.txt", res.data.token, "utf-8");
|
||||
|
@ -46,21 +57,16 @@ $(document).ready(function() {
|
|||
// 저장 여부 확인
|
||||
var isTokenExists = FILE.fileExists("token.txt");
|
||||
if(isTokenExists) {
|
||||
// 성공하면 아이디 표시
|
||||
$("#logged_username").text(res.data.username);
|
||||
|
||||
// 화면 전환
|
||||
$(".show-no-logged").css("display", "none");
|
||||
$(".show-logged").css("display", "");
|
||||
loginSuccess(res); // 로그인 성공 시 수행
|
||||
} else {
|
||||
console.log("저장공간이 충분한지 확인하여 주세요");
|
||||
console.info("저장공간이 충분한지 확인하여 주세요");
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
var errorMessage = xhr.status + ': ' + xhr.statusText;
|
||||
console.log(xhr.responseText);
|
||||
console.log('Error: ' + errorMessage);
|
||||
console.info(xhr.responseText);
|
||||
console.info('Error: ' + errorMessage);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -68,17 +74,12 @@ $(document).ready(function() {
|
|||
var isTokenExists = FILE.fileExists("token.txt");
|
||||
if(isTokenExists) {
|
||||
var token = FILE.readFile("token.txt", "utf-8");
|
||||
$.get(serverUrl, {
|
||||
$.get(__config.webapp.baseURL, {
|
||||
route: "api.auth.json",
|
||||
action: "checkToken",
|
||||
token: token
|
||||
}, function(res) {
|
||||
// 토큰 확인에 성공하면 아이디 표시
|
||||
$("#logged_username").text(res.data.username);
|
||||
|
||||
// 화면 전환
|
||||
$(".show-no-logged").css("display", "none");
|
||||
$(".show-logged").css("display", "");
|
||||
loginSuccess(res); // 로그인 성공 시 수행
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -92,12 +93,30 @@ $(document).ready(function() {
|
|||
// 토큰 파일 삭제
|
||||
FILE.deleteFile("token.txt");
|
||||
|
||||
// todo: expire token in the database
|
||||
|
||||
// 삭제할 객체를 모두 찾아 지움
|
||||
$(".remove-when-logout").remove();
|
||||
|
||||
// 화면 전환
|
||||
$(".loginbox").css("display", "");
|
||||
$(".logoutbox").css("display", "none");
|
||||
$(".show-no-logged").css("display", "");
|
||||
$(".show-logged").css("display", "none");
|
||||
|
||||
console.log("로그아웃 되었습니다.");
|
||||
console.info("로그아웃 되었습니다.");
|
||||
});
|
||||
|
||||
// 연결
|
||||
$("#btn_connect").click(function() {
|
||||
var isTokenExists = FILE.fileExists("token.txt");
|
||||
if(isTokenExists) {
|
||||
SSLoader.main();
|
||||
} else {
|
||||
console.info("로그인을 먼저 진행하여 주세요.");
|
||||
}
|
||||
});
|
||||
|
||||
// 종료
|
||||
$("#btn_disconnect").click(function() {
|
||||
// todo
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
exports.config = {
|
||||
appName: "welsonjs",
|
||||
development: true,
|
||||
development: false,
|
||||
shadowsocks: {
|
||||
host: "158.247.196.146",
|
||||
port: 8388,
|
||||
|
|
40
config.json
Normal file
40
config.json
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"Server": [
|
||||
"socks://localhost:61654"
|
||||
],
|
||||
"NameServer": "https://1.1.1.1/dns-query",
|
||||
"FilterString": "outbound and (ip ? ip.DstAddr != 1.1.1.1 : true)",
|
||||
"TunName": "TAP-Windows Adapter V9",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -232,15 +232,4 @@ exports.start = function(callback) {
|
|||
exports.addScript("app/assets/js/PIE-1.0.0.js");
|
||||
exports.addScript("app/assets/js/jquery.html5-placeholder-shim-5a87f05.js");
|
||||
}
|
||||
|
||||
// load VUE (2.6.11), vue-router (3.3.4), axios (0.19.2)
|
||||
if (!__config.development) {
|
||||
exports.addScript("app/assets/js/vue-2.6.11.min.js");
|
||||
exports.addScript("app/assets/js/vue-router-3.3.4.min.js");
|
||||
exports.addScript("app/assets/js/axios-0.19.2.min.js");
|
||||
} else {
|
||||
exports.addScript("app/assets/js/vue-2.6.11.js");
|
||||
exports.addScript("app/assets/js/vue-router-3.3.4.js");
|
||||
exports.addScript("app/assets/js/axios-0.19.2.js");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,3 +37,8 @@ exports.execCommand = function(cmd) {
|
|||
"& {" + cmd + "}"
|
||||
]);
|
||||
};
|
||||
|
||||
exports.runAs = function(cmd) {
|
||||
return PS.execCommand("Start-Process cmd \"/q /k " + cmd + "\" -Verb RunAs");
|
||||
};
|
||||
|
||||
|
|
|
@ -56,3 +56,4 @@ exports.run = function(cmd, fork) {
|
|||
console.info("run() -> " + c);
|
||||
WSH.Run(c, 0, !fork);
|
||||
};
|
||||
|
||||
|
|
30
ssloader.js
30
ssloader.js
|
@ -5,8 +5,7 @@
|
|||
var SS = require("lib/shadowsocks");
|
||||
var WINTAP = require("lib/wintap");
|
||||
var SYS = require("lib/system");
|
||||
var HOSTS = require("lib/hosts");
|
||||
var JSON = require("lib/json");
|
||||
var FILE = require("lib/file");
|
||||
|
||||
var ssConfig = {
|
||||
Server: [],
|
||||
|
@ -48,21 +47,40 @@ var ssConfig = {
|
|||
};
|
||||
|
||||
exports.main = function() {
|
||||
console.log("* Connecting to shadowsocks...");
|
||||
// 내부 포트 결정
|
||||
console.log("* Connecting to socket proxy...");
|
||||
var listenPort = SS.connect();
|
||||
ssConfig.Server.push("socks://localhost:" + listenPort);
|
||||
console.log("* Local listening port: " + listenPort);
|
||||
|
||||
// 네트워크 인터페이스 정보 조회
|
||||
console.log("* Gethering network interfaces...");
|
||||
var inets = SYS.getNetworkInterfaces();
|
||||
for (var i = 0; i < inets.length; i++) {
|
||||
console.log(" > " + inets[i].Caption);
|
||||
}
|
||||
|
||||
// TAP 설치 여부 조회
|
||||
console.log("* Gethering WindowsTAP interfaces...");
|
||||
console.log(WINTAP.query("tap0901"));
|
||||
ssConfig.TunName = "TAP-Windows Adapter V9";
|
||||
|
||||
console.log(JSON.stringify(ssConfig));
|
||||
|
||||
|
||||
// 앱 규칙 설정
|
||||
var processNames = global.processNames;
|
||||
for (var i in processNames) {
|
||||
ssConfig.AppRules.Proxy.push(processNames[i]);
|
||||
}
|
||||
|
||||
// 설정 파일 저장
|
||||
var serialized_ssConfig = JSON.stringify(ssConfig, null, 4);
|
||||
if (FILE.fileExists("config.json")) {
|
||||
FILE.deleteFile("config.json");
|
||||
}
|
||||
FILE.writeFile("config.json", serialized_ssConfig, "utf-8");
|
||||
console.info("설정 파일 저장 완료!");
|
||||
|
||||
// 앱 프록시 실행
|
||||
console.info("앱 프록시는 관리자 권한을 필요로 합니다. 확인을 눌러주세요.");
|
||||
};
|
||||
|
||||
exports.ssConfig = ssConfig;
|
||||
|
|
|
@ -22,6 +22,15 @@ global.console.__echo = function(msg) {
|
|||
global.console.__messages.push(msg);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Override global.console.log()
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
global.console.log = function(msg) {
|
||||
if (__config.development === true) {
|
||||
global.console.__echo(msg);
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Override global.exit()
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue
Block a user