forked from gopythonre/subweb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.py
396 lines (377 loc) · 29.1 KB
/
api.py
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# coding=utf-8
import sys
import flask_restful
from flask import redirect, url_for
import base64
import re
import requests
import urllib3
import urllib
import urllib.parse
import json
import time
import codecs
import api.subconverter
import api.aff
import api.getini
import api.admin
import os
from flask import Flask,render_template,request
urllib3.disable_warnings()
def safe_base64_decode(s): # 解密
try:
if len(s) % 4 != 0:
s = s + '=' * (4 - len(s) % 4)
base64_str = base64.urlsafe_b64decode(s)
return bytes.decode(base64_str)
except Exception as e:
print('解码错误')
def safe_base64_encode(s): # 加密
try:
return base64.urlsafe_b64encode(bytes(s, encoding='utf8'))
except Exception as e:
print('加密错误',e)
app = Flask(__name__)
ip = api.aff.apiip+'/'
@app.route('/',methods=['GET', 'POST'])
def login():
if request.method == "POST":
if request.form['submit'] == '基础使用版':
return redirect(ip+'basic')
if request.form['submit'] == '节点分组版':
return redirect(ip+'customgroup')
if request.form['submit'] == '配置文件版':
return redirect(ip+'ini')
if request.form['submit'] == '节点过滤版':
return redirect(ip+'list')
return render_template('login.html')
@app.route('/basic', methods=['GET', 'POST'])
def basic():
try:
if request.method == "POST":
s = request.form['left']
s = s.replace('\n','|').replace('\r','')
if s.split('|')[-1]== '':
s = s[:-1]
if '://' in s:
sub = urllib.parse.quote(s)
try:
tool=str(request.values.get('tool'))
emoji = request.form.get('emoji')
if emoji == None:
emoji = 'false'
fdn = request.form.get('fdn')
if fdn == None:
fdn= 'false'
new_name = request.form.get('new_name')
if new_name == None:
new_name= 'false'
except :
return '出现BUG,请反馈'
if tool == 'clashr':
CustomGroupvmess = '{ip}/sub?target=clashr&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=clashr&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('clashr.html',sub = s,custom="未填写",api=CustomGroupvmess,api2=api2)
if tool == 'trojan':
CustomGroupvmess = '{ip}/sub?target=trojan&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=trojan&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('trojan.html',sub = s,custom="未填写",api=CustomGroupvmess,api2=api2)
if tool == 'loon':
CustomGroupvmess = '{ip}/sub?target=loon&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=loon&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('loon.html',sub = s,custom="未填写",api=CustomGroupvmess,api2=api2)
if tool == 'surge':
CustomGroupvmess = '{ip}/sub?target=surge&url={sub}&ver=4&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=surge&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('surge.html',sub = s,custom="默认为surge4,参数为为ver=4。",api=CustomGroupvmess,api2=api2)
if tool == 'qx':
CustomGroupvmess = '{ip}/sub?target=quanx&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=quanx&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('quanx.html',sub = s,custom="未填写",api=CustomGroupvmess,api2=api2)
if tool == 'mellow':
CustomGroupvmess = '{ip}/sub?target=mellow&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=mellow&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('mellow.html',sub = s,custom="未填写",api=CustomGroupvmess,api2=api2)
if tool == 'surfboard':
CustomGroupvmess = '{ip}/sub?target=surfboard&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=surfboard&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('surfboard.html',sub = s,custom="未填写",api=CustomGroupvmess,api2=api2)
else:
return render_template('basic.html')
else:
return '订阅不规范'
return render_template('basic.html')
except Exception as e:
return e
@app.route('/customgroup', methods=['GET', 'POST'])
def customgroup():
try:
if request.method == "POST":
if request.form['submit'] == '点击添加节点分组':
ori1 = request.form['custom1']
ori2 = request.form['custom2']
ori3 = request.form['custom3']
add1 = '@'+ request.form['firstname']
add2 = '@'+request.form['lastname']
add3='@'+ request.values.get('method')
if add1 == '@':
return '未填写名称'
if add2 == '@':
return '未填写节点'
return render_template('index.html',custom1=ori1+add1,custom2=ori2+add2,custom3=ori3+add3)
s = request.form['left']
s = s.replace('\n','|').replace('\r','')
if s.split('|')[-1]== '':
s = s[:-1]
if '://' in s:
n=request.form['custom1']
c=request.form['custom2']
method = request.form['custom3']
len1 = len(str(n).split('@'))
len2 = len(str(c).split('@'))
len3 = len(str(method).split('@'))
if len1 != len2 or len1 != len3 or len2 != len3:
return('检查分组是否一一对应')
groups = str(safe_base64_encode(api.subconverter.getgroups(n,c,method))).split('\'')[1]
sub = urllib.parse.quote(s)
try:
tool=str(request.values.get('tool'))
emoji = request.form.get('emoji')
if emoji == None:
emoji = 'false'
fdn = request.form.get('fdn')
if fdn == None:
fdn= 'false'
new_name = request.form.get('new_name')
if new_name == None:
new_name= 'false'
except :
return '出现BUG,请反馈'
if tool == 'clashr':
CustomGroupvmess = '{ip}/sub?target=clashr&url={sub}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=clashr&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('clashr.html',sub = s,custom=n+c+method+' 备用暂时不支持',api=CustomGroupvmess,api2=api2)
if tool == 'trojan':
CustomGroupvmess = '{ip}/sub?target=trojan&url={sub}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=trojan&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('trojan.html',sub = s,custom=n+c+method+' 备用暂时不支持',api=CustomGroupvmess,api2=api2)
if tool == 'surge':
CustomGroupvmess = '{ip}/sub?target=surge&url={sub}&groups={groups}&ver=4&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=surge&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('surge.html',sub = s,custom=n+c+method+'\n备用暂时不支持\n'+'默认为surge4,参数为为ver=4。',api=CustomGroupvmess,api2=api2)
if tool == 'quanx':
CustomGroupvmess = '{ip}/sub?target=quanx&url={sub}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=quanx&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('quanx.html',sub = s,custom=n+c+method+' 备用暂时不支持',api=CustomGroupvmess,api2=api2)
if tool == 'loon':
CustomGroupvmess = '{ip}/sub?target=loon&url={sub}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=loon&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('loon.html',sub = s,custom=n+c+method+' 备用暂时不支持',api=CustomGroupvmess,api2=api2)
if tool == 'mellow':
CustomGroupvmess = '{ip}/sub?target=mellow&url={sub}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=mellow&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('mellow.html',sub = s,custom=n+c+method+' 备用暂时不支持',api=CustomGroupvmess,api2=api2)
if tool == 'surfboard':
CustomGroupvmess = '{ip}/sub?target=surfboard&url={sub}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=surfboard&url={sub}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(sub=str(sub),emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('surfboard.html',sub = s,custom=n+c+method+' 备用暂时不支持',api=CustomGroupvmess,api2=api2)
else:
return render_template('index.html')
else:
return '订阅不规范'
return render_template('index.html')
except Exception as e:
return e
@app.route('/ini', methods=['GET', 'POST'])
def inigroup():
try:
if request.method == "POST":
iniflag = 'url' #配置文件是本地配置或者远程配置标志位
s = request.form['left']
s = s.replace('\n','|').replace('\r','')
if s.split('|')[-1]== '':
s = s[:-1]
if '://' in s:
ini=request.form['ini']
sub = urllib.parse.quote(s)
try:
tool=str(request.values.get('tool'))
custom = request.form['custom1']
encodecustom=urllib.parse.quote(custom)
excustom = request.form['custom2']
encodeexcustom=urllib.parse.quote(excustom)
emoji = request.form.get('emoji')
if emoji == None:
emoji = 'false'
fdn = request.form.get('fdn')
if fdn == None:
fdn= 'false'
new_name = request.form.get('new_name')
if new_name == None:
new_name= 'false'
except :
return '出现BUG,请反馈'
try:
if ';设置规则标志位' in ini and ';设置分组标志位' in ini :
ini1 = api.subconverter.getini(ini).split('&')
if 'erro' in ini1 :
return '检查远程配置文件是否正确'
iniflag = 'file' #检测到本地配置,标志位设为file
rulesets = str(safe_base64_encode(ini1[0])).split('\'')[1]
groups = str(safe_base64_encode(ini1[1])).split('\'')[1]
else:
ini = urllib.parse.quote(ini)
except :
return '检查远程配置文件是否正确'
if tool == 'surge':
if iniflag == 'file':
CustomGroupvmess = '{ip}/sub?target=surge&url={sub}&ruleset={rulesets}&groups={groups}&ver=4&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(ip=api.aff.subip,sub=str(sub),groups=groups,rulesets=rulesets,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
api2 = 'https://gfwsb.114514.best/sub?target=surge&url={sub}&ruleset={rulesets}&groups={groups}&ver=4&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(sub=str(sub),groups=groups,rulesets=rulesets,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
return render_template('surge.html',sub = s,custom=ini+'\n默认为surge4,参数为为ver=4。',api=CustomGroupvmess,api2=api2)
if iniflag == 'url':
CustomGroupvmess = '{ip}/sub?target={tar}&url={sub}&config={config}&ver=4&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(tar=tool,ip=api.aff.subip,sub=str(sub),config=ini,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
api2 = 'https://gfwsb.114514.best/sub?target={tar}&url={sub}&config={config}&ver=4&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(tar=tool,sub=str(sub),config=ini,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
return render_template('surge.html',sub = s,custom=ini+'\n'+'默认为surge4,参数为为ver=4。',api=CustomGroupvmess,api2=api2)
if iniflag == 'file':
CustomGroupvmess = '{ip}/sub?target={tar}&url={sub}&ruleset={rulesets}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(tar=tool,ip=api.aff.subip,sub=str(sub),groups=groups,rulesets=rulesets,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
api2 = 'https://gfwsb.114514.best/sub?target={tar}&url={sub}&ruleset={rulesets}&groups={groups}&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(tar=tool,sub=str(sub),groups=groups,rulesets=rulesets,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
if iniflag == 'url':
CustomGroupvmess = '{ip}/sub?target={tar}&url={sub}&config={config}&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(tar=tool,ip=api.aff.subip,sub=str(sub),config=ini,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
api2 = 'https://gfwsb.114514.best/sub?target={tar}&url={sub}&config={config}&emoji={emoji}&fdn={fdn}&new_name={new_name}&include={custom}&exclude={custom2}'.format(tar=tool,sub=str(sub),config=ini,emoji=emoji,new_name=new_name,fdn=fdn,custom2=encodeexcustom,custom=encodecustom)
return render_template('{tool}.html'.format(tool=tool),sub = s,custom=ini,api=CustomGroupvmess,api2=api2)
else:
return '订阅不规范'
return render_template('ini.html')
except Exception as e:
return e
@app.route('/list', methods=['GET', 'POST'])
def lists():
try:
if request.method == "POST":
s = request.form['left']
s = s.replace('\n','|').replace('\r','')
if s.split('|')[-1]== '':
s = s[:-1]
if '://' in s:
sub = urllib.parse.quote(s)
try:
tool=str(request.values.get('tool'))
custom = request.form['custom1']
encodecustom=urllib.parse.quote(custom)
excustom = request.form['custom2']
encodeexcustom=urllib.parse.quote(excustom)
emoji = request.form.get('emoji')
if emoji == None:
emoji = 'false'
fdn = request.form.get('fdn')
if fdn == None:
fdn= 'false'
except :
return '出现BUG,请反馈'
yourcustom = '包含的节点:'+custom+' 去掉的节点:'+excustom
if tool == 'clashnode':
CustomGroupvmess = '{ip}/sub?target=clashr&list=true&url={sub}&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=clashr&list=true&url={sub}&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('clashr.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'qxnode':
CustomGroupvmess = '{ip}/sub?target=quanx&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=quanx&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('qxnode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'surnode':
CustomGroupvmess = '{ip}/sub?target=surge&url={sub}&ver=4&list=true&udp=true&tfo=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=surge&url={sub}&ver=4&list=true&udp=true&tfo=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('surgenode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'ssrnode':
CustomGroupvmess = '{ip}/sub?target=ssr&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=ssr&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('othernode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'quannode':
CustomGroupvmess = '{ip}/sub?target=quan&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=quan&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('othernode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'ssdnode':
CustomGroupvmess = '{ip}/sub?target=ssd&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=ssd&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('othernode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'ssnode':
CustomGroupvmess = '{ip}/sub?target=ss&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=ss&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('othernode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'sssubnode':
CustomGroupvmess = '{ip}/sub?target=sssub&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=sssub&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('othernode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
if tool == 'v2raynode':
CustomGroupvmess = '{ip}/sub?target=v2ray&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,ip=api.aff.subip,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
api2 = 'https://gfwsb.114514.best/sub?target=v2ray&url={sub}&list=true&include={custom}&exclude={custom2}&emoji={emoji}&fdn={fdn}&new_name={new_name}'.format(custom2=encodeexcustom,sub=str(sub),custom=encodecustom,emoji=emoji,new_name=new_name,fdn=fdn)
return render_template('othernode.html',sub = s,custom=yourcustom,api=CustomGroupvmess,api2=api2)
else:
return render_template('basic.html')
else:
return '订阅不规范'
return render_template('list.html')
except Exception as e:
return e
@app.route('/ruleset', methods=['GET', 'POST'])
def ruleset():
try:
if request.method == "POST":
if request.form['submit'] == '点击添加分流':
ori1 = request.form['rulecustom']+'\n'
ori = request.form['custom1']
add1 = 'surge_ruleset='+ request.form['rulename'] +','+request.form['rulelist']
return render_template('ruleset.html',rulecustom=ori1+add1,custom1=ori)
if request.form['submit'] == '点击添加分组':
ori1 = request.form['custom1']+'\n'
ori = request.form['rulecustom']
add1 = 'custom_proxy_group='+ request.form['firstname']
add2 = '`'+request.form['lastname']
add3='`'+ request.values.get('method')
if add1 == '`':
return '未填写名称'
if add2 == '`':
return '未填写地址'
if 'fallback' in add3 or 'url-test' in add3:
add4 = '`http://www.gstatic.com/generate_204`300'
else:
add4 = ''
return render_template('ruleset.html',rulecustom=ori,custom1=ori1+add1+add3+add2+add4)
return render_template('ruleset.html')
except Exception as e:
return e
@app.route('/help', methods=['GET', 'POST'])
def help():
try:
content= api.admin.getfile('../help.txt')
return render_template('content.html',content='帮助文档:\n\n\n'+content)
except Exception as e:
return '无帮助文档,请使用管理系统上传帮助文档到../help.txt'
@app.route('/admin', methods=['GET', 'POST'])
def admin():
try:
if request.method == "POST":
s = request.form['passwd']
if api.aff.passwd == s:
if request.form['submit'] == '上传配置':
content = request.form.get('content')
fileadd = request.form.get('file')
api.admin.writefile(content,fileadd)
content= api.admin.getfile(fileadd)
return render_template('content.html',content=content)
if request.form['submit'] == '查看配置':
fileadd = request.form.get('file')
content= api.admin.getfile(fileadd)
return render_template('content.html',content=content)
if request.form['submit'] == '重启后端' :
os.system('pkill subconverter')
return '重启后端成功!!!'
if request.form['submit'] == '重启前端' :
os.system('pkill -9 -f api.py')
return '重启前端成功!!!'
else:
return '密码错误'
return render_template('admin.html')
except Exception as e:
return e
if __name__ == '__main__':
app.run(host='0.0.0.0',debug=False,port=10086) #自定义端口