hiddifypanel 10.70.8__py3-none-any.whl → 10.80.0__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.
Files changed (89) hide show
  1. hiddifypanel/VERSION +1 -1
  2. hiddifypanel/VERSION.py +5 -2
  3. hiddifypanel/__init__.py +5 -1
  4. hiddifypanel/apps/__init__.py +0 -0
  5. hiddifypanel/apps/asgi_app.py +7 -0
  6. hiddifypanel/apps/celery_app.py +3 -0
  7. hiddifypanel/apps/wsgi_app.py +5 -0
  8. hiddifypanel/auth.py +8 -3
  9. hiddifypanel/base.py +43 -126
  10. hiddifypanel/base_setup.py +82 -0
  11. hiddifypanel/cache.py +3 -2
  12. hiddifypanel/celery.py +45 -0
  13. hiddifypanel/database.py +7 -0
  14. hiddifypanel/drivers/ssh_liberty_bridge_api.py +2 -1
  15. hiddifypanel/drivers/wireguard_api.py +1 -1
  16. hiddifypanel/hutils/crypto.py +27 -0
  17. hiddifypanel/hutils/flask.py +5 -3
  18. hiddifypanel/hutils/network/cf_api.py +5 -5
  19. hiddifypanel/hutils/proxy/__init__.py +1 -0
  20. hiddifypanel/hutils/proxy/clash.py +3 -3
  21. hiddifypanel/hutils/proxy/shared.py +14 -18
  22. hiddifypanel/hutils/proxy/singbox.py +4 -2
  23. hiddifypanel/hutils/proxy/wireguard.py +34 -0
  24. hiddifypanel/hutils/proxy/xray.py +3 -3
  25. hiddifypanel/hutils/proxy/xrayjson.py +10 -7
  26. hiddifypanel/models/admin.py +1 -1
  27. hiddifypanel/models/base_account.py +3 -0
  28. hiddifypanel/models/config.py +5 -2
  29. hiddifypanel/models/config_enum.py +15 -2
  30. hiddifypanel/models/proxy.py +1 -1
  31. hiddifypanel/models/user.py +2 -2
  32. hiddifypanel/panel/__init__.py +8 -8
  33. hiddifypanel/panel/admin/AdminstratorAdmin.py +16 -10
  34. hiddifypanel/panel/admin/DomainAdmin.py +132 -98
  35. hiddifypanel/panel/admin/ProxyAdmin.py +4 -0
  36. hiddifypanel/panel/admin/QuickSetup.py +48 -17
  37. hiddifypanel/panel/admin/SettingAdmin.py +6 -0
  38. hiddifypanel/panel/admin/UserAdmin.py +63 -36
  39. hiddifypanel/panel/admin/adminlte.py +1 -1
  40. hiddifypanel/panel/admin/templates/index.html +6 -4
  41. hiddifypanel/panel/admin/templates/model/user_list.html +11 -3
  42. hiddifypanel/panel/cli.py +14 -3
  43. hiddifypanel/panel/commercial/restapi/v1/tgbot.py +19 -1
  44. hiddifypanel/panel/commercial/restapi/v2/admin/system_actions.py +5 -1
  45. hiddifypanel/panel/commercial/restapi/v2/admin/user_api.py +2 -1
  46. hiddifypanel/panel/commercial/restapi/v2/user/apps_api.py +76 -6
  47. hiddifypanel/panel/common.py +5 -2
  48. hiddifypanel/panel/common_bp/login.py +14 -8
  49. hiddifypanel/panel/hlogger.py +32 -0
  50. hiddifypanel/panel/init_db.py +157 -77
  51. hiddifypanel/panel/node/__init__.py +9 -0
  52. hiddifypanel/panel/node/a.py +14 -0
  53. hiddifypanel/panel/node/hello.py +14 -0
  54. hiddifypanel/panel/node/test.proto +13 -0
  55. hiddifypanel/panel/node/test_grpc.py +40 -0
  56. hiddifypanel/panel/node/test_pb2.py +40 -0
  57. hiddifypanel/panel/node/test_pb2.pyi +17 -0
  58. hiddifypanel/panel/node/test_pb2_grpc.py +97 -0
  59. hiddifypanel/panel/usage.py +13 -3
  60. hiddifypanel/panel/user/templates/base_singbox_config.json.j2 +16 -0
  61. hiddifypanel/panel/user/templates/home/home.html +1 -2
  62. hiddifypanel/panel/user/templates/home/multi.html +1 -2
  63. hiddifypanel/panel/user/user.py +13 -19
  64. hiddifypanel/static/apps-icon/singbox.ico +0 -0
  65. hiddifypanel/translations/en/LC_MESSAGES/messages.mo +0 -0
  66. hiddifypanel/translations/en/LC_MESSAGES/messages.po +125 -30
  67. hiddifypanel/translations/fa/LC_MESSAGES/messages.mo +0 -0
  68. hiddifypanel/translations/fa/LC_MESSAGES/messages.po +123 -32
  69. hiddifypanel/translations/pt/LC_MESSAGES/messages.mo +0 -0
  70. hiddifypanel/translations/pt/LC_MESSAGES/messages.po +114 -22
  71. hiddifypanel/translations/ru/LC_MESSAGES/messages.mo +0 -0
  72. hiddifypanel/translations/ru/LC_MESSAGES/messages.po +129 -32
  73. hiddifypanel/translations/zh/LC_MESSAGES/messages.mo +0 -0
  74. hiddifypanel/translations/zh/LC_MESSAGES/messages.po +107 -18
  75. hiddifypanel/translations.i18n/en.json +73 -14
  76. hiddifypanel/translations.i18n/fa.json +72 -13
  77. hiddifypanel/translations.i18n/fr.json +28 -10
  78. hiddifypanel/translations.i18n/my.json +1266 -0
  79. hiddifypanel/translations.i18n/pt.json +68 -9
  80. hiddifypanel/translations.i18n/ru.json +75 -16
  81. hiddifypanel/translations.i18n/zh.json +67 -8
  82. hiddifypanel-10.80.0.dist-info/METADATA +137 -0
  83. {hiddifypanel-10.70.8.dist-info → hiddifypanel-10.80.0.dist-info}/RECORD +136 -119
  84. {hiddifypanel-10.70.8.dist-info → hiddifypanel-10.80.0.dist-info}/WHEEL +1 -2
  85. hiddifypanel-10.80.0.dist-info/entry_points.txt +3 -0
  86. hiddifypanel-10.70.8.dist-info/METADATA +0 -144
  87. hiddifypanel-10.70.8.dist-info/entry_points.txt +0 -2
  88. hiddifypanel-10.70.8.dist-info/top_level.txt +0 -1
  89. {hiddifypanel-10.70.8.dist-info → hiddifypanel-10.80.0.dist-info}/LICENSE.md +0 -0
