-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.aardio
255 lines (221 loc) · 8.04 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
import win.ui;
import win.ui.menu;
/*DSG{{*/
mainForm = win.form(text="Unofficial_Z_Access";right=757;bottom=467)
mainForm.add(
BTgo={cls="button";text="GO";left=684;top=2;right=757;bottom=23;dr=1;dt=1;z=3};
EDurl={cls="edit";text="https://www.google.com/ncr";left=1;top=0;right=681;bottom=24;aw=1;dl=1;dr=1;dt=1;edge=1;z=2};
mainWeb={cls="custom";text="自定义控件";left=0;top=28;right=753;bottom=467;db=1;dl=1;dr=1;dt=1;z=1}
)
/*}}*/
var HostResolverLine="";
var QUICLine="";
var HostLine="";
var CMDLine="";
//var CMDLine='--proxy-server=127.0.0.1:2500';
import wsock.tcp.simpleHttpServer;
var webbase=wsock.tcp.simpleHttpServer.startUrl()
//var url="https://zh.z-library.se/";
var url="/web/index.html";
if(_ARGV["c"])
{
import fsys.file;
var cfg;
if(_ARGV["c"]!="")
cfg=fsys.file(_ARGV["c"]);
else
cfg=fsys.file("CMDconfig.txt");
if(!fsys.file.is(cfg))
{
win.msgboxErr("No Config File! ","ERROR!");
return;
}
CMDLine=cfg.read();
cfg.close();
}
if(true)
{
HostResolverLine="";
QUICLine="";
import fsys.file;
var cfg;
if(_ARGV["d"]!=""&&_ARGV["d"]!=null)
cfg=fsys.file(_ARGV["d"]);
else
cfg=fsys.file("DOMAINconfig.txt");
if(!fsys.file.is(cfg))
{
win.msgboxErr("No Config File! ","ERROR!");
return;
}
while(1)
{
var IP=cfg.read();
var d=IP;
while(1)
{
d=cfg.read();
if(d=="") break 1;
else if(!d) break 2;
if(string.unpack(d,1,1)==string.unpack("^"))
{
d=string.slice(d,2,-1,true);
HostLine=HostLine+"MAP "+d+" "+IP+",";
}
else if(string.unpack(d,1,1)==string.unpack("-"))
{
d=string.slice(d,2,-1,true);
HostResolverLine=HostResolverLine+"MAP "+d+" "+IP+":443,";
}
else
{
HostResolverLine=HostResolverLine+"MAP "+d+" "+IP+":443,";
QUICLine=QUICLine+d+":443,";
}
}
}
cfg.close();
if(HostResolverLine!="") HostResolverLine=string.slice(HostResolverLine,1,-2,true);
if(QUICLine!="") QUICLine=string.slice(QUICLine,1,-2,true);
if(HostLine!="") HostLine=string.slice(HostLine,1,-2,true);
CMDLine="";
if(HostResolverLine!="") CMDLine=CMDLine+'--host-resolver-rules="'+HostResolverLine+'" ';
if(QUICLine!="") CMDLine=CMDLine+'-origin-to-force-quic-on='+QUICLine+' ';
if(HostLine!="") CMDLine=CMDLine+'--host-rules="'+HostLine+'" --ignore-certificate-errors ';
if(CMDLine!="") CMDLine=string.slice(CMDLine,1,-2,true);
}
if(_ARGV["p"]||_STUDIO_INVOKED)
{
import fsys.file;
import web.json;
var fcfg=fsys.file("config.json")
if(!fsys.file.is(fcfg))
{
win.msgboxErr("No Config File! ","ERROR!");
return;
}
var cfg=fcfg.read(-1)
//win.msgbox(cfg)
fcfg.close()
cfg=web.json.parse(cfg)
//win.msgbox(cfg)
var pacpath="http://127.0.0.1:"+cfg["listen_PORT"]+"/proxy.pac"
CMDLine=CMDLine+" --proxy-pac-url="+pacpath;
import process.python;
import process.python.pip;
//process.python.pip.require("requests==2.32.3")
//process.python.pip.require("ahocorasick-python==0.0.9")
//process.python.pip.require("dnspython==2.3.0")
process.python.execfile("/py/server.py")
if(!_STUDIO_INVOKED)
{
console.close()
}
}
import web.view.7;
if(string.len(CMDLine)>=8192) win.msgbox("Too long CMDLine, and this may cause Error. ","Warning");
var view=web.view(mainForm.mainWeb,0,CMDLine);
view.go(webbase+"/web/index.html");
//win.msgbox(webbase)
mainForm.show();
import fsys.file
wrt=fsys.file("CMDline.txt","w")
wrt.write(CMDLine)
wrt.close()
var AndroidLine=CMDLine;
var ReplaceTable={
['"'] = "\"+'"'
};
AndroidLine=string.replace(AndroidLine,".|:",ReplaceTable);
AndroidLine='echo "_'+" "+AndroidLine+'" > chrome-command-line';
wrt=fsys.file("AndroidECHO.txt","w")
wrt.write(AndroidLine)
wrt.close()
if(_ARGV["o"])
{
url=webbase+"/CMDline.txt";
}
else if(_ARGV["a"])
{
url=webbase+"/AndroidECHO.txt";
}
else if(_ARGV["g"]) url=_ARGV["g"];
else if(_ARGV["h"])
{
url=webbase+"/help.html";
}
view.go(webbase+url);
mainForm.BTgo.oncommand = function(id,event){
if(mainForm.EDurl.text=="index") mainForm.EDurl.text=webbase+"/web/index.html"
else if(mainForm.EDurl.text=="proxypac") mainForm.EDurl.text=webbase+"/proxy.pac"
else if(mainForm.EDurl.text=="cmdline") mainForm.EDurl.text=webbase+"/CMDline.txt"
else if(mainForm.EDurl.text=="androidecho") mainForm.EDurl.text=webbase+"/AndroidECHO.txt"
else view.go(mainForm.EDurl.text)
}
mainForm.EDurl.oncommand = function(id,event){
}
return win.loopMessage();
/* You may need:
// from: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/components/network_session_configurator/common/network_switch_list.h
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file deliberately has no header guard, as it's inlined in a number of
// files.
// no-include-guard-because-multiply-included
// Disables the QUIC protocol.
NETWORK_SWITCH(kDisableQuic, "disable-quic")
// Disables the HTTP/2 protocol.
NETWORK_SWITCH(kDisableHttp2, "disable-http2")
// Enables Alternate-Protocol when the port is user controlled (> 1024).
NETWORK_SWITCH(kEnableUserAlternateProtocolPorts,
"enable-user-controlled-alternate-protocol-ports")
// Enables the QUIC protocol. This is a temporary testing flag.
NETWORK_SWITCH(kEnableQuic, "enable-quic")
// Ignores certificate-related errors.
NETWORK_SWITCH(kIgnoreCertificateErrors, "ignore-certificate-errors")
// Specifies a comma separated list of host-port pairs to force use of QUIC on.
NETWORK_SWITCH(kOriginToForceQuicOn, "origin-to-force-quic-on")
// Disables known-root checks for outgoing WebTransport connections.
NETWORK_SWITCH(kWebTransportDeveloperMode, "webtransport-developer-mode")
// Specifies a comma separated list of QUIC connection options to send to
// the server.
NETWORK_SWITCH(kQuicConnectionOptions, "quic-connection-options")
// Specifies a comma separated list of QUIC client connection options.
NETWORK_SWITCH(kQuicClientConnectionOptions, "quic-client-connection-options")
// Specifies the maximum length for a QUIC packet.
NETWORK_SWITCH(kQuicMaxPacketLength, "quic-max-packet-length")
// Specifies the version of QUIC to use.
NETWORK_SWITCH(kQuicVersion, "quic-version")
// Allows for forcing socket connections to http/https to use fixed ports.
NETWORK_SWITCH(kTestingFixedHttpPort, "testing-fixed-http-port")
NETWORK_SWITCH(kTestingFixedHttpsPort, "testing-fixed-https-port")
// Comma-separated list of rules that control how hostnames are mapped.
//
// For example:
// "MAP * 127.0.0.1" --> Forces all hostnames to be mapped to 127.0.0.1
// "MAP *.google.com proxy" --> Forces all google.com subdomains to be
// resolved to "proxy".
// "MAP test.com [::1]:77 --> Forces "test.com" to resolve to IPv6 loopback.
// Will also force the port of the resulting
// socket address to be 77.
// "MAP * baz, EXCLUDE www.google.com" --> Remaps everything to "baz",
// except for "www.google.com".
//
// These mappings apply to the endpoint host in a net::URLRequest (the TCP
// connect and host resolver in a direct connection, and the CONNECT in an http
// proxy connection, and the endpoint host in a SOCKS proxy connection).
//
// TODO(mmenke): Can we just remove this? host-resolver-rules is more generally
// useful.
NETWORK_SWITCH(kHostRules, "host-rules")
// Enable "greasing" HTTP/2 frame types, that is, sending frames of reserved
// types. See https://tools.ietf.org/html/draft-bishop-httpbis-grease-00 for
// more detail.
NETWORK_SWITCH(kHttp2GreaseFrameType, "http2-grease-frame-type")
// If request has no body, close the stream not by setting END_STREAM flag on
// the HEADERS frame, but by sending an empty DATA frame with END_STREAM
// afterwards. Only affects HTTP/2 request streams, not proxy or bidirectional
// streams.
NETWORK_SWITCH(kHttp2EndStreamWithDataFrame, "http2-end-stream-with-data-frame")
*/