update files

This commit is contained in:
Namhyeon Go 2020-08-04 18:29:42 +09:00
parent 176938edc3
commit 054dcb27f8
14 changed files with 208 additions and 118 deletions

13
app.js
View File

@ -114,14 +114,15 @@ function require(FN) {
var __dirname = getDirName(__filename); var __dirname = getDirName(__filename);
// load script file // 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; var T = null;
try { try {
TS = FSO.OpenTextFile(__filename, 1); objStream.charSet = "utf-8";
if (TS.AtEndOfStream) return ""; objStream.open();
T = TS.ReadAll(); objStream.loadFromFile(__filename);
TS.Close(); T = objStream.readText();
TS = null; objStream.close();
} catch (e) { } catch (e) {
console.error("LOAD ERROR! " + e.number + ", " + e.description + ", FN=" + FN, 1); console.error("LOAD ERROR! " + e.number + ", " + e.description + ", FN=" + FN, 1);
return; return;

View File

@ -157,20 +157,44 @@ input.text {
#content .statusbox { #content .statusbox {
width: 360px; width: 360px;
margin: 60px auto; margin: 100px auto;
} }
#content .statusbox ul li { #content .statusbox .box1 ul li {
float: left; float: left;
width: 180px; width: 180px;
margin: 10px 0; margin: 10px 0;
} }
#content .statusbox ul li dl dt { #content .statusbox .box1 ul li dl dt {
color: #616686; color: #616686;
display: inline; display: inline;
} }
#content .statusbox ul li dl dd { #content .statusbox .box1 ul li dl dd {
display: inline; 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

View File

@ -1,15 +1,20 @@
<div id="aside"> <div id="aside">
<div class="searchbox"> <div class="searchbox">
<input id="keyword" class="text" type="text" placeholder="위치 찾아보기..."/> <input id="keyword" class="text" type="text" placeholder="찾아보기..."/>
</div> </div>
<div class="serverbox"> <div class="serverbox">
<ul> <ul>
<li> <li>
<span>모든 네트워크</span> <span>할당된 서버</span>
<ul class="sub"> <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> <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> </ul>
</li> </li>
</ul> </ul>
@ -58,46 +63,24 @@
<button id="btn_logout" class="logout" type="button">로그아웃</button> <button id="btn_logout" class="logout" type="button">로그아웃</button>
</div> </div>
</div> </div>
<div class="statusbox"> <div class="statusbox">
<ul> <div class="box1">
<li> <ul>
<dl> <li>
<dt>서버:</dt> <dl>
<dd>-</dd> <dt>상태:</dt>
</dl> <dd>
</li> <span id="textbox_status">연결 안됨</span>
<li> </dd>
<dl> </dl>
<dt>상태:</dt> </li>
<dd><span style="font-weight: bold;">연결 안됨</span></dd> <li>
</dl> <button id="btn_connect" class="connect" type="button">연결</button>
</li> <button id="btn_disconnect" class="disconnect" type="button">종료</button>
<li> </li>
<dl> </ul>
<dt>IP:</dt> </div>
<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> </div>
</div> </div>

View File