@@ -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(
@@ -60,7 +77,7 @@ def _v94(child_id):
60
77
 
61
78
  def _v93(child_id):
62
79
  set_hconfig(ConfigEnum.quic_enable, True)
63
- set_hconfig(ConfigEnum.splithttp_enable, True)
80
+ set_hconfig(ConfigEnum.xhttp_enable, True)
64
81
 
65
82
 
66
83
  def _v92(child_id):
@@ -68,8 +85,9 @@ def _v92(child_id):
68
85
 
69
86
 
70
87
  def _v89(child_id):
71
- set_hconfig(ConfigEnum.path_splithttp, hutils.random.get_random_string(7, 15))
72
- set_hconfig(ConfigEnum.splithttp_enable, False)
88
+ set_hconfig(ConfigEnum.path_xhttp,
89
+ hutils.random.get_random_string(7, 15))
90
+ set_hconfig(ConfigEnum.xhttp_enable, False)
73
91
  pass
74
92
 
75
93
 
@@ -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, '2022-blake3-aes-256-gcm')
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(Child.name == "Root").first().unique_id
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, hutils.random.get_random_unused_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, hutils.random.get_random_string(7, 15))
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, hutils.random.get_random_unused_port())
154
- add_config_if_not_exist(ConfigEnum.hysteria_port, hutils.random.get_random_unused_port())
155
- add_config_if_not_exist(ConfigEnum.ssh_server_port, hutils.random.get_random_unused_port())
156
- add_config_if_not_exist(ConfigEnum.wireguard_port, hutils.random.get_random_unused_port())
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, hutils.random.get_random_unused_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()
@@ -191,14 +218,15 @@ def _v65():
191
218
  add_config_if_not_exist(ConfigEnum.mux_min_streams, '4')
192
219
  add_config_if_not_exist(ConfigEnum.mux_max_streams, '0')
193
220
  add_config_if_not_exist(ConfigEnum.mux_padding_enable, False)
