xtunnel 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/config/default.json +1 -1
- package/core/config.json +1 -1
- package/index.js +12 -3
- package/package.json +1 -1
package/config/default.json
CHANGED
package/core/config.json
CHANGED
package/index.js
CHANGED
@@ -9,7 +9,9 @@ const config = JSON.parse(fs.readFileSync(path.join(__dirname, './config/default
|
|
9
9
|
|
10
10
|
let rayProcess = null
|
11
11
|
|
12
|
-
|
12
|
+
[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `uncaughtException`, `SIGTERM`].forEach((eventType) => {
|
13
|
+
process.on(eventType, stop.bind(null, eventType))
|
14
|
+
})
|
13
15
|
|
14
16
|
program.version('1.0.0').description('Tunnel CLI')
|
15
17
|
program.command('* <url>').action(url => url && run(url))
|
@@ -29,25 +31,32 @@ async function run(url) {
|
|
29
31
|
}
|
30
32
|
} catch (error) {
|
31
33
|
console.error(error)
|
34
|
+
console.error('SUBSCRIBE LINK ERROR')
|
32
35
|
}
|
33
36
|
}
|
34
37
|
|
35
38
|
function start() {
|
39
|
+
console.log('TUNNEL START')
|
36
40
|
// 关闭上个进程
|
37
41
|
rayProcess && rayProcess.kill('SIGINT')
|
38
42
|
// 设置系统代理
|
39
43
|
setSystemProxy(config.setting.localHttpPort)
|
40
44
|
// 根据操作系统平台-启动新进程
|
41
|
-
rayProcess = child_process.exec(path.join(__dirname, './core/xray-linux-x64'), (error, stdout, stderr) => error && stop()
|
45
|
+
rayProcess = child_process.exec(path.join(__dirname, './core/xray-linux-x64'), (error, stdout, stderr) => error && stop(true))
|
42
46
|
rayProcess.stdout.on('data', console.log)
|
43
47
|
rayProcess.stderr.on('data', console.error)
|
44
48
|
}
|
45
49
|
|
46
|
-
function stop() {
|
50
|
+
function stop(isRestart) {
|
51
|
+
console.log('TUNNEL STOP')
|
47
52
|
// 关闭上个进程
|
48
53
|
rayProcess && rayProcess.kill('SIGINT')
|
49
54
|
// 取消系统代理
|
50
55
|
setSystemProxy()
|
56
|
+
if (isRestart) {
|
57
|
+
console.error('启动失败(请检查权限/端口占用),重新启动中...')
|
58
|
+
start()
|
59
|
+
}
|
51
60
|
return true
|
52
61
|
}
|
53
62
|
|