forked from zzabao1985/winXray-v3.6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.aardio
352 lines (310 loc) · 10.8 KB
/
main.aardio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/*启动参数检测{{*/
if(_ARGV.github){
loadcodex("\forms\main\tools\github.aardio");
return;
}
elseif(_ARGV.sshInstall){
import fsys.wow64;
import process;
import console;
console.open();
var prcs;
fsys.wow64.disableRedirection(
function(){
var dest,port = string.match(_ARGV.sshInstall,"(.+)\:(\d+)");
if(dest&&port){
_ARGV.sshInstall = "-p" + port +" " + dest;
}
prcs = process("ssh","-t " +_ARGV.sshInstall + ` "echo -e '安装完成以后,您可以一次性复制所有服务器账号配置 - 然后在 winXray 主界面点击\e[1;31m「批量导入链接」\e[0m即可,winXray将逐行识别有效的服务器分享链接或通用JSON配置,并忽略无效的行。如果 CentOS 8安装失败 - 可尝试更换为 CentOS 7 并重新安装。\n';firewall-cmd --permanent --add-port=80/tcp;firewall-cmd --permanent --add-port=443/tcp;firewall-cmd --reload;iptables -A INPUT -p tcp --dport 80 -j ACCEPT;iptables -A INPUT -p tcp --dport 443 -j ACCEPT;wget -P /root -N --no-check-certificate ""https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh"" && chmod 700 /root/install.sh && /root/install.sh"`)
if(!prcs){
if(_WIN10_LATER){
import process.control;
process.control("ms-settings:optionalfeatures");
console.log("请检查是否指定了正确的SSH端口,或尝试重新安装 OpenSSH.Client");
}
else {
console.log("此功能仅支持 Windows 10 系统");
}
}
else {
import process.job.limitKill;
prcs.assignToJobObject(process.job.limitKill);
prcs.wait();
}
console.pause();
}
)
return;
}
elseif(_ARGV.sshLogin){
import fsys.wow64;
import process;
import console;
console.open();
var prcs;
fsys.wow64.disableRedirection(
function(){
var dest,port = string.match(_ARGV.sshLogin,"(.+)\:(\d+)");
if(dest&&port){
_ARGV.sshLogin = "-p" + port +" " + dest;
}
prcs = process("ssh","-t " +_ARGV.sshLogin + ``)
if(!prcs){
if(_WIN10_LATER){
import process.control;
process.control("ms-settings:optionalfeatures");
console.log("请检查是否指定了正确的SSH端口,或尝试重新安装 OpenSSH.Client");
}
else {
console.log("此功能仅支持 Windows 10 系统");
}
}
else {
import process.job.limitKill;
prcs.assignToJobObject(process.job.limitKill);
prcs.wait();
}
console.pause();
}
)
return;
}
elseif(_ARGV.sshInstallKey){
import fsys.wow64;
import process;
import console;
console.open();
var prcs;
fsys.wow64.disableRedirection(
function(){
var sshKeyPath = io.getSpecial(0x28/*_CSIDL_PROFILE*/,"/.ssh/id_rsa.pub") ;
var keyData = string.load(sshKeyPath);
if(!keyData){
var prcs = process.popen("ssh-keygen",` -t rsa -f "`+io.getSpecial(0x28/*_CSIDL_PROFILE*/,"/.ssh/id_rsa")+`" -y`);
keyData = prcs? prcs.read(-1);
}
if(!keyData){
if(_WIN10_LATER){
import process.control;
process.control("ms-settings:optionalfeatures");
console.log("请检查是否指定了正确的SSH端口,或尝试重新安装 OpenSSH.Client");
}
else {
console.log("此功能仅支持 Windows 10 系统");
}
}
else{
var dest,port = string.match(_ARGV.sshInstallKey,"(.+)\:(\d+)");
if(dest&&port){
_ARGV.sshInstallKey = "-p" + port +" " + dest;
}
prcs = process("ssh","-t " +_ARGV.sshInstallKey + ` "mkdir -p ~/.ssh;chmod 700 ~/.ssh;chmod 600 ~/.ssh/authorized_keys;echo '`+keyData+`' > ~/.ssh/authorized_keys"`)
if(!prcs){
if(_WIN10_LATER){
import process.control;
process.control("ms-settings:optionalfeatures");
console.log("请检查是否指定了正确的SSH端口,或尝试重新安装 OpenSSH.Client");
}
else {
console.log("此功能仅支持 Windows 10 系统");
}
}
else {
import process.job.limitKill;
prcs.assignToJobObject(process.job.limitKill);
prcs.wait();
}
}
console.pause();
}
)
return;
}
elseif(_ARGV.updateTime){
import time.ntp;
time.ntp.updateSystemTime();
return;
}
else {
import process;
import fsys.update.simpleMain;
if( fsys.update.simpleMain(
"winXray(V2Ray/V2Ray、Shadowsocks、Trojan通用客户端 )",
"https://raw.githubusercontent.com/winXray/winXray/master/release/update/version.txt",
..io.appData("/winXray/update"),
function(version,description,status){}
,,false)){
return 0;
}
}
/*}}*/
import fonts.fontAwesome;
import win.ui;
/*DSG{{*/
mainForm = win.form(text="winXray";right=1019;bottom=679;bgcolor=15793151;border="none")
mainForm.add(
caption={cls="bkplus";text="winXray 3.6";left=67;top=9;right=727;bottom=27;align="left";color=6052956;dl=1;dt=1;font=LOGFONT(h=-14);z=7};
custom={cls="custom";left=83;top=40;right=1022;bottom=679;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;z=4};
logo={cls="bkplus";text='\uF1D9';left=35;top=7;right=64;bottom=32;color=3054125;dl=1;dt=1;font=LOGFONT(h=-18;name='FontAwesome');z=6};
navBar={cls="bkplus";left=0;top=37;right=83;bottom=681;bgcolor=3442175;db=1;dl=1;dt=1;z=1};
navJsonConfig={cls="plus";text="配置";left=0;top=132;right=85;bottom=212;bkBottom=3;bkLeft=7;bkRight=8;bkTop=2;border={color=-65536};color=16777215;dl=1;dt=1;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-37;name='FontAwesome');padding={bottom=20}};iconText='\uF0F6';notify=1;textPadding={bottom=10};valign="bottom";x=0.5;y=0.2;z=5};
navStart={cls="plus";text="首页";left=0;top=48;right=85;bottom=128;bkBottom=3;bkLeft=7;bkRight=8;bkTop=2;border={color=-65536};color=16777215;dl=1;dt=1;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-37;name='FontAwesome');padding={bottom=20}};iconText='\uF015';notify=1;textPadding={bottom=10};valign="bottom";x=0.5;y=0.2;z=3};
navTools={cls="plus";text="工具";left=0;top=216;right=85;bottom=296;bkBottom=3;bkLeft=7;bkRight=8;bkTop=2;border={color=-65536};color=16777215;dl=1;dt=1;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-37;name='FontAwesome');padding={bottom=20}};iconText='\uF0AD';notify=1;textPadding={bottom=10};valign="bottom";x=0.5;y=0.2;z=8};
titleBar={cls="bkplus";left=0;top=0;right=1022;bottom=38;bgcolor=8036607;dl=1;dr=1;dt=1;forecolor=16777215;linearGradient=180;z=2}
)
/*}}*/
import win.ui.atom;
var atom,hwnd = mainForm.atom("DFA5667E-1D8C-49C0-8918-C6FEC2DECCF8");
if(!atom){
win.showForeground(hwnd);
win.quitMessage();
return;
}
import win.ui.simpleWindow;
win.ui.simpleWindow( mainForm );
import win.dlg.message;
win.dlg.message.install();
import win.ui.tabs;
var tbs = win.ui.tabs(
mainForm.navStart,
mainForm.navJsonConfig,
mainForm.navTools
);
tbs.skin({
background={
active=0xFFFFFFFF;
default=0x00FFFFFF;
hover=0x38FFFFFF
};
color={
default=0xFFFFFFFF;
};
checked={
background={default=0xFFFFFFFF;};
color={default=0xff86a543;};
}
})
tbs.loadForm(1,"\forms\main\v2ray.aardio" );
tbs.loadForm(2,"\forms\main\config\jsonConfig.aardio" );
tbs.loadForm(3,"\forms\main\tools\tools.aardio");
tbs.selIndex = 1;
import v2ray.core;
import win.ui.menu;
mainForm.wndproc = {
[0xACCF/*_WM_TRAYMESSAGE*/ ] = function(hwnd,message,wParam,lParam){
if( lParam = 0x205/*_WM_RBUTTONUP*/ ){
win.setForeground(mainForm.hwnd)
mainForm.popmenu = win.ui.popmenu(mainForm);
mainForm.popmenu.add('自动切换到最快的服务器',function(id){
publish("uiCommand.restartV2RayCore",)
});
mainForm.popmenu.add('立即更新所有订阅源',function(id){
v2ray.outbounds.updateSubscription();
});
mainForm.popmenu.add();
import v2ray.core;
var id = mainForm.popmenu.add('不使用代理',function(id){
sysProxy.switch("direct");
});
mainForm.popmenu.check(id,config.proxy.mode=="direct",0/*_MF_BYCOMMAND*/);
var id = mainForm.popmenu.add('使用全局代理',function(id){
sysProxy.switch("proxy");
});
mainForm.popmenu.check(id,config.proxy.mode=="proxy",0/*_MF_BYCOMMAND*/);
var id = mainForm.popmenu.add('使用 PAC 自动代理',function(id){
sysProxy.switch("pac");
});
mainForm.popmenu.check(id,config.proxy.mode=="pac",0/*_MF_BYCOMMAND*/);
mainForm.popmenu.add();
var id = mainForm.popmenu.add('编辑 PAC 配置',function(id){
publish("uiCommand.showPacForm");
});
mainForm.popmenu.add();
if(_WIN10_LATER){
mainForm.popmenu.add('打开系统代理设置',function(id){
import process.control;
process.control("ms-settings:network-proxy")
});
mainForm.popmenu.add('打开 Internet 代理选项',function(id){
import process.control;
process.control("inetcpl.cpl",,4);
});
}
else {
mainForm.popmenu.add('打开系统代理设置',function(id){
import process.control;
process.control("inetcpl.cpl",,4);
});
}
mainForm.popmenu.add('打开网卡连接',function(id){
import process;
process.explore("shell:::{7007ACC7-3202-11D1-AAD2-00805FC1270E}");
});
mainForm.popmenu.add();
mainForm.popmenu.add('获取 winXray 最新源代码',function(id){
import process;
process.openUrl("https://github.com/search?q=winXray+license%3AUnlicense+fork%3Atrue+sort%3Aupdated")
});
import chrome.path;
var chromePath = chrome.path();
if(chromePath && v2ray.core.socksProxyPort){
mainForm.popmenu.add('使用 SOCKS5 代理打开浏览器',function(id){
import process
process.execute(chromePath,` --proxy-server="SOCKS5://127.0.0.1:`+v2ray.core.socksProxyPort
+`" --user-data-dir="` +io.appData("winXray/chrome-socks5")+ `" https://www.google.com`);
});
}
mainForm.popmenu.add();
mainForm.popmenu.add('退出',function(id){
mainForm.onClose = null;
mainForm.close()
});
var pt = ::POINT();
::User32.GetCursorPos(pt);
mainForm.popmenu.popup(pt.x,pt.y,true)
}
elseif( lParam = 0x203/*_WM_LBUTTONDBLCLK*/) {
if(win.isIconic(mainForm.hwnd)){
mainForm.show(9/*_SW_RESTORE*/);
}
else {
mainForm.show();
}
win.setForeground(mainForm.hwnd);
}
}
}
mainForm.onDestroy = function(){
mainForm.tray.delete();
}
import win.util.tray;
mainForm.onClose = function(hwnd,message,wParam,lParam){
if(!mainForm.tray){
mainForm.tray = win.util.tray(mainForm);
}
else {
mainForm.tray.reset();
}
mainForm.show(false);
return true;
}
mainForm.tray = win.util.tray(mainForm)
if(!_ARGV.tray){
mainForm.show();
}
subscribe("uiCommand.HotkeyChanged",function(...){
if(#config.proxy.hotkey){
if(mainForm.hkProxyId){
mainForm.unreghotkey(mainForm.hkProxyId)
mainForm.hkProxyId = null;
}
mainForm.hkProxyId = mainForm.reghotkey( function(id,mod,vk){
import sysProxy;
var mode = sysProxy.switchHotkey();
var dlg = win.dlg.message(win.getForeground())
dlg.ok(mode=="pac"?"已切换到 PAC 代理模式":"已切换到全局代理模式",1200);
},config.proxy.hotkey[1],config.proxy.hotkey[2])
}
} )
publish("uiCommand.HotkeyChanged");
return win.loopMessage();