194
- add_config_if_not_exist(ConfigEnum.mux_brutal_enable, True)
221
+ add_config_if_not_exist(ConfigEnum.mux_brutal_enable, False)
195
222
  add_config_if_not_exist(ConfigEnum.mux_brutal_up_mbps, '100')
196
223
  add_config_if_not_exist(ConfigEnum.mux_brutal_down_mbps, '100')
197
224
 
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, hutils.random.get_random_unused_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, hutils.random.get_random_string())
223
- add_config_if_not_exist(ConfigEnum.proxy_path_client, hutils.random.get_random_string())
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, hutils.random.get_random_unused_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_(["tuic", "hysteria2", "hysteria"])).delete()
254
- db.session.add(Proxy(l3='tls', transport='custom', cdn='direct', proto='tuic', enable=True, name="TUIC"))
255
- db.session.add(Proxy(l3='tls', transport='custom', cdn='direct', proto='hysteria2', enable=True, name="Hysteria2"))
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(StrConfig.key == ConfigEnum.ssh_server_enable).delete()
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', cdn='direct', proto='ssh', enable=True, name="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, hutils.random.get_random_unused_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(ConfigEnum.warp_enable) else "disable")
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, uuid.uuid4().hex[0:random.randint(1, 8) * 2])
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(ConfigEnum.reality_private_key, key_pair['private_key'])
335
- add_config_if_not_exist(ConfigEnum.reality_public_key, key_pair['public_key'])
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(ConfigEnum.admin_secret), name="Owner", mode=AdminMode.super_admin, comment=""))
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(Domain.mode in [DomainType.direct, DomainType.relay]).first()
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(domain=fd, mode='fake', alias='moved from domain fronting', cdn_ip=direct_host))
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(ConfigEnum.shadowtls_fakedomain, "en.wikipedia.org")
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, package_days=3650, mode=UserMode.weekly),
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, value=hutils.network.get_random_decoy_domain()),
426
- StrConfig(key=ConfigEnum.proxy_path, value=hutils.random.get_random_string()),
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(Proxy.name == 'tls XTLSVision direct trojan').delete()
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")
@@ -522,9 +571,9 @@ def get_proxy_rows_v1():
522
571
  "httpupgrade direct vless",
523
572
  # "httpupgrade direct trojan",
524
573
  "httpupgrade direct vmess",
525
- "splithttp direct vless",
526
- "splithttp direct trojan",
527
- "splithttp direct vmess",
574
+ "xhttp direct vless",
575
+ "xhttp direct trojan",
576
+ "xhttp direct vmess",
528
577
  "tcp direct vless",
529
578
  "tcp direct trojan",
530
579
  "tcp direct vmess",
@@ -542,9 +591,9 @@ def get_proxy_rows_v1():
542
591
  # "httpupgrade relay trojan",
543
592
  "httpupgrade relay vmess",
544
593
 
545
- "splithttp relay vless",
546
- "splithttp relay trojan",
547
- "splithttp relay vmess",
594
+ "xhttp relay vless",
595
+ "xhttp relay trojan",
596
+ "xhttp relay vmess",
548
597
 
549
598
  "tcp relay vless",
550
599
  "tcp relay trojan",
@@ -566,9 +615,9 @@ def get_proxy_rows_v1():
566
615
  # "httpupgrade CDN trojan",
567
616
  "httpupgrade CDN vmess",
568
617
 
569
- "splithttp CDN vless",
570
- "splithttp CDN trojan",
571
- "splithttp CDN vmess",
618
+ "xhttp CDN vless",
619
+ "xhttp CDN trojan",
620
+ "xhttp CDN vmess",
572
621
 
573
622
  "grpc CDN vless",
574
623
  "grpc CDN trojan",
