hiddifypanel 9.0.0.dev54__py3-none-any.whl → 9.0.0.dev61__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 (72) hide show
  1. hiddifypanel/VERSION +1 -1
  2. hiddifypanel/VERSION.py +2 -2
  3. hiddifypanel/base.py +5 -4
  4. hiddifypanel/hutils/__init__.py +8 -1
  5. hiddifypanel/hutils/auth.py +94 -0
  6. hiddifypanel/hutils/auto_ip_selector.py +1 -1
  7. hiddifypanel/hutils/convert.py +14 -0
  8. hiddifypanel/hutils/encode.py +11 -0
  9. hiddifypanel/hutils/flask.py +24 -0
  10. hiddifypanel/{panel/github_issue_generator.py → hutils/github_issue.py} +104 -14
  11. hiddifypanel/hutils/json.py +24 -0
  12. hiddifypanel/hutils/random.py +19 -0
  13. hiddifypanel/hutils/utils.py +0 -161
  14. hiddifypanel/models/__init__.py +1 -0
  15. hiddifypanel/models/admin.py +53 -8
  16. hiddifypanel/models/base_account.py +31 -169
  17. hiddifypanel/models/config_enum.py +23 -1
  18. hiddifypanel/models/domain.py +2 -2
  19. hiddifypanel/models/parent_domain.py +1 -0
  20. hiddifypanel/models/user.py +105 -33
  21. hiddifypanel/models/utils.py +3 -3
  22. hiddifypanel/panel/admin/Actions.py +5 -6
  23. hiddifypanel/panel/admin/AdminstratorAdmin.py +1 -1
  24. hiddifypanel/panel/admin/Backup.py +5 -5
  25. hiddifypanel/panel/admin/ChildAdmin.py +3 -3
  26. hiddifypanel/panel/admin/Dashboard.py +12 -10
  27. hiddifypanel/panel/admin/DomainAdmin.py +10 -9
  28. hiddifypanel/panel/admin/ProxyAdmin.py +4 -6
  29. hiddifypanel/panel/admin/QuickSetup.py +11 -13
  30. hiddifypanel/panel/admin/SettingAdmin.py +20 -10
  31. hiddifypanel/panel/admin/UserAdmin.py +14 -12
  32. hiddifypanel/panel/auth.py +43 -10
  33. hiddifypanel/panel/auth_back2.py +5 -5
  34. hiddifypanel/panel/cli.py +1 -0
  35. hiddifypanel/panel/commercial/ParentDomainAdmin.py +3 -3
  36. hiddifypanel/panel/commercial/ProxyDetailsAdmin.py +1 -0
  37. hiddifypanel/panel/commercial/restapi/v1/tgbot.py +1 -2
  38. hiddifypanel/panel/commercial/restapi/v1/tgmsg.py +37 -29
  39. hiddifypanel/panel/commercial/restapi/v2/user/apps_api.py +5 -4
  40. hiddifypanel/panel/commercial/restapi/v2/user/configs_api.py +15 -7
  41. hiddifypanel/panel/commercial/restapi/v2/user/info_api.py +7 -11
  42. hiddifypanel/panel/commercial/telegrambot/Usage.py +2 -1
  43. hiddifypanel/panel/commercial/telegrambot/admin.py +1 -0
  44. hiddifypanel/panel/common.py +12 -89
  45. hiddifypanel/panel/common_bp/login.py +12 -12
  46. hiddifypanel/panel/database.py +22 -21
  47. hiddifypanel/panel/hiddify.py +27 -29
  48. hiddifypanel/panel/importer/xui.py +2 -2
  49. hiddifypanel/panel/init_db.py +32 -13
  50. hiddifypanel/panel/usage.py +2 -1
  51. hiddifypanel/panel/user/link_maker.py +118 -15
  52. hiddifypanel/panel/user/templates/new.html +4 -2
  53. hiddifypanel/panel/user/user.py +83 -38
  54. hiddifypanel/static/new/assets/{index-bd9ba5e9.js → index-2cd90979.js} +1 -1
  55. hiddifypanel/templates/fake.html +2 -2
  56. hiddifypanel/templates/master.html +1 -1
  57. hiddifypanel/translations/en/LC_MESSAGES/messages.mo +0 -0
  58. hiddifypanel/translations/en/LC_MESSAGES/messages.po +317 -189
  59. hiddifypanel/translations/fa/LC_MESSAGES/messages.mo +0 -0
  60. hiddifypanel/translations/fa/LC_MESSAGES/messages.po +346 -206
  61. hiddifypanel/translations/pt/LC_MESSAGES/messages.mo +0 -0
  62. hiddifypanel/translations/pt/LC_MESSAGES/messages.po +315 -195
  63. hiddifypanel/translations/ru/LC_MESSAGES/messages.mo +0 -0
  64. hiddifypanel/translations/ru/LC_MESSAGES/messages.po +315 -195
  65. hiddifypanel/translations/zh/LC_MESSAGES/messages.mo +0 -0
  66. hiddifypanel/translations/zh/LC_MESSAGES/messages.po +866 -2739
  67. {hiddifypanel-9.0.0.dev54.dist-info → hiddifypanel-9.0.0.dev61.dist-info}/METADATA +2 -1
  68. {hiddifypanel-9.0.0.dev54.dist-info → hiddifypanel-9.0.0.dev61.dist-info}/RECORD +72 -66
  69. {hiddifypanel-9.0.0.dev54.dist-info → hiddifypanel-9.0.0.dev61.dist-info}/LICENSE.md +0 -0
  70. {hiddifypanel-9.0.0.dev54.dist-info → hiddifypanel-9.0.0.dev61.dist-info}/WHEEL +0 -0
  71. {hiddifypanel-9.0.0.dev54.dist-info → hiddifypanel-9.0.0.dev61.dist-info}/entry_points.txt +0 -0
  72. {hiddifypanel-9.0.0.dev54.dist-info → hiddifypanel-9.0.0.dev61.dist-info}/top_level.txt +0 -0
