xtunnel 1.1.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "setting": {
3
3
  "localHttpPort": "10870",
4
- "localSockPort": "1080",
4
+ "localSockPort": "10800",
5
5
  "subscribeLink": "",
6
6
  "selectedServer": "",
7
- "selectedMode": "PAC"
7
+ "selectedMode": "GLOBAL"
8
8
  },
9
9
  "routingPac": {
10
10
  "domainStrategy": "IPOnDemand",
@@ -44,7 +44,7 @@
44
44
  "udp": false,
45
45
  "auth": "noauth"
46
46
  },
47
- "port": "1080"
47
+ "port": "10800"
48
48
  },
49
49
  {
50
50
  "listen": "127.0.0.1",
@@ -52,7 +52,7 @@
52
52
  "settings": {
53
53
  "timeout": 360
54
54
  },
55
- "port": "1087"
55
+ "port": "10870"
56
56
  }
57
57
  ],
58
58
  "outbounds": [
package/core/config.json CHANGED
@@ -1,89 +0,0 @@
1
- {
2
- "log": {
3
- "error": "",
4
- "loglevel": "error",
5
- "access": ""
6
- },
7
- "inbounds": [
8
- {
9
- "listen": "127.0.0.1",
10
- "protocol": "socks",
11
- "settings": {
12
- "udp": false,
13
- "auth": "noauth"
14
- },
15
- "port": "1080"
16
- },
17
- {
18
- "listen": "127.0.0.1",
19
- "protocol": "http",
20
- "settings": {
21
- "timeout": 360
22
- },
23
- "port": "1087"
24
- }
25
- ],
26
- "outbounds": [
27
- {
28
- "mux": {
29
- "enabled": false,
30
- "concurrency": 8
31
- },
32
- "protocol": "vmess",
33
- "streamSettings": {
34
- "wsSettings": {
35
- "path": "/v2ray",
36
- "headers": {
37
- "host": ""
38
- }
39
- },
40
- "tlsSettings": {
41
- "allowInsecure": true
42
- },
43
- "security": "none",
44
- "network": "ws"
45
- },
46
- "tag": "proxy",
47
- "settings": {
48
- "vnext": [
49
- {
50
- "address": "u3.amazonfeed.net",
51
- "users": [
52
- {
53
- "id": "d289df49-72eb-3b11-b83f-928b0a0f0dfc",
54
- "alterId": 2,
55
- "level": 0,
56
- "security": "aes-128-gcm"
57
- }
58
- ],
59
- "port": 11101
60
- }
61
- ]
62
- }
63
- },
64
- {
65
- "tag": "direct",
66
- "protocol": "freedom",
67
- "settings": {
68
- "domainStrategy": "UseIP",
69
- "redirect": "",
70
- "userLevel": 0
71
- }
72
- },
73
- {
74
- "tag": "block",
75
- "protocol": "blackhole",
76
- "settings": {
77
- "response": {
78
- "type": "none"
79
- }
80
- }
81
- }
82
- ],
83
- "dns": {},
84
- "routing": {
85
- "domainStrategy": "AsIs",
86
- "rules": []
87
- },
88
- "transport": {}
89
- }
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const program = require('commander')
4
- const axios = require('axios')
5
4
  const path = require('path')
6
5
  const fs = require('fs')
7
6
  const child_process = require('child_process')
@@ -9,11 +8,11 @@ const config = JSON.parse(fs.readFileSync(path.join(__dirname, './config/default
9
8
 
10
9
  let rayProcess = null
11
10
 
12
- process.on('exit', () => stop())
13
- process.on('SIGINT', () => stop())
14
- process.on('SIGUSR1', () => stop())
15
- process.on('SIGUSR2', () => stop())
16
- process.on('uncaughtException', err => stop() && process.exit(1))
11
+ process.on('exit', stop)
12
+ process.on('SIGINT', stop)
13
+ process.on('SIGUSR1', stop)
14
+ process.on('SIGUSR2', stop)
15
+ process.on('uncaughtException', err => { stop(); process.exit(1) })
17
16
 
18
17
  program.version('1.0.0').description('Tunnel CLI')
19
18
  program.command('* <url>').action(url => url && run(url))
@@ -21,7 +20,7 @@ program.parse(process.argv)
21
20
 
22
21
  async function run(url) {
23
22
  try {
24
- let res = await axios.get(url)
23
+ let res = await get(url)
25
24
  if (res.data) {
26
25
  subItems = Buffer.from(res.data, 'base64').toString().split("vmess://").map(o => Buffer.from(o, 'base64').toString()).filter(o => o)
27
26
  let server = subItems.map(o => JSON.parse(o)).filter(o => o.verify_cert)[0]
@@ -44,22 +43,18 @@ function start() {
44
43
  // 设置系统代理
45
44
  setSystemProxy(config.setting.localHttpPort)
46
45
  // 根据操作系统平台-启动新进程
47
- rayProcess = child_process.exec(path.join(__dirname, './core/xray-linux-x64'), (error, stdout, stderr) => error && stop(true))
46
+ rayProcess = child_process.exec(path.join(__dirname, './core/xray-linux-x64'), (error, stdout, stderr) => error && stop())
48
47
  rayProcess.stdout.on('data', console.log)
49
48
  rayProcess.stderr.on('data', console.error)
50
49
  }
51
50
 
52
- function stop(isRestart) {
51
+ function stop() {
53
52
  console.log('TUNNEL STOP')
54
53
  // 关闭上个进程
55
54
  rayProcess && rayProcess.kill('SIGINT')
56
55
  // 取消系统代理
57
56
  setSystemProxy()
58
- if (isRestart) {
59
- console.error('启动失败(请检查权限/端口占用),重新启动中...')
60
- start()
61
- }
62
- return true
57
+ process.exit(1)
63
58
  }
64
59
 
65
60
  function setSystemProxy(port) {
@@ -70,4 +65,14 @@ function setSystemProxy(port) {
70
65
  let command1 = `git config --global --unset http.sslBackend && git config --global --unset http.proxy`
71
66
  child_process.exec(command1)
72
67
  }
68
+ }
69
+
70
+ function get(url) {
71
+ return new Promise((resolve, reject) => {
72
+ https.get(url, res => {
73
+ let data = ''
74
+ res.on('data', chunk => data += chunk)
75
+ res.on('end', () => resolve({ data }))
76
+ }).on("error", error => reject(error))
77
+ })
73
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xtunnel",
3
- "version": "1.1.3",
3
+ "version": "1.3.0",
4
4
  "description": "xtunnel",
5
5
  "main": "index.js",
6
6
  "scripts": {},
@@ -10,7 +10,6 @@
10
10
  "author": "cheney",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "axios": "^0.24.0",
14
13
  "commander": "^8.3.0"
15
14
  }
16
15
  }