@@ -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, cdn='direct', proto='ss', enable=True, name="ShadowSocks2022"))
580
- rows.append(Proxy(l3=ProxyL3.custom, transport=ProxyTransport.shadowsocks, cdn='relay', proto='ss', enable=True, name="ShadowSocks2022 Relay"))
581
-
582
- rows.append(Proxy(l3=ProxyL3.tls, transport=ProxyTransport.shadowtls, cdn='direct', proto='ss', enable=True, name="ShadowTLS"))
583
- rows.append(Proxy(l3=ProxyL3.tls, transport=ProxyTransport.shadowtls, cdn='relay', proto='ss', enable=True, name="ShadowTLS Relay"))
584
- rows.append(Proxy(l3='ssh', transport='ssh', cdn='direct', proto='ssh', enable=True, name="SSH"))
585
- rows.append(Proxy(l3='ssh', transport=ProxyTransport.ssh, cdn=ProxyCDN.relay, proto=ProxyProto.ssh, enable=True, name="SSH Relay"))
586
-
587
- rows.append(Proxy(l3='tls', transport='custom', cdn='direct', proto='tuic', enable=True, name="TUIC"))
588
- rows.append(Proxy(l3='tls', transport='custom', cdn='relay', proto='tuic', enable=True, name="TUIC Relay"))
589
- rows.append(Proxy(l3='tls', transport='custom', cdn='direct', proto='hysteria2', enable=True, name="Hysteria2"))
590
- rows.append(Proxy(l3='tls', transport='custom', cdn='relay', proto='hysteria2', enable=True, name="Hysteria2 Relay"))
591
- rows.append(Proxy(l3=ProxyL3.udp, transport=ProxyTransport.custom, cdn=ProxyCDN.direct, proto=ProxyProto.wireguard, enable=True, name="WireGuard"))
592
- rows.append(Proxy(l3=ProxyL3.udp, transport=ProxyTransport.custom, cdn=ProxyCDN.relay, proto=ProxyProto.wireguard, enable=True, name="WireGuard Relay"))
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()
@@ -602,7 +663,7 @@ def make_proxy_rows(cfgs):
602
663
  for l3 in [ProxyL3.h3_quic, "tls_h2", "tls", "http", "reality"]:
603
664
  for c in cfgs:
604
665
  transport, cdn, proto = c.split(" ")
605
- if transport != ProxyTransport.splithttp and l3 == ProxyL3.h3_quic:
666
+ if transport != ProxyTransport.xhttp and l3 == ProxyL3.h3_quic:
606
667
  continue
607
668
  if l3 in ["kcp", 'reality'] and cdn != "direct":
608
669
  continue
@@ -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(f'ALTER TABLE {column.table.name} ADD COLUMN {column.name} {column_type}', commit=True)
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(e, ConfigEnum) else e.value for e in enum_class]
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(text(f"SHOW COLUMNS FROM {table_name} LIKE '{column_name}';")).fetchall()
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:
@@ -686,9 +750,13 @@ def add_new_enum_values():
686
750
  continue
687
751
 
688
752
  # Add the new value to the enum column in the database
689
- enumstr = ','.join([f"'{a}'" for a in [*existing_values, *old_values]])
690
-
691
- db_execute(f"ALTER TABLE {table_name} MODIFY COLUMN `{column_name}` ENUM({enumstr});", commit=True)
753
+ # enumstr = ','.join([f"'{a}'" for a in [*existing_values, *old_values]])
754
+ enumstr = ','.join([f"'{a}'" for a in [*existing_values]])
755
+ expired_enumstr = ','.join([f"'{a}'" for a in [*old_values]])
756
+ db_execute(
757
+ f"delete from {table_name} where `{column_name}` in ({expired_enumstr});", commit=True)
758
+ db_execute(
759
+ f"ALTER TABLE {table_name} MODIFY COLUMN `{column_name}` ENUM({enumstr});", commit=True)
692
760
 
693
761
 
694
762
  def latest_db_version():
@@ -710,7 +778,8 @@ def upgrade_database():
710
778
  logger.info("no backup found...")
711
779
  return
712
780
  if os.path.isfile(sqlite_db):
713
- logger.info("Finding Old Version Database... importing configs from latest backup")
781
+ logger.info(
782
+ "Finding Old Version Database... importing configs from latest backup")
714
783
  newest_file = max([(f, os.path.getmtime(os.path.join(backup_root, f)))
715
784
  for f in os.listdir(backup_root) if os.path.isfile(os.path.join(backup_root, f))], key=lambda x: x[1])[0]
716
785
  with open(f'{backup_root}{newest_file}', 'r') as f:
@@ -728,7 +797,8 @@ def upgrade_database():
728
797
  override_child_unique_id=0,
729
798
  replace_owner_admin=True
730
799
  )
731
- db_version = int([d['value'] for d in json_data['hconfigs'] if d['key'] == "db_version"][0])
800
+ db_version = int(
801
+ [d['value'] for d in json_data['hconfigs'] if d['key'] == "db_version"][0])
732
802
  os.rename(sqlite_db, sqlite_db + ".old")