@ -1,32 +1,43 @@
var global = {};
var FILE = require("lib/file"); var FILE = require("lib/file");
var SSLoader = require("ssloader");
Vue.component("server-item", { global.processNames = [];
props: ['item'], global.serverNames = [];
template: '<li class="show-logged"><a href="#"><span><img :src="item.icon"> {{item.title}}</span></a></li>'
});
var app = new Vue({ var loginSuccess = function(res) {
el: "#app", // 성공하면 아이디 표시
data: { $("#logged_username").text(res.data.username);
servers: [
{ // 서버 및 프로세스 정보 수신
icon: "app/assets/img/flags/shiny/16/United-States.png", var token = FILE.readFile("token.txt", "utf-8");
country: "United States", $.get(__config.webapp.baseURL, {
title: "US 1" route: "detail.user",
}, action: "api",
{ token: token
icon: "app/assets/img/flags/shiny/16/United-States.png", }, function(res) {
country: "United States", // 사용자 프로세스 조회
title: "US 2" var $userProcesses = $("#userProcesses");
}, for (var i in res.processes) {
{ var row = res.processes[i];
icon: "app/assets/img/flags/shiny/16/United-States.png", $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>');
country: "United States", global.processNames.push(row.processname);
title: "US 3" }
}
] // 사용자 서버 조회
} 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() { $(document).ready(function() {
$(".show-logged").css("display", "none"); $(".show-logged").css("display", "none");
@ -34,11 +45,11 @@ $(document).ready(function() {
$("#loginform").attr("action", __config.webapp.baseURL); $("#loginform").attr("action", __config.webapp.baseURL);
$("#loginform").ajaxForm({ $("#loginform").ajaxForm({
beforeSubmit: function() { beforeSubmit: function() {
console.log("로그인을 시도합니다. 잠시만 기다려 주세요."); console.info("로그인을 시도합니다. 잠시만 기다려 주세요.");
}, },
success: function(res) { success: function(res) {
if(res.success === false) { if(res.success === false) {
console.log("로그인에 실패하였습니다. 다시 시도하여 주세요"); console.info("로그인에 실패하였습니다. 다시 시도하여 주세요");
} else { } else {
// 로그인 사용자의 토큰을 저장 // 로그인 사용자의 토큰을 저장
FILE.writeFile("token.txt", res.data.token, "utf-8"); FILE.writeFile("token.txt", res.data.token, "utf-8");
@ -46,21 +57,16 @@ $(document).ready(function() {
// 저장 여부 확인 // 저장 여부 확인
var isTokenExists = FILE.fileExists("token.txt"); var isTokenExists = FILE.fileExists("token.txt");
if(isTokenExists) { if(isTokenExists) {
// 성공하면 아이디 표시 loginSuccess(res); // 로그인 성공 시 수행
$("#logged_username").text(res.data.username);
// 화면 전환
$(".show-no-logged").css("display", "none");
$(".show-logged").css("display", "");
} else { } else {
console.log("저장공간이 충분한지 확인하여 주세요"); console.info("저장공간이 충분한지 확인하여 주세요");
} }
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
var errorMessage = xhr.status + ': ' + xhr.statusText; var errorMessage = xhr.status + ': ' + xhr.statusText;
console.log(xhr.responseText); console.info(xhr.responseText);
console.log('Error: ' + errorMessage); console.info('Error: ' + errorMessage);
} }
}); });
@ -68,17 +74,12 @@ $(document).ready(function() {
var isTokenExists = FILE.fileExists("token.txt"); var isTokenExists = FILE.fileExists("token.txt");
if(isTokenExists) { if(isTokenExists) {
var token = FILE.readFile("token.txt", "utf-8"); var token = FILE.readFile("token.txt", "utf-8");
$.get(serverUrl, { $.get(__config.webapp.baseURL, {
route: "api.auth.json", route: "api.auth.json",
action: "checkToken", action: "checkToken",
token: token token: token
}, function(res) { }, function(res) {
// 토큰 확인에 성공하면 아이디 표시 loginSuccess(res); // 로그인 성공 시 수행
$("#logged_username").text(res.data.username);
// 화면 전환
$(".show-no-logged").css("display", "none");
$(".show-logged").css("display", "");
}); });
} }
@ -92,12 +93,30 @@ $(document).ready(function() {
// 토큰 파일 삭제 // 토큰 파일 삭제
FILE.deleteFile("token.txt"); FILE.deleteFile("token.txt");
// todo: expire token in the database // 삭제할 객체를 모두 찾아 지움
$(".remove-when-logout").remove();
// 화면 전환 // 화면 전환
$(".loginbox").css("display", ""); $(".loginbox").css("display", "");
$(".logoutbox").css("display", "none"); $(".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
}); });
}); });

View File

@ -1,6 +1,6 @@
exports.config = { exports.config = {
appName: "welsonjs", appName: "welsonjs",
development: true, development: false,
shadowsocks: { shadowsocks: {
host: "158.247.196.146", host: "158.247.196.146",
port: 8388, port: 8388,

40
config.json Normal file
View 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"
]
}
}

View File

@ -232,15 +232,4 @@ exports.start = function(callback) {
exports.addScript("app/assets/js/PIE-1.0.0.js"); exports.addScript("app/assets/js/PIE-1.0.0.js");
exports.addScript("app/assets/js/jquery.html5-placeholder-shim-5a87f05.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");
}
}; };

View File

@ -37,3 +37,8 @@ exports.execCommand = function(cmd) {
"& {" + cmd + "}" "& {" + cmd + "}"
]); ]);
}; };
exports.runAs = function(cmd) {
return PS.execCommand("Start-Process cmd \"/q /k " + cmd + "\" -Verb RunAs");
};

View File

@ -56,3 +56,4 @@ exports.run = function(cmd, fork) {
console.info("run() -> " + c); console.info("run() -> " + c);
WSH.Run(c, 0, !fork); WSH.Run(c, 0, !fork);
}; };

View File

@ -5,8 +5,7 @@
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"); var FILE = require("lib/file");
var JSON = require("lib/json");
var ssConfig = { var ssConfig = {
Server: [], Server: [],
@ -48,21 +47,40 @@ var ssConfig = {
}; };
exports.main = function() { exports.main = function() {
console.log("* Connecting to shadowsocks..."); // 내부 포트 결정
console.log("* Connecting to socket proxy...");
var listenPort = SS.connect(); var listenPort = SS.connect();
ssConfig.Server.push("socks://localhost:" + listenPort); ssConfig.Server.push("socks://localhost:" + listenPort);
console.log("* Local listening port: " + 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 = 0; i < inets.length; i++) { for (var i = 0; i < inets.length; i++) {
console.log(" > " + inets[i].Caption); console.log(" > " + inets[i].Caption);
} }
// TAP 설치 여부 조회
console.log("* Gethering WindowsTAP interfaces..."); console.log("* Gethering WindowsTAP interfaces...");
console.log(WINTAP.query("tap0901")); console.log(WINTAP.query("tap0901"));
ssConfig.TunName = "TAP-Windows Adapter V9"; 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;

1
token.txt Normal file
View File

@ -0,0 +1 @@
32fiJjwxNmDhSpLhqG1yKPt7qTxMFyno

View File

@ -22,6 +22,15 @@ global.console.__echo = function(msg) {
global.console.__messages.push(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() // Override global.exit()
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////