@@ -1,19 +1,22 @@
1
+ import user_agents
2
+ import datetime
3
+ import random
4
+ import re
1
5
 
2
- from flask import redirect, render_template, request, Response, g, url_for, jsonify, flash
6
+ from flask import render_template, request, Response, g
3
7
  from apiflask import abort
4
- from hiddifypanel.hutils import auto_ip_selector
5
- import datetime
6
- from hiddifypanel.models import *
7
- from hiddifypanel.panel.database import db
8
- from hiddifypanel.panel import hiddify
9
8
  from . import link_maker
10
9
  from flask_classful import FlaskView, route
11
- import random
12
10
  from urllib.parse import urlparse
13
- import user_agents
14
11
  from flask_babelex import gettext as _
15
- import re
12
+
13
+
16
14
  from hiddifypanel.panel.auth import login_required
15
+ from hiddifypanel.hutils import auto_ip_selector
16
+ from hiddifypanel.panel.database import db
17
+ from hiddifypanel.panel import hiddify
18
+ from hiddifypanel.models import *
19
+ from hiddifypanel import hutils
17
20
 
18
21
 
19
22
  class UserView(FlaskView):
@@ -24,7 +27,7 @@ class UserView(FlaskView):
24
27
  ua = request.user_agent.string
25
28
  print(ua)
26
29
  print(hiddify.get_user_agent())
27
- return ua, 400
30
+ return ua
28
31
 
29
32
  def index(self):
30
33
  return self.auto_sub()
@@ -34,12 +37,65 @@ class UserView(FlaskView):
34
37
  return self.new()
35
38
  return self.get_proper_config() or self.all_configs(base64=True)
36
39
 
37
- @route('/sub')
38
- @route('/sub/')
40
+ # former /sub/ or /sub (it was auto actually but we named it as /sub/)
41
+ # TODO: @hiddify: check this out
42
+ @route('/auto/')
43
+ @route('/auto')
39
44
  @login_required(roles={Role.user})
40
45
  def force_sub(self):
41
46
  return self.get_proper_config() or self.all_configs(base64=False)
42
47
 
48
+ # region new endpoints
49
+ @route("/sub/")
50
+ @route("/sub")
51
+ @login_required(roles={Role.user})
52
+ def sub(self):
53
+ return self.all_configs(base64=False)
54
+
55
+ @route("/sub64/")
56
+ @route("/sub64")
57
+ @login_required(roles={Role.user})
58
+ def sub64(self):
59
+ return self.all_configs(base64=True)
60
+
61
+ @route("/singbox/")
62
+ @route("/singbox")
63
+ @login_required(roles={Role.user})
64
+ def singbox_full(self):
65
+ return self.full_singbox()
66
+
67
+ @route("/singbox-ssh/")
68
+ @route("/singbox-ssh")
69
+ @login_required(roles={Role.user})
70
+ def singbox_ssh(self):
71
+ return self.singbox()
72
+
73
+ @route("/clash/")
74
+ @route("/clash")
75
+ @login_required(roles={Role.user})
76
+ def clash(self):
77
+ return self.clash_config(meta_or_normal="normal")
78
+
79
+ @route("/clashmeta/")
80
+ @route("/clashmeta")
81
+ @login_required(roles={Role.user})
82
+ def clashmeta(self):
83
+ return self.clash_config(meta_or_normal="meta")
84
+ # endregion
85
+
86
+ @ route('/new/')
87
+ @ route('/new')
88
+ @login_required(roles={Role.user})
89
+ def new(self):
90
+ conf = self.get_proper_config()
91
+ if conf:
92
+ return conf
93
+
94
+ c = get_common_data(g.account.uuid, mode="new")
95
+ user_agent = user_agents.parse(request.user_agent.string)
96
+ # return render_template('home/multi.html', **c, ua=user_agent)
97
+ return render_template('new.html', **c, ua=user_agent)
98
+
43
99
  def get_proper_config(self):
44
100
  if g.user_agent['is_browser']:
45
101
  return None
@@ -59,20 +115,6 @@ class UserView(FlaskView):
59
115
  if re.match('^(Hiddify|FoXray|Fair|v2rayNG|SagerNet|Shadowrocket|V2Box|Loon|Liberty)', ua, re.IGNORECASE):