733
803
  set_hconfig(ConfigEnum.db_version, db_version, commit=True)
734
804
 
@@ -765,7 +835,8 @@ def init_db():
765
835
  if not db_action or (start_version == 0 and ver == 10):
766
836
  continue
767
837
 
768
- logger.info(f"Updating db from version {db_version} for node {child.id}")
838
+ logger.info(
839
+ f"Updating db from version {db_version} for node {child.id}")
769
840
 
770
841
  if ver < 70:
771
842
  if child.id != 0:
@@ -775,11 +846,13 @@ def init_db():
775
846
  db_action(child.id)
776
847
 
777
848
  Events.db_init_event.notify(db_version=db_version)
778
- logger.info(f"Updated successfuly db from version {db_version} to {ver}")
849
+ logger.info(
850
+ f"Updated successfuly db from version {db_version} to {ver}")
779
851
 
780
852
  db_version = ver
781
853
  db.session.commit()
782
- set_hconfig(ConfigEnum.db_version, db_version, child_id=child.id, commit=False)
854
+ set_hconfig(ConfigEnum.db_version, db_version,
855
+ child_id=child.id, commit=False)
783
856
 
784
857
  db.session.commit()
785
858
  g.child = Child.by_id(0)
@@ -791,11 +864,14 @@ def migrate(db_version):
791
864
  for column in table_obj.columns:
792
865
  add_column(column)
793
866
  Events.db_prehook.notify()
867
+ if db_version < 97:
868
+ execute('ALTER TABLE str_config MODIFY value VARCHAR(3072);')
794
869
  if db_version < 82:
795
870
  execute('ALTER TABLE child DROP INDEX `name`;')
796
871
  if db_version < 77:
797
872
  execute('ALTER TABLE user_detail DROP COLUMN connected_ips;')
798
- execute('update user_detail set connected_devices="" where connected_devices IS NULL')
873
+ execute(
874
+ 'update user_detail set connected_devices="" where connected_devices IS NULL')
799
875
 
800
876
  if db_version < 70:
801
877
  execute('CREATE INDEX date ON daily_usage (date);')
@@ -827,7 +903,8 @@ def migrate(db_version):
827
903
 
828
904
  if db_version < 52:
829
905
  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(f'update domain set mode="direct", sub_link_only=false where mode=0 or mode="0"')
906
+ execute(
907
+ f'update domain set mode="direct", sub_link_only=false where mode=0 or mode="0"')
831
908
  execute(f'update proxy set transport="WS" where transport = "ws"')
832
909
  execute(f'update admin_user set mode="agent" where mode = "slave"')
833
910
  execute(f'update admin_user set mode="super_admin" where id=1')
@@ -867,9 +944,12 @@ def migrate(db_version):
867
944
  execute(f'DROP TABLE str_config')
868
945
  execute(f'ALTER TABLE str_config_old RENAME TO str_config')
869
946
 
870
- execute('ALTER TABLE user RENAME COLUMN monthly_usage_limit_GB TO usage_limit_GB')
871
- execute(f'update admin_user set parent_admin_id=1 where parent_admin_id is NULL and 1!=id')
872
- execute(f'update admin_user set max_users=100,max_active_users=100 where max_users is NULL')
947
+ execute(
948
+ 'ALTER TABLE user RENAME COLUMN monthly_usage_limit_GB TO usage_limit_GB')
949
+ execute(
950
+ f'update admin_user set parent_admin_id=1 where parent_admin_id is NULL and 1!=id')
951
+ execute(
952
+ f'update admin_user set max_users=100,max_active_users=100 where max_users is NULL')
873
953
  execute(f'update dailyusage set child_id=0 where child_id is NULL')
874
954
  execute(f'update dailyusage set admin_id=1 where admin_id is NULL')
875
955
  execute(f'update dailyusage set admin_id=1 where admin_id = 0')
