-
Notifications
You must be signed in to change notification settings - Fork 3
/
functions.js
208 lines (201 loc) · 6.47 KB
/
functions.js
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
// args: [{"name": "xxx", "value": "xxx"}...] // value will remove all ' and "
// return ["full command", null] or [null, "error message"]
function brook_server(args){
var s = "brook server";
for(var i=0; i<args.length; i++){
if(args[i].name == '--listen'){
if(!args[i].value){
return [null, "missing listen"];
}
s += " --listen '" + args[i].value + "'";
}
if(args[i].name == '--password'){
if(!args[i].value){
return [null, "missing password"];
}
s += " --password '" + args[i].value + "'";
}
if(args[i].name == '--tcpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "tcpTimeout must be int"];
}
s += " --tcpTimeout " + parseInt(args[i].value);
}
if(args[i].name == '--udpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "udpTimeout must be int"];
}
s += " --udpTimeout " + parseInt(args[i].value);
}
}
return [s, null];
}
function brook_wsserver(args){
var s = "brook wsserver";
for(var i=0; i<args.length; i++){
if(args[i].name == '--listen'){
if(!args[i].value){
return [null, "missing listen"];
}
s += " --listen '" + args[i].value + "'";
}
if(args[i].name == '--password'){
if(!args[i].value){
return [null, "missing password"];
}
s += " --password '" + args[i].value + "'";
}
if(args[i].name == '--path'){
if(!args[i].value){
return [null, "missing path"];
}
s += " --path '" + args[i].value + "'";
}
if(args[i].name == '--tcpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "tcpTimeout must be int"];
}
s += " --tcpTimeout " + parseInt(args[i].value);
}
if(args[i].name == '--udpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "udpTimeout must be int"];
}
s += " --udpTimeout " + parseInt(args[i].value);
}
}
return [s, null];
}
function brook_wssserver(args){
var s = "brook wssserver";
for(var i=0; i<args.length; i++){
if(args[i].name == '--domain'){
if(!args[i].value){
return [null, "missing domain"];
}
s += " --domain '" + args[i].value + "'";
}
if(args[i].name == '--password'){
if(!args[i].value){
return [null, "missing password"];
}
s += " --password '" + args[i].value + "'";
}
if(args[i].name == '--path'){
if(!args[i].value){
return [null, "missing path"];
}
s += " --path '" + args[i].value + "'";
}
if(args[i].name == '--tcpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "tcpTimeout must be int"];
}
s += " --tcpTimeout " + parseInt(args[i].value);
}
if(args[i].name == '--udpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "udpTimeout must be int"];
}
s += " --udpTimeout " + parseInt(args[i].value);
}
}
return [s, null];
}
function brook_socks5(args){
var s = "brook socks5";
for(var i=0; i<args.length; i++){
if(args[i].name == '--socks5'){
if(!args[i].value){
return [null, "missing socks5"];
}
s += " --socks5 '" + args[i].value + "'";
}
if(args[i].name == '--username'){
if(args[i].value){
s += " --username '" + args[i].value + "'";
}
}
if(args[i].name == '--password'){
if(args[i].value){
s += " --password '" + args[i].value + "'";
}
}
if(args[i].name == '--tcpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "tcpTimeout must be int"];
}
s += " --tcpTimeout " + parseInt(args[i].value);
}
if(args[i].name == '--udpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "udpTimeout must be int"];
}
s += " --udpTimeout " + parseInt(args[i].value);
}
}
return [s, null];
}
function brook_relay(args){
var s = "brook relay";
for(var i=0; i<args.length; i++){
if(args[i].name == '--from'){
if(!args[i].value){
return [null, "missing from"];
}
s += " --from '" + args[i].value + "'";
}
if(args[i].name == '--to'){
if(!args[i].value){
return [null, "missing to"];
}
s += " --to '" + args[i].value + "'";
}
if(args[i].name == '--tcpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "tcpTimeout must be int"];
}
s += " --tcpTimeout " + parseInt(args[i].value);
}
if(args[i].name == '--udpTimeout'){
if(isNaN(parseInt(args[i].value))){
return [null, "udpTimeout must be int"];
}
s += " --udpTimeout " + parseInt(args[i].value);
}
}
return [s, null];
}
function mr2_server(args){
var s = "mr2 server";
for(var i=0; i<args.length; i++){
if(args[i].name == '--listen'){
if(!args[i].value){
return [null, "missing listen"];
}
s += " --listen '" + args[i].value + "'";
}
if(args[i].name == '--password'){
if(!args[i].value){
return [null, "missing password"];
}
s += " --password '" + args[i].value + "'";
}
}
return [s, null];
}
function nico(args){
var s = "nico";
var l = args[0].value.split(' ').filter(function(v){return v.trim() != ''});
var l1 = [];
var l2 = [];
l.forEach(function(v){
l2.push(v);
if(l2.length == 2){
l1.push('"' + l2.join(' ') + '"');
l2 = [];
}
});
s += ' ' + l1.join(' ');
return [s, null];
}