xfuture 1.9.1 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- package/index-for-win32-ia32.js +135 -0
- package/package/win32/xFuture.node +0 -0
- package/package/win32/xray.dll +0 -0
- package/package.json +2 -1
@@ -0,0 +1,135 @@
|
|
1
|
+
let os = require("os");
|
2
|
+
const { spawn } = require('child_process')
|
3
|
+
var isMac = false;
|
4
|
+
const parser = require('./parser');
|
5
|
+
const fs = require('fs');
|
6
|
+
parser.isGlobalMode = false;
|
7
|
+
|
8
|
+
class xFuture {
|
9
|
+
|
10
|
+
init(){
|
11
|
+
this.driver = "";
|
12
|
+
this.isTunMode = true;
|
13
|
+
}
|
14
|
+
|
15
|
+
SetEventCallback(name, func){
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
GetSingBoxDuraion(){
|
20
|
+
return 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
GetXrayDuration(){
|
24
|
+
return 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
SetPassword(password) {
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
SetTunModeEnable(enable, workingDir){
|
32
|
+
this.isTunMode = enable;
|
33
|
+
this.workingDir = workingDir;
|
34
|
+
}
|
35
|
+
|
36
|
+
StartTunnel(url){
|
37
|
+
if(this.driver.length == 0) return false;
|
38
|
+
this.currentURI = url;
|
39
|
+
var json = parser.parse(url);
|
40
|
+
var xray_json = JSON.stringify(json);
|
41
|
+
console.log("address:", json.address);
|
42
|
+
var ok = this.startTunnelPrivate(xray_json, url);
|
43
|
+
if (ok) {
|
44
|
+
ok = this.StartProxy();
|
45
|
+
}
|
46
|
+
return ok;
|
47
|
+
}
|
48
|
+
|
49
|
+
startTunnelPrivate(json, url){
|
50
|
+
|
51
|
+
try {
|
52
|
+
// 同步写入文件
|
53
|
+
var filePath = this.workingDir + "\\configuration.json";
|
54
|
+
fs.writeFileSync(filePath, json, 'utf8');
|
55
|
+
console.log('File has been written successfully!');
|
56
|
+
var driver = this.workingDir + "\\mao-dou-xray-vpn-driver.exe";
|
57
|
+
spawn(driver, ["run", this.workingDir, filePath, url]);
|
58
|
+
return true;
|
59
|
+
} catch (err) {
|
60
|
+
console.error('An error occurred while writing to the file:', err);
|
61
|
+
return false;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
stopTunnelPrivate() {
|
66
|
+
var driver = this.workingDir + "\\mao-dou-xray-vpn-driver.exe";
|
67
|
+
spawn(driver, ["kill"]);
|
68
|
+
}
|
69
|
+
|
70
|
+
StopTunnel(){
|
71
|
+
this.stopTunnelPrivate();
|
72
|
+
this.StopProxy();
|
73
|
+
}
|
74
|
+
|
75
|
+
SetVlessEncoding(version){
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
StartProxy(){
|
80
|
+
var ret = true;
|
81
|
+
try {
|
82
|
+
let process = spawn(this.driver, ["global", "socks=127.0.0.1:40008"])
|
83
|
+
process.on('close', (code) => {
|
84
|
+
console.info('[sysproxy open]:', code)
|
85
|
+
});
|
86
|
+
} catch(err) {
|
87
|
+
console.warn('[sysproxy open] failed:', err)
|
88
|
+
this.stopTunnelPrivate();
|
89
|
+
ret = false;
|
90
|
+
}
|
91
|
+
return ret;
|
92
|
+
}
|
93
|
+
|
94
|
+
// App 进程退出时调用该接口,否则会导致电脑出现断网情况
|
95
|
+
StopProxy(){
|
96
|
+
if (!isMac) {
|
97
|
+
try {
|
98
|
+
let process = spawn(this.driver, ["off"])
|
99
|
+
process.on('close', function (code) {
|
100
|
+
console.info('[sysproxy stop]:', code)
|
101
|
+
});
|
102
|
+
} catch(err) {
|
103
|
+
console.warn('[sysproxy stop] failed:', err)
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
SetGlobalMode(isGlobalMode, ipdir){
|
109
|
+
console.log("isGlobalMode:", isGlobalMode, " dir:", ipdir);
|
110
|
+
parser.workingDir = ipdir;
|
111
|
+
parser.isGlobalMode = isGlobalMode;
|
112
|
+
}
|
113
|
+
|
114
|
+
// 1. Mac 请传 install_helper.sh 和 xfuture_helper 的绝对路径
|
115
|
+
// 2. Windows 请传 "maodou" 固定字符串 和 sysproxy.exe 的绝对路径
|
116
|
+
InstallDriver(shell_path, helper_path){
|
117
|
+
this.driver = helper_path;
|
118
|
+
}
|
119
|
+
|
120
|
+
GetCurrentStatus(){
|
121
|
+
return 0;
|
122
|
+
}
|
123
|
+
|
124
|
+
GetCurrentURI(){
|
125
|
+
return this.currentURI;
|
126
|
+
}
|
127
|
+
|
128
|
+
GetStatistics(){
|
129
|
+
return {"downloadlink":0, "mdownloadlink":0, "muploadlink":0, "uploadlink":0};
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
const xFutureInstance = new xFuture;
|
134
|
+
xFutureInstance.init();
|
135
|
+
module.exports = xFutureInstance;
|
Binary file
|
package/package/win32/xray.dll
CHANGED
Binary file
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "xfuture",
|
3
|
-
"version": "1.9.
|
3
|
+
"version": "1.9.3",
|
4
4
|
"description": "electron vpn sdk",
|
5
5
|
"main": "x.js",
|
6
6
|
"scripts": {
|
@@ -21,6 +21,7 @@
|
|
21
21
|
},
|
22
22
|
"files": [
|
23
23
|
"index.js",
|
24
|
+
"index-for-win32-ia32.js",
|
24
25
|
"parser.js",
|
25
26
|
"package.json",
|
26
27
|
"package/darwin/xFuture.node",
|