@@ -0,0 +1,9 @@
1
+ from flask import Flask
2
+
3
+
4
+
5
+
6
+ from . import test_pb2_grpc
7
+ from .hello import HelloServicer
8
+ def init_app(app:Flask):
9
+ test_pb2_grpc.add_HelloServicer_to_server(HelloServicer(),app.wsgi_app)
@@ -0,0 +1,14 @@
1
+ import asyncio
2
+ from . import test_pb2_grpc
3
+ import sonora.aio
4
+ from .test_pb2 import HelloRequest
5
+
6
+
7
+ async def temp():
8
+ async with sonora.aio.insecure_web_channel(f"http://localhost:9000") as channel:
9
+ stub = test_pb2_grpc.HelloStub(channel)
10
+ print(await stub.SayHello(HelloRequest(req="F")))
11
+
12
+
13
+
14
+ asyncio.run(temp())
@@ -0,0 +1,14 @@
1
+ import grpc
2
+
3
+ # from hiddifypanel.hasync.config import BoolConfig
4
+ from hiddifypanel.models.config import hconfig
5
+ from hiddifypanel.models.config_enum import ConfigEnum
6
+ from . import test_pb2
7
+ from . import test_pb2_grpc
8
+
9
+ class HelloServicer(test_pb2_grpc.HelloServicer):
10
+ """Missing associated documentation comment in .proto file."""
11
+
12
+ def SayHello(self, request: test_pb2.HelloRequest, context) -> test_pb2.HelloResponse:
13
+
14
+ return test_pb2.HelloResponse(res=hconfig(ConfigEnum.log_level))
@@ -0,0 +1,13 @@
1
+ syntax = "proto3";
2
+
3
+ message HelloRequest {
4
+ string req = 1;
5
+ }
6
+
7
+ message HelloResponse {
8
+ string res = 1;
9
+ }
10
+
11
+ service Hello {
12
+ rpc SayHello (HelloRequest) returns (HelloResponse);
13
+ }
@@ -0,0 +1,40 @@
1
+ # Generated by the Protocol Buffers compiler. DO NOT EDIT!
2
+ # source: hiddifypanel/async/node/test.proto
3
+ # plugin: grpclib.plugin.main
4
+ import abc
5
+ import typing
6
+
7
+ import grpclib.const
8
+ import grpclib.client
9
+ if typing.TYPE_CHECKING:
10
+ import grpclib.server
11
+
12
+ import hiddifypanel.hasync.node.test_pb2
13
+
14
+
15
+ class HelloBase(abc.ABC):
16
+
17
+ @abc.abstractmethod
18
+ async def SayHello(self, stream: 'grpclib.server.Stream[hiddifypanel.hasync.node.test_pb2.HelloRequest, hiddifypanel.hasync.node.test_pb2.HelloResponse]') -> None:
19
+ pass
20
+
21
+ def __mapping__(self) -> typing.Dict[str, grpclib.const.Handler]:
22
+ return {
23
+ '/Hello/SayHello': grpclib.const.Handler(
24
+ self.SayHello,
25
+ grpclib.const.Cardinality.UNARY_UNARY,
26
+ hiddifypanel.hasync.node.test_pb2.HelloRequest,
27
+ hiddifypanel.hasync.node.test_pb2.HelloResponse,
28
+ ),
29
+ }
30
+
31
+
32
+ class HelloStub:
33
+
34
+ def __init__(self, channel: grpclib.client.Channel) -> None:
35
+ self.SayHello = grpclib.client.UnaryUnaryMethod(
36
+ channel,
37
+ '/Hello/SayHello',
38
+ hiddifypanel.hasync.node.test_pb2.HelloRequest,
39
+ hiddifypanel.hasync.node.test_pb2.HelloResponse,
40
+ )
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: hiddifypanel/panel/node/test.proto
5
+ # Protobuf Python Version: 5.27.2
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 5,
15
+ 27,
16
+ 2,
17
+ '',
18
+ 'hiddifypanel/panel/node/test.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\"hiddifypanel/panel/node/test.proto\"\x1b\n\x0cHelloRequest\x12\x0b\n\x03req\x18\x01 \x01(\t\"\x1c\n\rHelloResponse\x12\x0b\n\x03res\x18\x01 \x01(\t22\n\x05Hello\x12)\n\x08SayHello\x12\r.HelloRequest\x1a\x0e.HelloResponseb\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'hiddifypanel.panel.node.test_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ DESCRIPTOR._loaded_options = None
34
+ _globals['_HELLOREQUEST']._serialized_start=38
35
+ _globals['_HELLOREQUEST']._serialized_end=65
36
+ _globals['_HELLORESPONSE']._serialized_start=67
37
+ _globals['_HELLORESPONSE']._serialized_end=95
38
+ _globals['_HELLO']._serialized_start=97
39
+ _globals['_HELLO']._serialized_end=147
40
+ # @@protoc_insertion_point(module_scope)