xfuture 1.3.0 → 1.3.2

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.
package/config.js ADDED
@@ -0,0 +1,443 @@
1
+
2
+ class xConfiguration {
3
+
4
+ }
5
+
6
+ const xConfig = new xConfiguration;
7
+ xConfig.ai = {
8
+ "log": {
9
+ "level": "warn",
10
+ "timestamp": true
11
+ },
12
+ "dns": {
13
+ "servers": [
14
+ {
15
+ "tag": "remote",
16
+ "address": "tcp://8.8.8.8",
17
+ "detour": "proxy"
18
+ },
19
+ {
20
+ "tag": "local",
21
+ "address": "223.5.5.5",
22
+ "detour": "direct"
23
+ },
24
+ {
25
+ "tag": "block",
26
+ "address": "rcode://success"
27
+ },
28
+ {
29
+ "tag": "local_local",
30
+ "address": "223.5.5.5",
31
+ "detour": "direct"
32
+ }
33
+ ],
34
+ "rules": [
35
+ {
36
+ "server": "local",
37
+ "disable_cache": true,
38
+ "geosite": [
39
+ "cn"
40
+ ]
41
+ },
42
+ {
43
+ "server": "block",
44
+ "disable_cache": true,
45
+ "geosite": [
46
+ "category-ads-all"
47
+ ]
48
+ },
49
+ {
50
+ "outbound": "any",
51
+ "server": "local_local"
52
+ }
53
+ ],
54
+ "strategy": "ipv4_only"
55
+ },
56
+ "inbounds": [
57
+ {
58
+ "type": "tun",
59
+ "tag": "tun-in",
60
+ "interface_name": "singbox_tun",
61
+ "inet4_address": "172.19.0.1/30",
62
+ "inet6_address": "fdfe:dcba:9876::1/126",
63
+ "mtu": 9000,
64
+ "auto_route": true,
65
+ "strict_route": true,
66
+ "stack": "gvisor",
67
+ "sniff": true
68
+ }
69
+ ],
70
+ "outbounds": [
71
+ {
72
+ "type": "socks",
73
+ "tag": "proxy",
74
+ "server": "127.0.0.1",
75
+ "server_port": 1081
76
+ },
77
+ {
78
+ "type": "direct",
79
+ "tag": "direct"
80
+ },
81
+ {
82
+ "type": "block",
83
+ "tag": "block"
84
+ },
85
+ {
86
+ "type": "dns",
87
+ "tag": "dns_out"
88
+ }
89
+ ],
90
+ "route": {
91
+ "auto_detect_interface": true,
92
+ "geoip":{
93
+ "path":"D:\\linkv\\maodou\\xfuture\\resources\\geoip.db"
94
+ },
95
+ "geosite":{
96
+ "path":"D:\\linkv\\maodou\\xfuture\\resources\\geosite.db"
97
+ },
98
+ "rules": [
99
+ {
100
+ "outbound": "dns_out",
101
+ "inbound": [
102
+ "dns_in"
103
+ ]
104
+ },
105
+ {
106
+ "outbound": "dns_out",
107
+ "protocol": [
108
+ "dns"
109
+ ]
110
+ },
111
+ {
112
+ "outbound": "block",
113
+ "network": "udp",
114
+ "port": [
115
+ 135,
116
+ 137,
117
+ 138,
118
+ 139,
119
+ 5353
120
+ ]
121
+ },
122
+ {
123
+ "outbound": "block",
124
+ "ip_cidr": [
125
+ "224.0.0.0/3",
126
+ "ff00::/8"
127
+ ]
128
+ },
129
+ {
130
+ "outbound": "block",
131
+ "source_ip_cidr": [
132
+ "224.0.0.0/3",
133
+ "ff00::/8"
134
+ ]
135
+ },
136
+ {
137
+ "outbound": "dns_out",
138
+ "port": [
139
+ 53
140
+ ],
141
+ "process_name": [
142
+ "wv2ray.exe",
143
+ "v2ray.exe",
144
+ "SagerNet.exe",
145
+ "v2ray.exe",
146
+ "v2ray.exe",
147
+ "xray.exe",
148
+ "wxray.exe",
149
+ "clash-windows-amd64-v3.exe",
150
+ "clash-windows-amd64.exe",
151
+ "clash-windows-386.exe",
152
+ "clash.exe",
153
+ "Clash.Meta-windows-amd64-compatible.exe",
154
+ "Clash.Meta-windows-amd64.exe",
155
+ "Clash.Meta-windows-386.exe",
156
+ "Clash.Meta.exe",
157
+ "clash.exe",
158
+ "hysteria-windows-amd64.exe",
159
+ "hysteria-windows-386.exe",
160
+ "hysteria.exe",
161
+ "naiveproxy.exe",
162
+ "naive.exe",
163
+ "tuic-client.exe",
164
+ "tuic.exe",
165
+ "juicity-client.exe",
166
+ "juicity.exe",
167
+ "electron.exe"
168
+ ]
169
+ },
170
+ {
171
+ "outbound": "direct",
172
+ "process_name": [
173
+ "wv2ray.exe",
174
+ "v2ray.exe",
175
+ "SagerNet.exe",
176
+ "v2ray.exe",
177
+ "v2ray.exe",
178
+ "xray.exe",
179
+ "wxray.exe",
180
+ "clash-windows-amd64-v3.exe",
181
+ "clash-windows-amd64.exe",
182
+ "clash-windows-386.exe",
183
+ "clash.exe",
184
+ "Clash.Meta-windows-amd64-compatible.exe",
185
+ "Clash.Meta-windows-amd64.exe",
186
+ "Clash.Meta-windows-386.exe",
187
+ "Clash.Meta.exe",
188
+ "clash.exe",
189
+ "hysteria-windows-amd64.exe",
190
+ "hysteria-windows-386.exe",
191
+ "hysteria.exe",
192
+ "naiveproxy.exe",
193
+ "naive.exe",
194
+ "tuic-client.exe",
195
+ "tuic.exe",
196
+ "sing-box-client.exe",
197
+ "sing-box.exe",
198
+ "juicity-client.exe",
199
+ "juicity.exe",
200
+ "electron.exe"
201
+ ]
202
+ },
203
+ {
204
+ "outbound": "direct",
205
+ "domain": [
206
+ "example-example.com",
207
+ "example-example2.com"
208
+ ],
209
+ "domain_suffix": [
210
+ ".example-example.com",
211
+ ".example-example2.com"
212
+ ]
213
+ },
214
+ {
215
+ "outbound": "block",
216
+ "geosite": [
217
+ "category-ads-all"
218
+ ]
219
+ },
220
+ {
221
+ "outbound": "direct",
222
+ "geosite": [
223
+ "cn"
224
+ ]
225
+ },
226
+ {
227
+ "outbound": "direct",
228
+ "geoip": [
229
+ "private",
230
+ "cn"
231
+ ]
232
+ }
233
+ ]
234
+ }
235
+ }
236
+
237
+ xConfig.global = {
238
+ "log": {
239
+ "level": "warn",
240
+ "timestamp": true
241
+ },
242
+ "dns": {
243
+ "servers": [
244
+ {
245
+ "tag": "remote",
246
+ "address": "tcp://8.8.8.8",
247
+ "detour": "proxy"
248
+ },
249
+ {
250
+ "tag": "local",
251
+ "address": "223.5.5.5",
252
+ "detour": "direct"
253
+ },
254
+ {
255
+ "tag": "block",
256
+ "address": "rcode://success"
257
+ },
258
+ {
259
+ "tag": "local_local",
260
+ "address": "223.5.5.5",
261
+ "detour": "direct"
262
+ }
263
+ ],
264
+ "rules": [
265
+ {
266
+ "server": "local",
267
+ "disable_cache": true,
268
+ "geosite": [
269
+ "cn"
270
+ ]
271
+ },
272
+ {
273
+ "server": "block",
274
+ "disable_cache": true,
275
+ "geosite": [
276
+ "category-ads-all"
277
+ ]
278
+ },
279
+ {
280
+ "outbound": "any",
281
+ "server": "local_local"
282
+ }
283
+ ],
284
+ "strategy": "ipv4_only"
285
+ },
286
+ "inbounds": [
287
+ {
288
+ "type": "tun",
289
+ "tag": "tun-in",
290
+ "interface_name": "singbox_tun",
291
+ "inet4_address": "172.19.0.1/30",
292
+ "inet6_address": "fdfe:dcba:9876::1/126",
293
+ "mtu": 9000,
294
+ "auto_route": true,
295
+ "strict_route": true,
296
+ "stack": "gvisor",
297
+ "sniff": true
298
+ }
299
+ ],
300
+ "outbounds": [
301
+ {
302
+ "type": "socks",
303
+ "tag": "proxy",
304
+ "server": "127.0.0.1",
305
+ "server_port": 1081
306
+ },
307
+ {
308
+ "type": "direct",
309
+ "tag": "direct"
310
+ },
311
+ {
312
+ "type": "block",
313
+ "tag": "block"
314
+ },
315
+ {
316
+ "type": "dns",
317
+ "tag": "dns_out"
318
+ }
319
+ ],
320
+ "route": {
321
+ "geoip":{
322
+ "path":"D:\\linkv\\maodou\\xfuture\\resources\\geoip.db"
323
+ },
324
+ "geosite":{
325
+ "path":"D:\\linkv\\maodou\\xfuture\\resources\\geosite.db"
326
+ },
327
+ "auto_detect_interface": true,
328
+ "rules": [
329
+ {
330
+ "outbound": "dns_out",
331
+ "inbound": [
332
+ "dns_in"
333
+ ]
334
+ },
335
+ {
336
+ "outbound": "dns_out",
337
+ "protocol": [
338
+ "dns"
339
+ ]
340
+ },
341
+ {
342
+ "outbound": "block",
343
+ "network": "udp",
344
+ "port": [
345
+ 135,
346
+ 137,
347
+ 138,
348
+ 139,
349
+ 5353
350
+ ]
351
+ },
352
+ {
353
+ "outbound": "block",
354
+ "ip_cidr": [
355
+ "224.0.0.0/3",
356
+ "ff00::/8"
357
+ ]
358
+ },
359
+ {
360
+ "outbound": "block",
361
+ "source_ip_cidr": [
362
+ "224.0.0.0/3",
363
+ "ff00::/8"
364
+ ]
365
+ },
366
+ {
367
+ "outbound": "dns_out",
368
+ "port": [
369
+ 53
370
+ ],
371
+ "process_name": [
372
+ "wv2ray.exe",
373
+ "v2ray.exe",
374
+ "SagerNet.exe",
375
+ "v2ray.exe",
376
+ "v2ray.exe",
377
+ "xray.exe",
378
+ "wxray.exe",
379
+ "clash-windows-amd64-v3.exe",
380
+ "clash-windows-amd64.exe",
381
+ "clash-windows-386.exe",
382
+ "clash.exe",
383
+ "Clash.Meta-windows-amd64-compatible.exe",
384
+ "Clash.Meta-windows-amd64.exe",
385
+ "Clash.Meta-windows-386.exe",
386
+ "Clash.Meta.exe",
387
+ "clash.exe",
388
+ "hysteria-windows-amd64.exe",
389
+ "hysteria-windows-386.exe",
390
+ "hysteria.exe",
391
+ "naiveproxy.exe",
392
+ "naive.exe",
393
+ "tuic-client.exe",
394
+ "tuic.exe",
395
+ "juicity-client.exe",
396
+ "juicity.exe",
397
+ "electron.exe"
398
+ ]
399
+ },
400
+ {
401
+ "outbound": "direct",
402
+ "process_name": [
403
+ "wv2ray.exe",
404
+ "v2ray.exe",
405
+ "SagerNet.exe",
406
+ "v2ray.exe",
407
+ "v2ray.exe",
408
+ "xray.exe",
409
+ "wxray.exe",
410
+ "clash-windows-amd64-v3.exe",
411
+ "clash-windows-amd64.exe",
412
+ "clash-windows-386.exe",
413
+ "clash.exe",
414
+ "Clash.Meta-windows-amd64-compatible.exe",
415
+ "Clash.Meta-windows-amd64.exe",
416
+ "Clash.Meta-windows-386.exe",
417
+ "Clash.Meta.exe",
418
+ "clash.exe",
419
+ "hysteria-windows-amd64.exe",
420
+ "hysteria-windows-386.exe",
421
+ "hysteria.exe",
422
+ "naiveproxy.exe",
423
+ "naive.exe",
424
+ "tuic-client.exe",
425
+ "tuic.exe",
426
+ "sing-box-client.exe",
427
+ "sing-box.exe",
428
+ "juicity-client.exe",
429
+ "juicity.exe",
430
+ "electron.exe"
431
+ ]
432
+ },
433
+ {
434
+ "outbound": "proxy",
435
+ "port_range": [
436
+ "0:65535"
437
+ ]
438
+ }
439
+ ]
440
+ }
441
+ }
442
+
443
+ module.exports = xConfig;
package/index.js CHANGED
@@ -18,44 +18,39 @@ parser.isGlobalMode = false;
18
18
  class xFuture {
19
19
 
20
20
  init(){
21
- if (this.driver == null || this.driver == undefined) {
22
- this.driver = "";
23
- }
24
- if (this.tunModeEnable == null || this.tunModeEnable == undefined) {
25
- this.tunModeEnable = false;
26
- }
21
+ this.driver = "";
22
+ this.isTunMode = true;
27
23
  }
28
24
 
29
25
  SetPassword(password) {
30
26
  ff.SetPassword(password);
31
27
  }
32
28
 
33
- SetTunModeEnable(enable, exe_file, config_file){
34
- this.tunModeEnable = enable;
35
- if (!isMac) {
36
- ff.SetTunModeEnable(enable, exe_file, config_file);
37
- }
29
+ SetTunModeEnable(enable, running_file, config_file){
30
+ this.isTunMode = enable;
31
+ parser.isTunMode = enable;
32
+ ff.SetTunModeEnable(enable, running_file, config_file);
38
33
  }
39
34
 
40
35
  StartTunnel(url){
41
- this.init();
42
36
  if(this.driver.length == 0) return false;
43
- var json = JSON.stringify(parser.parse(url));
44
- console.log("json:", json);
45
- var ret = ff.StartTunnel(json, url);
46
- if (ret) {
47
- ret = this.StartProxy();
37
+ var xray_json = JSON.stringify(parser.parse(url));
38
+ var sing_json = JSON.stringify(parser.getSingBox());
39
+ console.log("json:", xray_json, " sing_json:", sing_json);
40
+ var ok = ff.StartTunnel(xray_json, url, sing_json);
41
+ if (ok) {
42
+ ok = this.StartProxy();
48
43
  }
49
- return ret;
44
+ return ok;
50
45
  }
51
46
 
52
47
  StopTunnel(){
53
48
  ff.StopTunnel();
54
- // this.StopProxy();
49
+ this.StopProxy();
55
50
  }
56
51
 
57
52
  StartProxy(){
58
- if (isMac || this.tunModeEnable) return true;
53
+ if (isMac || this.isTunMode) return true;
59
54
  var ret = true;
60
55
  try {
61
56
  let process = spawn(this.driver, ["global", "socks=127.0.0.1:1081"])
@@ -74,7 +69,7 @@ class xFuture {
74
69
 
75
70
  // App 进程退出时调用该接口,否则会导致电脑出现断网情况
76
71
  StopProxy(){
77
- if (!isMac && !this.tunModeEnable) {
72
+ if (!isMac && !this.isTunMode) {
78
73
  try {
79
74
  let process = spawn(this.driver, ["off"])
80
75
  process.on('close', function (code) {
@@ -88,22 +83,28 @@ class xFuture {
88
83
  }
89
84
 
90
85
  ChangeURL(url){
91
- var json = JSON.stringify(parser.parse(url));
92
- return ff.ChangeURL(json, url, false);
86
+
87
+ var xray_json = JSON.stringify(parser.parse(url));
88
+ var sing_json = JSON.stringify(parser.getSingBox());
89
+ console.log("ChangeURL: ", xray_json, " sing-box:", sing_json);
90
+ return ff.ChangeURL(xray_json, url, false, sing_json);
93
91
  }
94
92
 
95
93
  SetGlobalMode(isGlobalMode, ipdir){
96
94
  console.log("isGlobalMode:", isGlobalMode, " dir:", ipdir);
95
+ parser.workingDir = ipdir
97
96
  ff.SetGlobalMode(isGlobalMode, ipdir);
98
- parser.isGlobalMode = isGlobalMode;
99
97
  if (isGlobalMode == parser.isGlobalMode) {
100
98
  return;
101
99
  }
100
+ parser.isGlobalMode = isGlobalMode;
102
101
  let K_Connected = 2;
103
102
  if (this.GetCurrentStatus() == K_Connected) {
104
103
  var url = this.GetCurrentURI();
105
- var json = JSON.stringify(parser.parse(url));
106
- this.ChangeURL(json, url, true);
104
+ var xray_json = JSON.stringify(parser.parse(url));
105
+ var sing_json = JSON.stringify(parser.getSingBox());
106
+ ff.ChangeURL(xray_json, url, true, sing_json);
107
+ console.log("Change URL:", url, " force:", true, " xray_json:", xray_json, " sing-box:", sing_json);
107
108
  }
108
109
  }
109
110
 
@@ -142,4 +143,5 @@ class xFuture {
142
143
  }
143
144
 
144
145
  const xFutureInstance = new xFuture;
146
+ xFutureInstance.init();
145
147
  module.exports = xFutureInstance;
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xfuture",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "electron vpn sdk",
5
5
  "main": "x.js",
6
6
  "scripts": {
@@ -25,15 +25,19 @@
25
25
  "package/mac/install_helper.sh",
26
26
  "index.js",
27
27
  "parser.js",
28
+ "config.js",
28
29
  "package.json",
29
30
  "package/mac/xFuture.framework",
30
31
  "package/windows/sysproxy.exe",
31
32
  "package/windows/xFuture.node",
32
33
  "package/windows/xray.dll",
33
34
  "package/windows/xray.exe",
35
+ "package/windows/sing-box.dll",
34
36
  "package/windows/config.json",
35
37
  "resources/geoip.dat",
36
- "resources/geosite.dat"
38
+ "resources/geosite.dat",
39
+ "resources/geoip.db",
40
+ "resources/geosite.db"
37
41
  ],
38
42
  "build": {
39
43
  "mac": {
package/parser.js CHANGED
@@ -1,11 +1,9 @@
1
1
 
2
+ const config = require('./config');
2
3
 
3
4
  class xParser {
4
5
 
5
6
  parse(uri){
6
- if (this.isGlobalMode == null || this.isGlobalMode == undefined) {
7
- this.isGlobalMode = false;
8
- }
9
7
  if (uri.startsWith("vmess://")) {
10
8
  return this.parseVMess(uri);
11
9
  }
@@ -51,11 +49,8 @@ class xParser {
51
49
  return {};
52
50
  }
53
51
  var address = ipPorts[0];
54
- var port = Integer.parseInt(ipPorts[1]);
52
+ var port = ipPorts[1] * 1
55
53
 
56
- var security = "";
57
- var method = accountPasswords[0];
58
- var password = accountPasswords[1];
59
54
  var routing = {};
60
55
  var rules = [];
61
56
  if (!this.isGlobalMode) {
@@ -90,8 +85,6 @@ class xParser {
90
85
  info = raw.split("@");
91
86
  }
92
87
  if (info.length < 2) return {};
93
-
94
- var uuid = info[0];
95
88
  var config = info[1].split("?");
96
89
  if (config.length < 2) return {};
97
90
 
@@ -104,10 +97,6 @@ class xParser {
104
97
  if (suffix.length < 2) return {};
105
98
 
106
99
  var remark = suffix[1];
107
-
108
- var tag = "proxy";
109
- var parameters = suffix[0].split("&");
110
-
111
100
  var routing = {};
112
101
  var rules = [];
113
102
  if (!this.isGlobalMode) {
@@ -133,7 +122,6 @@ class xParser {
133
122
  return {};
134
123
  }
135
124
 
136
- var uuid = info[0];
137
125
  var config = info[1].split("?");
138
126
  if (config.length < 2) {
139
127
  return {};
@@ -144,7 +132,7 @@ class xParser {
144
132
  return {};
145
133
  }
146
134
  var address = ipAddress[0];
147
- var port = Integer.parseInt(ipAddress[1]);
135
+ var port = ipAddress[1] * 1
148
136
 
149
137
  var suffix = config[1].split("#");
150
138
  if (suffix.length < 2) {
@@ -202,7 +190,7 @@ class xParser {
202
190
 
203
191
  getRules() {
204
192
  var rules = [];
205
- if (!this.isGlobalMode) {
193
+ if (!this.isGlobalMode && !this.isTunMode) {
206
194
  rules = [
207
195
  {
208
196
  "type":"field",
@@ -226,18 +214,10 @@ class xParser {
226
214
 
227
215
  getBase(){
228
216
  var base = {
229
- "remark": "MaoDou",
217
+ "remark": "Mao Dou",
230
218
  "log": {
231
219
  "loglevel": "info"
232
220
  },
233
- "tun": {
234
- "inet4_address": "172.19.0.1/30",
235
- "stack": "system",
236
- "mtu": 9000,
237
- "auto_route": true,
238
- "auto_detect_interface": true,
239
- "override_android_vpn": false
240
- },
241
221
  "inbounds": [
242
222
  {
243
223
  "settings": {
@@ -250,17 +230,17 @@ class xParser {
250
230
  },
251
231
  {
252
232
  "settings": {
253
- "udp": true,
254
- "auth": "noauth"
233
+ "udp": true,
234
+ "auth": "noauth"
255
235
  },
256
236
  "protocol": "socks",
257
237
  "port": 1081,
258
238
  "sniffing": {
259
- "enabled": true,
260
- "destOverride": [
261
- "http",
262
- "tls"
263
- ]
239
+ "enabled": true,
240
+ "destOverride": [
241
+ "http",
242
+ "tls"
243
+ ]
264
244
  },
265
245
  "tag": "socks",
266
246
  "listen": "127.0.0.1"
@@ -277,7 +257,7 @@ class xParser {
277
257
  },
278
258
  {
279
259
  "settings": {
280
- "response": {
260
+ "response": {
281
261
  "type": "http"
282
262
  }
283
263
  },
@@ -290,12 +270,29 @@ class xParser {
290
270
  "domain:googleapis.cn": "googleapis.com",
291
271
  "dns.google": "8.8.8.8",
292
272
  },
293
- "servers":["8.8.8.8", "8.8.4.4", "1.1.1.1", "1.0.0.1"]
273
+ "servers":["8.8.8.8", "8.8.4.4"]
294
274
  }
295
275
  }
296
276
  return base;
297
277
  }
278
+ getSingBox(){
279
+ if (!this.isGlobalMode) {
280
+ var json = config.ai;
281
+ json.route.geoip.path = this.workingDir + "\\geoip.db";
282
+ json.route.geosite.path = this.workingDir + "\\geosite.db";
283
+ return json;
284
+ }
285
+ else{
286
+ var json = config.global
287
+ json.route.geoip.path = this.workingDir + "\\geoip.db";
288
+ json.route.geosite.path = this.workingDir + "\\geosite.db";
289
+ return json;
290
+ }
291
+ }
298
292
  }
299
293
 
300
294
  const xParserInstance = new xParser;
295
+ xParserInstance.isGlobalMode = false;
296
+ xParserInstance.isTunMode = true;
297
+ xParserInstance.workingDir = "";
301
298
  module.exports = xParserInstance;
Binary file
Binary file
package/x.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /** main.js */
2
2
  const { app, BrowserWindow, crashReporter, ipcMain} = require("electron");
3
- var engine = require("./index");
4
3
 
5
4
  // app.commandLine.appendArgument("--enable-features=Metal");
6
5
  crashReporter.start({ submitURL: 'http://82.157.38.31:1127/crashreports' })
@@ -9,11 +8,6 @@ crashReporter.start({ submitURL: 'http://82.157.38.31:1127/crashreports' })
9
8
  let path = app.getPath('crashDumps');
10
9
  console.log(path);
11
10
 
12
- app.on('before-quit', () => {
13
- engine.InstallDriver("/Users/yangyudong/Documents/dream/xfuture/package/mac/install_helper.sh", "D:\\linkv\\xfuture\\package\\windows\\sysproxy.exe");
14
- engine.StopProxy();
15
- })
16
-
17
11
  app.on("ready", () => {
18
12
  mainWindow = new BrowserWindow({
19
13
  width: 800,