60
116
  return self.all_configs(base64=True)
61
117
 
62
- @ route('/new/')
63
- @ route('/new')
64
- @login_required(roles={Role.user})
65
- # @ route('/')
66
- def new(self):
67
- conf = self.get_proper_config()
68
- if conf:
69
- return conf
70
-
71
- c = get_common_data(g.account.uuid, mode="new")
72
- user_agent = user_agents.parse(request.user_agent.string)
73
- # return render_template('home/multi.html', **c, ua=user_agent)
74
- return render_template('new.html', **c, ua=user_agent)
75
-
76
118
  @ route('/clash/<meta_or_normal>/proxies.yml')
77
119
  @ route('/clash/proxies.yml')
78
120
  @login_required(roles={Role.user})
@@ -90,6 +132,9 @@ class UserView(FlaskView):
90
132
  @ route('/report', methods=["POST"])
91
133
  @login_required(roles={Role.user})
92
134
  def report(self):
135
+
136
+ # THE REPORT MODEL IS NOT COMPLETED YET.
137
+
93
138
  data = request.get_json()
94
139
  user_ip = auto_ip_selector.get_real_user_ip()
95
140
  report = Report()
@@ -178,15 +223,15 @@ class UserView(FlaskView):
178
223
  if request.method == 'HEAD':
179
224
  resp = ""
180
225
  else:
181
- # render_template('all_configs.txt', **c, base64=do_base_64)
226
+ # render_template('all_configs.txt', **c, base64=hutils.encode.do_base_64)
182
227
  resp = link_maker.make_v2ray_configs(**c)
183
228
 
184
229
  if base64:
185
- resp = do_base_64(resp)
230
+ resp = hutils.encode.do_base_64(resp)
186
231
  return add_headers(resp, c)
187
232
 
188
- @login_required(roles={Role.user})
189
233
  @ route("/offline.html")
234
+ @login_required(roles={Role.user})
190
235
  def offline():
191
236
  return f"Not Connected <a href='{hiddify.get_account_panel_link(g.account, request.host)}'>click for reload</a>"
192
237
 
@@ -197,10 +242,10 @@ class UserView(FlaskView):
197
242
  return ""
198
243
 
199
244
 
200
- def do_base_64(str):
201
- import base64
202
- resp = base64.b64encode(f'{str}'.encode("utf-8"))
203
- return resp.decode()
245
+ # def do_base_64(str):
246
+ # import base64
247
+ # resp = base64.b64encode(f'{str}'.encode("utf-8"))
248
+ # return resp.decode()
204
249
 
205
250
 
206
251
  def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
@@ -224,7 +269,7 @@ def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
224
269
 
225
270
  if not db_domain:
226
271
  db_domain = DB(domain=domain, show_domains=[])
227
- flash(_("This domain does not exist in the panel!" + domain))
272
+ hutils.flask.flash(_("This domain does not exist in the panel!" + domain))
228
273
 
229
274
  if mode == 'multi':
230
275
  domains = Domain.query.all()
@@ -262,7 +307,7 @@ def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
262
307
  d.cdn_ip, d.mode == DomainType.auto_cdn_ip, default_asn)
263
308
  # print("autocdn ip mode ", d.cdn_ip)
264
309
  if "*" in d.domain:
265
- d.domain = d.domain.replace("*", hiddify.get_random_string(5, 15))
310
+ d.domain = d.domain.replace("*", hutils.random.get_random_string(5, 15))
266
311
 
267
312
  package_mode_dic = {
268
313
  UserMode.daily: 1,
@@ -307,7 +352,7 @@ def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
307
352
  'ConfigEnum': ConfigEnum,
308
353
  'link_maker': link_maker,
309
354
  'domains': domains,
310
- "bot": g.bot,
355
+ "bot": g.get('bot', None),
311
356
  "db_domain": db_domain,
312
357
  "telegram_enable": hconfig(ConfigEnum.telegram_enable) and any([d for d in domains if d.mode in [DomainType.direct, DomainType.relay, DomainType.old_xtls_direct]]),
313
358
  "ip": user_ip,
@@ -315,7 +360,7 @@ def get_common_data(user_uuid, mode, no_domain=False, filter_domain=None):
315
360
  "asn": asn,
316
361
  "country": auto_ip_selector.get_country(user_ip),
317
362
  'has_auto_cdn': has_auto_cdn,
318
- 'profile_url': hiddify.get_account_panel_link(g.account, domain)
363
+ 'profile_url': hiddify.get_account_panel_link(user, domain)
319
364
  }
320
365
 
321
366
 
@@ -330,6 +375,6 @@ def add_headers(res, c):
330
375
  resp.headers['profile-update-interval'] = 1
331
376
  # resp.headers['content-disposition']=f'attachment; filename="{c["db_domain"].alias or c["db_domain"].domain} {c["user"].name}"'
332
377
 
333
- resp.headers['profile-title'] = 'base64:'+do_base_64(c['profile_title'])
378
+ resp.headers['profile-title'] = 'base64:'+hutils.encode.do_base_64(c['profile_title'])
334
379
 
335
380
  return resp