hiddifypanel 10.70.9__py3-none-any.whl → 10.80.0.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hiddifypanel/VERSION +1 -1
- hiddifypanel/VERSION.py +5 -2
- hiddifypanel/__init__.py +5 -1
- hiddifypanel/auth.py +8 -3
- hiddifypanel/base.py +26 -23
- hiddifypanel/cache.py +2 -1
- hiddifypanel/drivers/ssh_liberty_bridge_api.py +2 -1
- hiddifypanel/drivers/wireguard_api.py +1 -1
- hiddifypanel/hutils/crypto.py +27 -0
- hiddifypanel/hutils/flask.py +5 -3
- hiddifypanel/hutils/network/cf_api.py +5 -5
- hiddifypanel/hutils/proxy/clash.py +1 -1
- hiddifypanel/hutils/proxy/shared.py +8 -12
- hiddifypanel/hutils/proxy/singbox.py +3 -1
- hiddifypanel/hutils/proxy/xray.py +1 -1
- hiddifypanel/models/admin.py +1 -1
- hiddifypanel/models/base_account.py +3 -0
- hiddifypanel/models/config.py +1 -1
- hiddifypanel/models/config_enum.py +13 -0
- hiddifypanel/models/user.py +2 -2
- hiddifypanel/panel/admin/AdminstratorAdmin.py +9 -2
- hiddifypanel/panel/admin/ProxyAdmin.py +4 -0
- hiddifypanel/panel/admin/QuickSetup.py +40 -9
- hiddifypanel/panel/admin/SettingAdmin.py +6 -0
- hiddifypanel/panel/admin/UserAdmin.py +10 -8
- hiddifypanel/panel/admin/adminlte.py +1 -1
- hiddifypanel/panel/cli.py +3 -1
- hiddifypanel/panel/commercial/restapi/v2/user/apps_api.py +76 -6
- hiddifypanel/panel/common.py +6 -3
- hiddifypanel/panel/common_bp/login.py +14 -8
- hiddifypanel/panel/init_db.py +139 -62
- hiddifypanel/panel/user/templates/base_singbox_config.json.j2 +16 -0
- hiddifypanel/panel/user/templates/home/home.html +1 -2
- hiddifypanel/panel/user/templates/home/multi.html +1 -2
- hiddifypanel/panel/user/user.py +1 -1
- hiddifypanel/static/apps-icon/singbox.ico +0 -0
- hiddifypanel/templates/fake.html +320 -0
- hiddifypanel/translations/en/LC_MESSAGES/messages.mo +0 -0
- hiddifypanel/translations/en/LC_MESSAGES/messages.po +50 -24
- hiddifypanel/translations/fa/LC_MESSAGES/messages.mo +0 -0
- hiddifypanel/translations/fa/LC_MESSAGES/messages.po +47 -25
- hiddifypanel/translations/pt/LC_MESSAGES/messages.mo +0 -0
- hiddifypanel/translations/pt/LC_MESSAGES/messages.po +41 -18
- hiddifypanel/translations/ru/LC_MESSAGES/messages.mo +0 -0
- hiddifypanel/translations/ru/LC_MESSAGES/messages.po +56 -29
- hiddifypanel/translations/zh/LC_MESSAGES/messages.mo +0 -0
- hiddifypanel/translations/zh/LC_MESSAGES/messages.po +34 -14
- hiddifypanel/translations.i18n/en.json +27 -11
- hiddifypanel/translations.i18n/fa.json +26 -10
- hiddifypanel/translations.i18n/fr.json +26 -8
- hiddifypanel/translations.i18n/my.json +1266 -0
- hiddifypanel/translations.i18n/pt.json +21 -5
- hiddifypanel/translations.i18n/ru.json +29 -13
- hiddifypanel/translations.i18n/zh.json +20 -4
- hiddifypanel-10.80.0.dev1.dist-info/METADATA +130 -0
- {hiddifypanel-10.70.9.dist-info → hiddifypanel-10.80.0.dev1.dist-info}/RECORD +111 -110
- {hiddifypanel-10.70.9.dist-info → hiddifypanel-10.80.0.dev1.dist-info}/WHEEL +1 -2
- hiddifypanel-10.80.0.dev1.dist-info/entry_points.txt +3 -0
- hiddifypanel-10.70.9.dist-info/METADATA +0 -144
- hiddifypanel-10.70.9.dist-info/entry_points.txt +0 -2
- hiddifypanel-10.70.9.dist-info/top_level.txt +0 -1
- {hiddifypanel-10.70.9.dist-info → hiddifypanel-10.80.0.dev1.dist-info}/LICENSE.md +0 -0
hiddifypanel/panel/init_db.py
CHANGED
@@ -17,6 +17,23 @@ from loguru import logger
|
|
17
17
|
MAX_DB_VERSION = 100
|
18
18
|
|
19
19
|
|
20
|
+
def _v97(child_id):
|
21
|
+
keys = hutils.crypto.generate_ssh_host_keys()
|
22
|
+
# set_hconfig(ConfigEnum.ssh_host_dsa_pk, keys['dsa']['pk'])
|
23
|
+
# set_hconfig(ConfigEnum.ssh_host_dsa_pub, keys['dsa']['pub'])
|
24
|
+
set_hconfig(ConfigEnum.ssh_host_rsa_pk, keys['rsa']['pk'])
|
25
|
+
set_hconfig(ConfigEnum.ssh_host_rsa_pub, keys['rsa']['pub'])
|
26
|
+
set_hconfig(ConfigEnum.ssh_host_ed25519_pk, keys['ed25519']['pk'])
|
27
|
+
set_hconfig(ConfigEnum.ssh_host_ed25519_pub, keys['ed25519']['pub'])
|
28
|
+
set_hconfig(ConfigEnum.ssh_host_ecdsa_pk, keys['ecdsa']['pk'])
|
29
|
+
set_hconfig(ConfigEnum.ssh_host_ecdsa_pub, keys['ecdsa']['pub'])
|
30
|
+
|
31
|
+
for a in AdminUser.query.all():
|
32
|
+
a.password = ""
|
33
|
+
for a in User.query.all():
|
34
|
+
a.password = ""
|
35
|
+
|
36
|
+
|
20
37
|
def _v96(child_id):
|
21
38
|
result = (
|
22
39
|
db.session.query(
|
@@ -68,7 +85,8 @@ def _v92(child_id):
|
|
68
85
|
|
69
86
|
|
70
87
|
def _v89(child_id):
|
71
|
-
set_hconfig(ConfigEnum.path_splithttp,
|
88
|
+
set_hconfig(ConfigEnum.path_splithttp,
|
89
|
+
hutils.random.get_random_string(7, 15))
|
72
90
|
set_hconfig(ConfigEnum.splithttp_enable, False)
|
73
91
|
pass
|
74
92
|
|
@@ -90,7 +108,8 @@ def _v85(child_id):
|
|
90
108
|
def _v84(child_id):
|
91
109
|
# the 2022-blake3-chacha20-poly1305 encryption method doesn't support multiuser config
|
92
110
|
if hconfig(ConfigEnum.shadowsocks2022_method) == '2022-blake3-chacha20-poly1305':
|
93
|
-
set_hconfig(ConfigEnum.shadowsocks2022_method,
|
111
|
+
set_hconfig(ConfigEnum.shadowsocks2022_method,
|
112
|
+
'2022-blake3-aes-256-gcm')
|
94
113
|
|
95
114
|
|
96
115
|
def _v83(child_id):
|
@@ -118,7 +137,8 @@ def _v79(child_id):
|
|
118
137
|
|
119
138
|
def _v78(child_id):
|
120
139
|
# equalize panel unique id and root child unique id
|
121
|
-
root_child_unique_id = Child.query.filter(
|
140
|
+
root_child_unique_id = Child.query.filter(
|
141
|
+
Child.name == "Root").first().unique_id
|
122
142
|
set_hconfig(ConfigEnum.unique_id, root_child_unique_id)
|
123
143
|
|
124
144
|
|
@@ -135,10 +155,12 @@ def _v74(child_id):
|
|
135
155
|
set_hconfig(ConfigEnum.ws_enable, False)
|
136
156
|
set_hconfig(ConfigEnum.grpc_enable, True)
|
137
157
|
set_hconfig(ConfigEnum.httpupgrade_enable, True)
|
138
|
-
set_hconfig(ConfigEnum.shadowsocks2022_port,
|
158
|
+
set_hconfig(ConfigEnum.shadowsocks2022_port,
|
159
|
+
hutils.random.get_random_unused_port())
|
139
160
|
set_hconfig(ConfigEnum.shadowsocks2022_method, "2022-blake3-aes-256-gcm")
|
140
161
|
set_hconfig(ConfigEnum.shadowsocks2022_enable, False)
|
141
|
-
set_hconfig(ConfigEnum.path_httpupgrade,
|
162
|
+
set_hconfig(ConfigEnum.path_httpupgrade,
|
163
|
+
hutils.random.get_random_string(7, 15))
|
142
164
|
db.session.bulk_save_objects(get_proxy_rows_v1())
|
143
165
|
|
144
166
|
for i in range(1, 10):
|
@@ -150,10 +172,14 @@ def _v74(child_id):
|
|
150
172
|
|
151
173
|
|
152
174
|
def _v71(child_id):
|
153
|
-
add_config_if_not_exist(ConfigEnum.tuic_port,
|
154
|
-
|
155
|
-
add_config_if_not_exist(ConfigEnum.
|
156
|
-
|
175
|
+
add_config_if_not_exist(ConfigEnum.tuic_port,
|
176
|
+
hutils.random.get_random_unused_port())
|
177
|
+
add_config_if_not_exist(ConfigEnum.hysteria_port,
|
178
|
+
hutils.random.get_random_unused_port())
|
179
|
+
add_config_if_not_exist(ConfigEnum.ssh_server_port,
|
180
|
+
hutils.random.get_random_unused_port())
|
181
|
+
add_config_if_not_exist(ConfigEnum.wireguard_port,
|
182
|
+
hutils.random.get_random_unused_port())
|
157
183
|
|
158
184
|
|
159
185
|
def _v70(child_id):
|
@@ -174,7 +200,8 @@ def _v70(child_id):
|
|
174
200
|
def _v69():
|
175
201
|
db.session.bulk_save_objects(get_proxy_rows_v1())
|
176
202
|
add_config_if_not_exist(ConfigEnum.wireguard_enable, True)
|
177
|
-
add_config_if_not_exist(ConfigEnum.wireguard_port,
|
203
|
+
add_config_if_not_exist(ConfigEnum.wireguard_port,
|
204
|
+
hutils.random.get_random_unused_port())
|
178
205
|
add_config_if_not_exist(ConfigEnum.wireguard_ipv4, "10.90.0.1")
|
179
206
|
add_config_if_not_exist(ConfigEnum.wireguard_ipv6, "fd42:42:90::1")
|
180
207
|
wg_pk, wg_pub, _ = hutils.crypto.get_wg_private_public_psk_pair()
|
@@ -198,7 +225,8 @@ def _v65():
|
|
198
225
|
|
199
226
|
def _v63():
|
200
227
|
add_config_if_not_exist(ConfigEnum.hysteria_enable, True)
|
201
|
-
add_config_if_not_exist(ConfigEnum.hysteria_port,
|
228
|
+
add_config_if_not_exist(ConfigEnum.hysteria_port,
|
229
|
+
hutils.random.get_random_unused_port())
|
202
230
|
add_config_if_not_exist(ConfigEnum.hysteria_obfs_enable, True)
|
203
231
|
add_config_if_not_exist(ConfigEnum.hysteria_up_mbps, "150")
|
204
232
|
add_config_if_not_exist(ConfigEnum.hysteria_down_mbps, "300")
|
@@ -219,20 +247,22 @@ def _v61():
|
|
219
247
|
|
220
248
|
|
221
249
|
def _v60():
|
222
|
-
add_config_if_not_exist(ConfigEnum.proxy_path_admin,
|
223
|
-
|
250
|
+
add_config_if_not_exist(ConfigEnum.proxy_path_admin,
|
251
|
+
hutils.random.get_random_string())
|
252
|
+
add_config_if_not_exist(ConfigEnum.proxy_path_client,
|
253
|
+
hutils.random.get_random_string())
|
224
254
|
|
225
255
|
|
226
256
|
def _v59():
|
227
257
|
# set user model username and password
|
228
258
|
for u in User.query.all():
|
229
259
|
hutils.model.gen_username(u)
|
230
|
-
hutils.model.gen_password(u)
|
260
|
+
# hutils.model.gen_password(u)
|
231
261
|
|
232
262
|
# set admin model username and password
|
233
263
|
for a in AdminUser.query.all():
|
234
264
|
hutils.model.gen_username(a)
|
235
|
-
hutils.model.gen_password(a)
|
265
|
+
# hutils.model.gen_password(a)
|
236
266
|
|
237
267
|
|
238
268
|
def _v57():
|
@@ -240,7 +270,8 @@ def _v57():
|
|
240
270
|
|
241
271
|
|
242
272
|
def _v56():
|
243
|
-
set_hconfig(ConfigEnum.reality_port,
|
273
|
+
set_hconfig(ConfigEnum.reality_port,
|
274
|
+
hutils.random.get_random_unused_port())
|
244
275
|
|
245
276
|
|
246
277
|
def _v55():
|
@@ -250,9 +281,12 @@ def _v55():
|
|
250
281
|
set_hconfig(ConfigEnum.hysteria_port, hystria_port)
|
251
282
|
set_hconfig(ConfigEnum.tuic_enable, True)
|
252
283
|
set_hconfig(ConfigEnum.hysteria_enable, True)
|
253
|
-
Proxy.query.filter(Proxy.proto.in_(
|
254
|
-
|
255
|
-
db.session.add(Proxy(l3='tls', transport='custom',
|
284
|
+
Proxy.query.filter(Proxy.proto.in_(
|
285
|
+
["tuic", "hysteria2", "hysteria"])).delete()
|
286
|
+
db.session.add(Proxy(l3='tls', transport='custom',
|
287
|
+
cdn='direct', proto='tuic', enable=True, name="TUIC"))
|
288
|
+
db.session.add(Proxy(l3='tls', transport='custom', cdn='direct',
|
289
|
+
proto='hysteria2', enable=True, name="Hysteria2"))
|
256
290
|
|
257
291
|
|
258
292
|
def _v52():
|
@@ -281,15 +315,18 @@ def _v48():
|
|
281
315
|
|
282
316
|
|
283
317
|
def _v47():
|
284
|
-
StrConfig.query.filter(
|
318
|
+
StrConfig.query.filter(
|
319
|
+
StrConfig.key == ConfigEnum.ssh_server_enable).delete()
|
285
320
|
|
286
321
|
|
287
322
|
def _v45():
|
288
323
|
|
289
324
|
if not Proxy.query.filter(Proxy.name == "SSH").first():
|
290
|
-
db.session.add(Proxy(l3='ssh', transport='ssh',
|
325
|
+
db.session.add(Proxy(l3='ssh', transport='ssh',
|
326
|
+
cdn='direct', proto='ssh', enable=True, name="SSH"))
|
291
327
|
|
292
|
-
add_config_if_not_exist(ConfigEnum.ssh_server_port,
|
328
|
+
add_config_if_not_exist(ConfigEnum.ssh_server_port,
|
329
|
+
hutils.random.get_random_unused_port())
|
293
330
|
add_config_if_not_exist(ConfigEnum.ssh_server_enable, False)
|
294
331
|
# def _v43():
|
295
332
|
# if not (Domain.query.filter(Domain.domain==hconfig(ConfigEnum.domain_fronting_domain)).first()):
|
@@ -315,7 +352,8 @@ def _v41():
|
|
315
352
|
|
316
353
|
def _v38():
|
317
354
|
add_config_if_not_exist(ConfigEnum.dns_server, "1.1.1.1")
|
318
|
-
add_config_if_not_exist(ConfigEnum.warp_mode, "all" if hconfig(
|
355
|
+
add_config_if_not_exist(ConfigEnum.warp_mode, "all" if hconfig(
|
356
|
+
ConfigEnum.warp_enable) else "disable")
|
319
357
|
add_config_if_not_exist(ConfigEnum.warp_plus_code, '')
|
320
358
|
|
321
359
|
|
@@ -329,13 +367,17 @@ def _v33():
|
|
329
367
|
|
330
368
|
|
331
369
|
def _v31():
|
332
|
-
add_config_if_not_exist(ConfigEnum.reality_short_ids,
|
370
|
+
add_config_if_not_exist(ConfigEnum.reality_short_ids,
|
371
|
+
uuid.uuid4().hex[0:random.randint(1, 8) * 2])
|
333
372
|
key_pair = hutils.crypto.generate_x25519_keys()
|
334
|
-
add_config_if_not_exist(
|
335
|
-
|
373
|
+
add_config_if_not_exist(
|
374
|
+
ConfigEnum.reality_private_key, key_pair['private_key'])
|
375
|
+
add_config_if_not_exist(
|
376
|
+
ConfigEnum.reality_public_key, key_pair['public_key'])
|
336
377
|
db.session.bulk_save_objects(get_proxy_rows_v1())
|
337
378
|
if not (AdminUser.query.filter(AdminUser.id == 1).first()):
|
338
|
-
db.session.add(AdminUser(id=1, uuid=hconfig(
|
379
|
+
db.session.add(AdminUser(id=1, uuid=hconfig(
|
380
|
+
ConfigEnum.admin_secret), name="Owner", mode=AdminMode.super_admin, comment=""))
|
339
381
|
execute("update admin_user set id=1 where name='owner'")
|
340
382
|
for i in range(1, 10):
|
341
383
|
for d in hutils.network.get_random_domains(50):
|
@@ -370,7 +412,8 @@ def _v20():
|
|
370
412
|
if hconfig(ConfigEnum.domain_fronting_domain):
|
371
413
|
fake_domains = [hconfig(ConfigEnum.domain_fronting_domain)]
|
372
414
|
|
373
|
-
direct_domain = Domain.query.filter(
|
415
|
+
direct_domain = Domain.query.filter(
|
416
|
+
Domain.mode in [DomainType.direct, DomainType.relay]).first()
|
374
417
|
if direct_domain:
|
375
418
|
direct_host = direct_domain.domain
|
376
419
|
else:
|
@@ -378,7 +421,8 @@ def _v20():
|
|
378
421
|
|
379
422
|
for fd in fake_domains:
|
380
423
|
if not Domain.query.filter(Domain.domain == fd).first():
|
381
|
-
db.session.add(Domain(
|
424
|
+
db.session.add(Domain(
|
425
|
+
domain=fd, mode='fake', alias='moved from domain fronting', cdn_ip=direct_host))
|
382
426
|
|
383
427
|
|
384
428
|
def _v19():
|
@@ -391,7 +435,8 @@ def _v19():
|
|
391
435
|
set_hconfig(ConfigEnum.path_ws, hutils.random.get_random_string(7, 15))
|
392
436
|
add_config_if_not_exist(ConfigEnum.tuic_enable, False)
|
393
437
|
add_config_if_not_exist(ConfigEnum.shadowtls_enable, False)
|
394
|
-
add_config_if_not_exist(
|
438
|
+
add_config_if_not_exist(
|
439
|
+
ConfigEnum.shadowtls_fakedomain, "en.wikipedia.org")
|
395
440
|
add_config_if_not_exist(ConfigEnum.utls, "chrome")
|
396
441
|
add_config_if_not_exist(ConfigEnum.telegram_bot_token, "")
|
397
442
|
add_config_if_not_exist(ConfigEnum.package_mode, "release")
|
@@ -416,14 +461,17 @@ def _v1():
|
|
416
461
|
|
417
462
|
data = [
|
418
463
|
StrConfig(key=ConfigEnum.db_version, value=1),
|
419
|
-
User(name="default", usage_limit_GB=3000,
|
464
|
+
User(name="default", usage_limit_GB=3000,
|
465
|
+
package_days=3650, mode=UserMode.weekly),
|
420
466
|
Domain(domain=external_ip + ".sslip.io", mode=DomainType.direct),
|
421
467
|
StrConfig(key=ConfigEnum.admin_secret, value=uuid.uuid4()),
|
422
468
|
StrConfig(key=ConfigEnum.http_ports, value="80"),
|
423
469
|
StrConfig(key=ConfigEnum.tls_ports, value="443"),
|
424
470
|
BoolConfig(key=ConfigEnum.first_setup, value=True),
|
425
|
-
StrConfig(key=ConfigEnum.decoy_domain,
|
426
|
-
|
471
|
+
StrConfig(key=ConfigEnum.decoy_domain,
|
472
|
+
value=hutils.network.get_random_decoy_domain()),
|
473
|
+
StrConfig(key=ConfigEnum.proxy_path,
|
474
|
+
value=hutils.random.get_random_string()),
|
427
475
|
BoolConfig(key=ConfigEnum.firewall, value=False),
|
428
476
|
BoolConfig(key=ConfigEnum.netdata, value=True),
|
429
477
|
StrConfig(key=ConfigEnum.lang, value='en'),
|
@@ -473,7 +521,8 @@ def _v1():
|
|
473
521
|
def _v7():
|
474
522
|
try:
|
475
523
|
Proxy.query.filter(Proxy.name == 'tls XTLS direct trojan').delete()
|
476
|
-
Proxy.query.filter(
|
524
|
+
Proxy.query.filter(
|
525
|
+
Proxy.name == 'tls XTLSVision direct trojan').delete()
|
477
526
|
except BaseException:
|
478
527
|
pass
|
479
528
|
add_config_if_not_exist(ConfigEnum.telegram_lib, "erlang")
|
@@ -576,20 +625,32 @@ def get_proxy_rows_v1():
|
|
576
625
|
|
577
626
|
]
|
578
627
|
))
|
579
|
-
rows.append(Proxy(l3=ProxyL3.custom, transport=ProxyTransport.shadowsocks,
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
rows.append(Proxy(l3=
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
rows.append(Proxy(l3='
|
589
|
-
|
590
|
-
rows.append(Proxy(l3='
|
591
|
-
|
592
|
-
|
628
|
+
rows.append(Proxy(l3=ProxyL3.custom, transport=ProxyTransport.shadowsocks,
|
629
|
+
cdn='direct', proto='ss', enable=True, name="ShadowSocks2022"))
|
630
|
+
rows.append(Proxy(l3=ProxyL3.custom, transport=ProxyTransport.shadowsocks,
|
631
|
+
cdn='relay', proto='ss', enable=True, name="ShadowSocks2022 Relay"))
|
632
|
+
|
633
|
+
rows.append(Proxy(l3=ProxyL3.tls, transport=ProxyTransport.shadowtls,
|
634
|
+
cdn='direct', proto='ss', enable=True, name="ShadowTLS"))
|
635
|
+
rows.append(Proxy(l3=ProxyL3.tls, transport=ProxyTransport.shadowtls,
|
636
|
+
cdn='relay', proto='ss', enable=True, name="ShadowTLS Relay"))
|
637
|
+
rows.append(Proxy(l3='ssh', transport='ssh', cdn='direct',
|
638
|
+
proto='ssh', enable=True, name="SSH"))
|
639
|
+
rows.append(Proxy(l3='ssh', transport=ProxyTransport.ssh,
|
640
|
+
cdn=ProxyCDN.relay, proto=ProxyProto.ssh, enable=True, name="SSH Relay"))
|
641
|
+
|
642
|
+
rows.append(Proxy(l3='tls', transport='custom', cdn='direct',
|
643
|
+
proto='tuic', enable=True, name="TUIC"))
|
644
|
+
rows.append(Proxy(l3='tls', transport='custom', cdn='relay',
|
645
|
+
proto='tuic', enable=True, name="TUIC Relay"))
|
646
|
+
rows.append(Proxy(l3='tls', transport='custom', cdn='direct',
|
647
|
+
proto='hysteria2', enable=True, name="Hysteria2"))
|
648
|
+
rows.append(Proxy(l3='tls', transport='custom', cdn='relay',
|
649
|
+
proto='hysteria2', enable=True, name="Hysteria2 Relay"))
|
650
|
+
rows.append(Proxy(l3=ProxyL3.udp, transport=ProxyTransport.custom,
|
651
|
+
cdn=ProxyCDN.direct, proto=ProxyProto.wireguard, enable=True, name="WireGuard"))
|
652
|
+
rows.append(Proxy(l3=ProxyL3.udp, transport=ProxyTransport.custom, cdn=ProxyCDN.relay,
|
653
|
+
proto=ProxyProto.wireguard, enable=True, name="WireGuard Relay"))
|
593
654
|
for p in rows:
|
594
655
|
is_exist = Proxy.query.filter(Proxy.name == p.name).first() or Proxy.query.filter(
|
595
656
|
Proxy.l3 == p.l3, Proxy.transport == p.transport, Proxy.cdn == p.cdn, Proxy.proto == p.proto).first()
|
@@ -638,7 +699,8 @@ def add_column(column):
|
|
638
699
|
try:
|
639
700
|
column_type = column.type.compile(db.engine.dialect)
|
640
701
|
|
641
|
-
db_execute(
|
702
|
+
db_execute(
|
703
|
+
f'ALTER TABLE {column.table.name} ADD COLUMN {column.name} {column_type}', commit=True)
|
642
704
|
except BaseException:
|
643
705
|
pass
|
644
706
|
|
@@ -663,13 +725,15 @@ def add_new_enum_values():
|
|
663
725
|
table_name = col.table
|
664
726
|
|
665
727
|
# Get the existing values in the enum
|
666
|
-
existing_values = [f'{e}' if isinstance(
|
728
|
+
existing_values = [f'{e}' if isinstance(
|
729
|
+
e, ConfigEnum) else e.value for e in enum_class]
|
667
730
|
|
668
731
|
# Get the values in the enum column in the database
|
669
732
|
# result = db.engine.execute(f"SELECT DISTINCT `{column_name}` FROM {table_name}")
|
670
733
|
# db_values = {row[0] for row in result}
|
671
734
|
|
672
|
-
result = db.session.execute(
|
735
|
+
result = db.session.execute(
|
736
|
+
text(f"SHOW COLUMNS FROM {table_name} LIKE '{column_name}';")).fetchall()
|
673
737
|
db_values = []
|
674
738
|
|
675
739
|
for row in result:
|
@@ -688,7 +752,8 @@ def add_new_enum_values():
|
|
688
752
|
# Add the new value to the enum column in the database
|
689
753
|
enumstr = ','.join([f"'{a}'" for a in [*existing_values, *old_values]])
|
690
754
|
|
691
|
-
db_execute(
|
755
|
+
db_execute(
|
756
|
+
f"ALTER TABLE {table_name} MODIFY COLUMN `{column_name}` ENUM({enumstr});", commit=True)
|
692
757
|
|
693
758
|
|
694
759
|
def latest_db_version():
|
@@ -710,7 +775,8 @@ def upgrade_database():
|
|
710
775
|
logger.info("no backup found...")
|
711
776
|
return
|
712
777
|
if os.path.isfile(sqlite_db):
|
713
|
-
logger.info(
|
778
|
+
logger.info(
|
779
|
+
"Finding Old Version Database... importing configs from latest backup")
|
714
780
|
newest_file = max([(f, os.path.getmtime(os.path.join(backup_root, f)))
|
715
781
|
for f in os.listdir(backup_root) if os.path.isfile(os.path.join(backup_root, f))], key=lambda x: x[1])[0]
|
716
782
|
with open(f'{backup_root}{newest_file}', 'r') as f:
|
@@ -728,7 +794,8 @@ def upgrade_database():
|
|
728
794
|
override_child_unique_id=0,
|
729
795
|
replace_owner_admin=True
|
730
796
|
)
|
731
|
-
db_version = int(
|
797
|
+
db_version = int(
|
798
|
+
[d['value'] for d in json_data['hconfigs'] if d['key'] == "db_version"][0])
|
732
799
|
os.rename(sqlite_db, sqlite_db + ".old")
|
733
800
|
set_hconfig(ConfigEnum.db_version, db_version, commit=True)
|
734
801
|
|
@@ -765,7 +832,8 @@ def init_db():
|
|
765
832
|
if not db_action or (start_version == 0 and ver == 10):
|
766
833
|
continue
|
767
834
|
|
768
|
-
logger.info(
|
835
|
+
logger.info(
|
836
|
+
f"Updating db from version {db_version} for node {child.id}")
|
769
837
|
|
770
838
|
if ver < 70:
|
771
839
|
if child.id != 0:
|
@@ -775,11 +843,13 @@ def init_db():
|
|
775
843
|
db_action(child.id)
|
776
844
|
|
777
845
|
Events.db_init_event.notify(db_version=db_version)
|
778
|
-
logger.info(
|
846
|
+
logger.info(
|
847
|
+
f"Updated successfuly db from version {db_version} to {ver}")
|
779
848
|
|
780
849
|
db_version = ver
|
781
850
|
db.session.commit()
|
782
|
-
set_hconfig(ConfigEnum.db_version, db_version,
|
851
|
+
set_hconfig(ConfigEnum.db_version, db_version,
|
852
|
+
child_id=child.id, commit=False)
|
783
853
|
|
784
854
|
db.session.commit()
|
785
855
|
g.child = Child.by_id(0)
|
@@ -791,11 +861,14 @@ def migrate(db_version):
|
|
791
861
|
for column in table_obj.columns:
|
792
862
|
add_column(column)
|
793
863
|
Events.db_prehook.notify()
|
864
|
+
if db_version < 97:
|
865
|
+
execute('ALTER TABLE str_config MODIFY value VARCHAR(3072);')
|
794
866
|
if db_version < 82:
|
795
867
|
execute('ALTER TABLE child DROP INDEX `name`;')
|
796
868
|
if db_version < 77:
|
797
869
|
execute('ALTER TABLE user_detail DROP COLUMN connected_ips;')
|
798
|
-
execute(
|
870
|
+
execute(
|
871
|
+
'update user_detail set connected_devices="" where connected_devices IS NULL')
|
799
872
|
|
800
873
|
if db_version < 70:
|
801
874
|
execute('CREATE INDEX date ON daily_usage (date);')
|
@@ -827,7 +900,8 @@ def migrate(db_version):
|
|
827
900
|
|
828
901
|
if db_version < 52:
|
829
902
|
execute(f'update domain set mode="sub_link_only", sub_link_only=false where sub_link_only = true or mode=1 or mode="1"')
|
830
|
-
execute(
|
903
|
+
execute(
|
904
|
+
f'update domain set mode="direct", sub_link_only=false where mode=0 or mode="0"')
|
831
905
|
execute(f'update proxy set transport="WS" where transport = "ws"')
|
832
906
|
execute(f'update admin_user set mode="agent" where mode = "slave"')
|
833
907
|
execute(f'update admin_user set mode="super_admin" where id=1')
|
@@ -867,9 +941,12 @@ def migrate(db_version):
|
|
867
941
|
execute(f'DROP TABLE str_config')
|
868
942
|
execute(f'ALTER TABLE str_config_old RENAME TO str_config')
|
869
943
|
|
870
|
-
execute(
|
871
|
-
|
872
|
-
execute(
|
944
|
+
execute(
|
945
|
+
'ALTER TABLE user RENAME COLUMN monthly_usage_limit_GB TO usage_limit_GB')
|
946
|
+
execute(
|
947
|
+
f'update admin_user set parent_admin_id=1 where parent_admin_id is NULL and 1!=id')
|
948
|
+
execute(
|
949
|
+
f'update admin_user set max_users=100,max_active_users=100 where max_users is NULL')
|
873
950
|
execute(f'update dailyusage set child_id=0 where child_id is NULL')
|
874
951
|
execute(f'update dailyusage set admin_id=1 where admin_id is NULL')
|
875
952
|
execute(f'update dailyusage set admin_id=1 where admin_id = 0')
|
@@ -49,6 +49,22 @@
|
|
49
49
|
"download_detour": "bypass"
|
50
50
|
}
|
51
51
|
{%endif%}
|
52
|
+
{%if hconfig(ConfigEnum.country)=="ru"%}
|
53
|
+
{
|
54
|
+
"tag": "geosite-ru",
|
55
|
+
"type": "remote",
|
56
|
+
"format": "binary",
|
57
|
+
"url": "https:\/\/github.com\/SagerNet\/sing-geosite\/raw\/rule-set\/geosite-category-ru.srs",
|
58
|
+
"download_detour": "bypass"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"tag": "geoip-ru",
|
62
|
+
"type": "remote",
|
63
|
+
"format": "binary",
|
64
|
+
"url": "https:\/\/github.com\/SagerNet\/sing-geoip\/raw\/rule-set\/geoip-ru.srs",
|
65
|
+
"download_detour": "bypass"
|
66
|
+
}
|
67
|
+
{%endif%}
|
52
68
|
{# {
|
53
69
|
"tag": "geosite-category-ads-all",
|
54
70
|
"type": "remote",
|
@@ -404,8 +404,7 @@
|
|
404
404
|
{{_("Check again")}}
|
405
405
|
</button>
|
406
406
|
{%- endmacro -%}
|
407
|
-
{{modal("country-alarm-modal",_("Turn of VPN"),_("
|
408
|
-
expected=%(expected_country)s",your_country=country,expected_country=hconfig(ConfigEnum.country)),footer=reload(),show=True)}}
|
407
|
+
{{modal("country-alarm-modal",_("Turn of VPN"),_("vpn.notallowed",your_country=country,expected_country=hconfig(ConfigEnum.country)),footer=reload(),show=True)}}
|
409
408
|
{% endif %}
|
410
409
|
|
411
410
|
|
@@ -404,8 +404,7 @@
|
|
404
404
|
{{_("Check again")}}
|
405
405
|
</button>
|
406
406
|
{%- endmacro -%}
|
407
|
-
{{modal("country-alarm-modal",_("Turn of VPN"),_("
|
408
|
-
expected=%(expected_country)s",your_country=country,expected_country=hconfig(ConfigEnum.country)),footer=reload(),show=True)}}
|
407
|
+
{{modal("country-alarm-modal",_("Turn of VPN"),_("vpn.notallowed,your_country=country,expected_country=hconfig(ConfigEnum.country)),footer=reload(),show=True)}}
|
409
408
|
{% endif %}
|
410
409
|
|
411
410
|
|
hiddifypanel/panel/user/user.py
CHANGED
@@ -266,7 +266,7 @@ Endpoint = {next(iter(servers))}:61339 #{servers}
|
|
266
266
|
if request.method == 'HEAD':
|
267
267
|
resp = ""
|
268
268
|
else:
|
269
|
-
resp = render_template('singbox_config.json', **c, host_keys=hutils.proxy.get_ssh_hostkeys(True),
|
269
|
+
resp = render_template('singbox_config.json', **c, host_keys=hutils.proxy.get_ssh_hostkeys(get_hconfigs(),True),
|
270
270
|
ssh_client_version=hiddify.get_ssh_client_version(user), ssh_ip=hutils.network.get_direct_host_or_ip(4), base64=False)
|
271
271
|
|
272
272
|
return add_headers(resp, c)
|
Binary file
|