xtunnel 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,7 +33,7 @@
33
33
  "tpl": {
34
34
  "log": {
35
35
  "error": "",
36
- "loglevel": "none",
36
+ "loglevel": "error",
37
37
  "access": ""
38
38
  },
39
39
  "inbounds": [
package/core/config.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "log": {
3
3
  "error": "",
4
- "loglevel": "none",
4
+ "loglevel": "error",
5
5
  "access": ""
6
6
  },
7
7
  "inbounds": [
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
- process.on('exit', () => stop())
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() && console.error('启动失败,请检查权限/端口占用'))
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xtunnel",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "xtunnel",
5
5
  "main": "index.js",
6
6
  "scripts": {},