hiddifypanel 9.0.0.dev32__py3-none-any.whl → 9.0.0.dev33__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 (47) hide show
  1. hiddifypanel/VERSION +1 -1
  2. hiddifypanel/VERSION.py +1 -1
  3. hiddifypanel/models/__init__.py +4 -3
  4. hiddifypanel/models/config.py +5 -5
  5. hiddifypanel/models/parent_domain.py +27 -27
  6. hiddifypanel/models/proxy.py +32 -30
  7. hiddifypanel/models/usage.py +71 -71
  8. hiddifypanel/panel/admin/Actions.py +5 -6
  9. hiddifypanel/panel/admin/AdminstratorAdmin.py +6 -6
  10. hiddifypanel/panel/admin/Backup.py +5 -5
  11. hiddifypanel/panel/admin/ChildAdmin.py +1 -2
  12. hiddifypanel/panel/admin/Dashboard.py +4 -5
  13. hiddifypanel/panel/admin/DomainAdmin.py +1 -1
  14. hiddifypanel/panel/admin/QuickSetup.py +1 -9
  15. hiddifypanel/panel/admin/UserAdmin.py +5 -5
  16. hiddifypanel/panel/admin/templates/parent_dash.html +1 -2
  17. hiddifypanel/panel/admin/templates/result.html +5 -3
  18. hiddifypanel/panel/cli.py +10 -32
  19. hiddifypanel/panel/commercial/ParentDomainAdmin.py +1 -1
  20. hiddifypanel/panel/commercial/restapi/v2/admin/server_status_api.py +5 -5
  21. hiddifypanel/panel/commercial/restapi/v2/user/info_api.py +2 -3
  22. hiddifypanel/panel/commercial/restapi/v2/user/short_api.py +2 -3
  23. hiddifypanel/panel/commercial/telegrambot/Usage.py +1 -1
  24. hiddifypanel/panel/commercial/templates/parent_dash.html +1 -1
  25. hiddifypanel/panel/common.py +3 -3
  26. hiddifypanel/panel/hiddify.py +33 -35
  27. hiddifypanel/panel/user/templates/new.html +2 -3
  28. hiddifypanel/panel/user/user.py +5 -193
  29. hiddifypanel/static/css/custom.css +5 -0
  30. hiddifypanel/static/new/assets/index-c4c80da4.js +1 -1
  31. hiddifypanel/templates/master.html +3 -2
  32. hiddifypanel/translations/en/LC_MESSAGES/messages.mo +0 -0
  33. hiddifypanel/translations/en/LC_MESSAGES/messages.po +90 -94
  34. hiddifypanel/translations/fa/LC_MESSAGES/messages.mo +0 -0
  35. hiddifypanel/translations/fa/LC_MESSAGES/messages.po +97 -94
  36. hiddifypanel/translations/pt/LC_MESSAGES/messages.mo +0 -0
  37. hiddifypanel/translations/pt/LC_MESSAGES/messages.po +103 -99
  38. hiddifypanel/translations/ru/LC_MESSAGES/messages.mo +0 -0
  39. hiddifypanel/translations/ru/LC_MESSAGES/messages.po +102 -98
  40. hiddifypanel/translations/zh/LC_MESSAGES/messages.mo +0 -0
  41. hiddifypanel/translations/zh/LC_MESSAGES/messages.po +91 -93
  42. {hiddifypanel-9.0.0.dev32.dist-info → hiddifypanel-9.0.0.dev33.dist-info}/METADATA +1 -1
  43. {hiddifypanel-9.0.0.dev32.dist-info → hiddifypanel-9.0.0.dev33.dist-info}/RECORD +47 -47
  44. {hiddifypanel-9.0.0.dev32.dist-info → hiddifypanel-9.0.0.dev33.dist-info}/LICENSE.md +0 -0
  45. {hiddifypanel-9.0.0.dev32.dist-info → hiddifypanel-9.0.0.dev33.dist-info}/WHEEL +0 -0
  46. {hiddifypanel-9.0.0.dev32.dist-info → hiddifypanel-9.0.0.dev33.dist-info}/entry_points.txt +0 -0
  47. {hiddifypanel-9.0.0.dev32.dist-info → hiddifypanel-9.0.0.dev33.dist-info}/top_level.txt +0 -0
hiddifypanel/VERSION CHANGED
@@ -1 +1 @@
1
- 9.0.0.dev32
1
+ 9.0.0.dev33
hiddifypanel/VERSION.py CHANGED
@@ -1,3 +1,3 @@
1
- __version__='9.0.0.dev32'
1
+ __version__='9.0.0.dev33'
2
2
  from datetime import datetime
3
3
  __release_date__= datetime.strptime('2024-01-09','%Y-%m-%d')
@@ -2,10 +2,11 @@ from .role import Role, AccountType
2
2
  from .config_enum import ConfigCategory, ConfigEnum, Lang
3
3
  from .config import StrConfig, BoolConfig, get_hconfigs, hconfig, set_hconfig, add_or_update_config, bulk_register_configs
4
4
 
5
- from .parent_domain import ParentDomain, add_or_update_parent_domains, bulk_register_parent_domains
5
+ from .parent_domain import ParentDomain
6
6
  from .domain import Domain, DomainType, ShowDomain, get_domain, get_current_proxy_domains, get_panel_domains, get_proxy_domains, get_proxy_domains_db, get_hdomains, hdomain, add_or_update_domain, bulk_register_domains
7
- from .proxy import Proxy, ProxyL3, ProxyCDN, ProxyProto, ProxyTransport, add_or_update_proxy, bulk_register_proxies
7
+ from .proxy import Proxy, ProxyL3, ProxyCDN, ProxyProto, ProxyTransport
8
8
  from .user import User, UserMode, remove_user, UserDetail, ONE_GIG
9
9
  from .admin import AdminUser, AdminMode
10
10
  from .child import Child
11
- from .usage import DailyUsage, get_daily_usage_stats
11
+ from .usage import DailyUsage
12
+ from .base_account import BaseAccount
@@ -36,7 +36,7 @@ class StrConfig(db.Model, SerializerMixin):
36
36
 
37
37
 
38
38
  @cache.cache(ttl=500)
39
- def hconfig(key: ConfigEnum, child_id=0):
39
+ def hconfig(key: ConfigEnum, child_id: int = 0):
40
40
  value = None
41
41
  try:
42
42
  str_conf = StrConfig.query.filter(StrConfig.key == key, StrConfig.child_id == child_id).first()
@@ -61,7 +61,7 @@ def hconfig(key: ConfigEnum, child_id=0):
61
61
  return value
62
62
 
63
63
 
64
- def set_hconfig(key: ConfigEnum, value, child_id=0, commit=True):
64
+ def set_hconfig(key: ConfigEnum, value: str | bool, child_id: int = 0, commit: bool = True):
65
65
  # hconfig.invalidate(key, child_id)
66
66
  # get_hconfigs.invalidate(child_id)
67
67
  hconfig.invalidate(key, child_id)
@@ -94,7 +94,7 @@ def set_hconfig(key: ConfigEnum, value, child_id=0, commit=True):
94
94
 
95
95
 
96
96
  @cache.cache(ttl=500)
97
- def get_hconfigs(child_id=0):
97
+ def get_hconfigs(child_id: int = 0):
98
98
  return {**{u.key: u.value for u in BoolConfig.query.filter(BoolConfig.child_id == child_id).all()},
99
99
  **{u.key: u.value for u in StrConfig.query.filter(StrConfig.child_id == child_id).all()},
100
100
  # ConfigEnum.telegram_fakedomain:hdomain(DomainType.telegram_faketls),
@@ -103,7 +103,7 @@ def get_hconfigs(child_id=0):
103
103
  }
104
104
 
105
105
 
106
- def add_or_update_config(commit=True, child_id=0, override_unique_id=True, **config):
106
+ def add_or_update_config(commit: bool = True, child_id: int = 0, override_unique_id: bool = True, **config):
107
107
  c = config['key']
108
108
  ckey = ConfigEnum(c)
109
109
  if c == ConfigEnum.unique_id and not override_unique_id:
@@ -115,7 +115,7 @@ def add_or_update_config(commit=True, child_id=0, override_unique_id=True, **con
115
115
  set_hconfig(ckey, v, child_id, commit=commit)
116
116
 
117
117
 
118
- def bulk_register_configs(hconfigs, commit=True, override_child_id=None, override_unique_id=True):
118
+ def bulk_register_configs(hconfigs, commit: bool = True, override_child_id: int = None, override_unique_id: bool = True):
119
119
  from hiddifypanel.panel import hiddify
120
120
  for conf in hconfigs:
121
121
  # print(conf)
@@ -19,33 +19,33 @@ class ParentDomain(db.Model, SerializerMixin):
19
19
  backref=backref('parent_domains', lazy='dynamic')
20
20
  )
21
21
 
22
- def to_dict(d):
22
+ def to_dict(self):
23
23
  return {
24
- 'domain': d.domain,
25
- 'alias': d.alias,
26
- 'show_domains': [dd.domain for dd in d.show_domains]
24
+ 'domain': self.domain,
25
+ 'alias': self.alias,
26
+ 'show_domains': [dd.domain for dd in self.show_domains]
27
27
  }
28
28
 
29
-
30
- def add_or_update_parent_domains(commit=True, **parent_domain):
31
- dbdomain = ParentDomain.query.filter(ParentDomain.domain == parent_domain['domain']).first()
32
- if not dbdomain:
33
- dbdomain = ParentDomain(domain=parent_domain['domain'])
34
- db.session.add(dbdomain)
35
- show_domains = parent_domain.get('show_domains', [])
36
- dbdomain.show_domains = Domain.query.filter(Domain.domain.in_(show_domains)).all()
37
- dbdomain.alias = parent_domain.get('alias')
38
- if commit:
39
- db.session.commit()
40
-
41
-
42
- def bulk_register_parent_domains(parent_domains, commit=True, remove=False):
43
- for p in parent_domains:
44
- add_or_update_parent_domains(commit=False, **p)
45
- if remove:
46
- dd = {p.domain: 1 for p in parent_domains}
47
- for d in ParentDomain.query.all():
48
- if d.domain not in dd:
49
- db.session.delete(d)
50
- if commit:
51
- db.session.commit()
29
+ @staticmethod
30
+ def add_or_update(commit=True, **parent_domain):
31
+ dbdomain = ParentDomain.query.filter(ParentDomain.domain == parent_domain['domain']).first()
32
+ if not dbdomain:
33
+ dbdomain = ParentDomain(domain=parent_domain['domain'])
34
+ db.session.add(dbdomain)
35
+ show_domains = parent_domain.get('show_domains', [])
36
+ dbdomain.show_domains = Domain.query.filter(Domain.domain.in_(show_domains)).all()
37
+ dbdomain.alias = parent_domain.get('alias')
38
+ if commit:
39
+ db.session.commit()
40
+
41
+ @staticmethod
42
+ def bulk_register(parent_domains, commit=True, remove=False):
43
+ for p in parent_domains:
44
+ ParentDomain.add_or_update(commit=False, **p)
45
+ if remove:
46
+ dd = {p.domain: 1 for p in parent_domains}
47
+ for d in ParentDomain.query.all():
48
+ if d.domain not in dd:
49
+ db.session.delete(d)
50
+ if commit:
51
+ db.session.commit()
@@ -62,36 +62,38 @@ class Proxy(db.Model, SerializerMixin):
62
62
  transport = db.Column(db.Enum(ProxyTransport), nullable=False)
63
63
  cdn = db.Column(db.Enum(ProxyCDN), nullable=False)
64
64
 
65
- def to_dict(d):
65
+ def to_dict(self):
66
66
  return {
67
- 'name': d.name,
68
- 'enable': d.enable,
69
- 'proto': d.proto,
70
- 'l3': d.l3,
71
- 'transport': d.transport,
72
- 'cdn': d.cdn,
73
- 'child_unique_id': d.child.unique_id if d.child else ''
67
+ 'name': self.name,
68
+ 'enable': self.enable,
69
+ 'proto': self.proto,
70
+ 'l3': self.l3,
71
+ 'transport': self.transport,
72
+ 'cdn': self.cdn,
73
+ 'child_unique_id': self.child.unique_id if self.child else ''
74
74
  }
75
75
 
76
-
77
- def add_or_update_proxy(commit=True, child_id=0, **proxy):
78
- dbproxy = Proxy.query.filter(Proxy.name == proxy['name']).first()
79
- if not dbproxy:
80
- dbproxy = Proxy()
81
- db.session.add(dbproxy)
82
- dbproxy.enable = proxy['enable']
83
- dbproxy.name = proxy['name']
84
- dbproxy.proto = proxy['proto']
85
- dbproxy.transport = proxy['transport']
86
- dbproxy.cdn = proxy['cdn']
87
- dbproxy.l3 = proxy['l3']
88
- dbproxy.child_id = child_id
89
- if commit:
90
- db.session.commit()
91
-
92
-
93
- def bulk_register_proxies(proxies, commit=True, override_child_id=None):
94
- from hiddifypanel.panel import hiddify
95
- for proxy in proxies:
96
- child_id = override_child_id if override_child_id is not None else hiddify.get_child(proxy.get('child_unique_id', None))
97
- add_or_update_proxy(commit=False, child_id=child_id, **proxy)
76
+ @staticmethod
77
+ def add_or_update(commit=True, child_id=0, **proxy):
78
+ dbproxy = Proxy.query.filter(Proxy.name == proxy['name']).first()
79
+ if not dbproxy:
80
+ dbproxy = Proxy()
81
+ db.session.add(dbproxy)
82
+ dbproxy.enable = proxy['enable']
83
+ dbproxy.name = proxy['name']
84
+ dbproxy.proto = proxy['proto']
85
+ dbproxy.transport = proxy['transport']
86
+ dbproxy.cdn = proxy['cdn']
87
+ dbproxy.l3 = proxy['l3']
88
+ dbproxy.child_id = child_id
89
+ if commit:
90
+ db.session.commit()
91
+
92
+ @staticmethod
93
+ def bulk_register(proxies, commit=True, override_child_id=None):
94
+ from hiddifypanel.panel import hiddify
95
+ for proxy in proxies:
96
+ child_id = override_child_id if override_child_id is not None else hiddify.get_child(proxy.get('child_unique_id', None))
97
+ Proxy.add_or_update(commit=False, child_id=child_id, **proxy)
98
+ if commit:
99
+ db.session.commit()
@@ -19,74 +19,74 @@ class DailyUsage(db.Model, SerializerMixin):
19
19
  # def __str__(self):
20
20
  # return str([id,date,usage,online,admin_id,child_id])
21
21
 
22
-
23
- def get_daily_usage_stats(admin_id=None, child_id=None):
24
- from .admin import AdminUser
25
- if not admin_id:
26
- admin_id = g.account.id
27
- sub_admins = AdminUser.query.filter(AdminUser.id == admin_id).first().recursive_sub_admins_ids()
28
- # print(sub_admins)
29
-
30
- def filter_daily_usage_admin(query):
31
- # print('before',admin_id,query.all())
32
- if admin_id:
33
- query = query.filter(DailyUsage.admin_id.in_(sub_admins))
34
- if child_id:
35
- query = query.filter(DailyUsage.child_id == child_id)
36
- # print('after',admin_id,query.all())
37
- return query
38
-
39
- def filter_user_admin(query):
40
- if admin_id:
41
- query = query.filter(User.added_by.in_(sub_admins))
42
-
43
- return query
44
-
45
- from .user import User
46
- # Today's usage and online count
47
- today = date.today()
48
- today_stats = filter_daily_usage_admin(db.session.query(
49
- func.coalesce(func.sum(DailyUsage.usage), 0),
50
- func.coalesce(func.sum(DailyUsage.online), 0)
51
- ).filter(DailyUsage.date == today)).first()
52
- users_online_today = filter_user_admin(User.query.filter(User.last_online >= today)).count()
53
-
54
- h24 = datetime.datetime.now()-datetime.timedelta(days=1)
55
- users_online_h24 = filter_user_admin(User.query.filter(User.last_online >= h24)).count()
56
-
57
- m5 = datetime.datetime.now()-datetime.timedelta(minutes=5)
58
- users_online_m5 = filter_user_admin(User.query.filter(User.last_online >= m5)).count()
59
-
60
- # Yesterday's usage and online count
61
- yesterday = date.today() - timedelta(days=1)
62
- yesterday_stats = filter_daily_usage_admin(db.session.query(
63
- func.coalesce(func.sum(DailyUsage.usage), 0),
64
- func.coalesce(func.sum(DailyUsage.online), 0)
65
- ).filter(DailyUsage.date == yesterday)).first()
66
- # users_online_yesterday = User.query.filter(User.last_online >= yesterday, User.last_online < today).count()
67
- # Last 30 days' usage and online count
68
- last_30_days_start = date.today() - timedelta(days=30)
69
- last_30_days_stats = filter_daily_usage_admin(db.session.query(
70
- func.coalesce(func.sum(DailyUsage.usage), 0),
71
- func.coalesce(func.sum(DailyUsage.online), 0)
72
- ).filter(DailyUsage.date >= last_30_days_start)).first()
73
- users_online_last_month = filter_user_admin(User.query.filter(User.last_online >= last_30_days_start)).count()
74
-
75
- # Total usage and online count
76
- total_stats = filter_daily_usage_admin(db.session.query(
77
- func.coalesce(func.sum(DailyUsage.usage), 0),
78
- func.coalesce(func.sum(DailyUsage.online), 0)
79
- )).first()
80
- ten_years_ago = today - timedelta(days=365*10)
81
- users_online_last_10_years = filter_user_admin(User.query.filter(User.last_online >= ten_years_ago)).count()
82
- total_users = filter_user_admin(User.query).count()
83
-
84
- # Return the usage stats as a dictionary
85
- return {
86
- "today": {"usage": today_stats[0], "online": users_online_today},
87
- "h24": {"usage": 0, "online": users_online_h24},
88
- "m5": {"usage": 0, "online": users_online_m5},
89
- "yesterday": {"usage": yesterday_stats[0], "online": yesterday_stats[1]},
90
- "last_30_days": {"usage": last_30_days_stats[0], "online": users_online_last_month},
91
- "total": {"usage": total_stats[0], "online": users_online_last_10_years, "users": total_users}
92
- }
22
+ @staticmethod
23
+ def get_daily_usage_stats(admin_id=None, child_id=None):
24
+ from .admin import AdminUser
25
+ if not admin_id:
26
+ admin_id = g.account.id
27
+ sub_admins = AdminUser.query.filter(AdminUser.id == admin_id).first().recursive_sub_admins_ids()
28
+ # print(sub_admins)
29
+
30
+ def filter_daily_usage_admin(query):
31
+ # print('before',admin_id,query.all())
32
+ if admin_id:
33
+ query = query.filter(DailyUsage.admin_id.in_(sub_admins))
34
+ if child_id:
35
+ query = query.filter(DailyUsage.child_id == child_id)
36
+ # print('after',admin_id,query.all())
37
+ return query
38
+
39
+ def filter_user_admin(query):
40
+ if admin_id:
41
+ query = query.filter(User.added_by.in_(sub_admins))
42
+
43
+ return query
44
+
45
+ from .user import User
46
+ # Today's usage and online count
47
+ today = date.today()
48
+ today_stats = filter_daily_usage_admin(db.session.query(
49
+ func.coalesce(func.sum(DailyUsage.usage), 0),
50
+ func.coalesce(func.sum(DailyUsage.online), 0)
51
+ ).filter(DailyUsage.date == today)).first()
52
+ users_online_today = filter_user_admin(User.query.filter(User.last_online >= today)).count()
53
+
54
+ h24 = datetime.datetime.now()-datetime.timedelta(days=1)
55
+ users_online_h24 = filter_user_admin(User.query.filter(User.last_online >= h24)).count()
56
+
57
+ m5 = datetime.datetime.now()-datetime.timedelta(minutes=5)
58
+ users_online_m5 = filter_user_admin(User.query.filter(User.last_online >= m5)).count()
59
+
60
+ # Yesterday's usage and online count
61
+ yesterday = date.today() - timedelta(days=1)
62
+ yesterday_stats = filter_daily_usage_admin(db.session.query(
63
+ func.coalesce(func.sum(DailyUsage.usage), 0),
64
+ func.coalesce(func.sum(DailyUsage.online), 0)
65
+ ).filter(DailyUsage.date == yesterday)).first()
66
+ # users_online_yesterday = User.query.filter(User.last_online >= yesterday, User.last_online < today).count()
67
+ # Last 30 days' usage and online count
68
+ last_30_days_start = date.today() - timedelta(days=30)
69
+ last_30_days_stats = filter_daily_usage_admin(db.session.query(
70
+ func.coalesce(func.sum(DailyUsage.usage), 0),
71
+ func.coalesce(func.sum(DailyUsage.online), 0)
72
+ ).filter(DailyUsage.date >= last_30_days_start)).first()
73
+ users_online_last_month = filter_user_admin(User.query.filter(User.last_online >= last_30_days_start)).count()
74
+
75
+ # Total usage and online count
76
+ total_stats = filter_daily_usage_admin(db.session.query(
77
+ func.coalesce(func.sum(DailyUsage.usage), 0),
78
+ func.coalesce(func.sum(DailyUsage.online), 0)
79
+ )).first()
80
+ ten_years_ago = today - timedelta(days=365*10)
81
+ users_online_last_10_years = filter_user_admin(User.query.filter(User.last_online >= ten_years_ago)).count()
82
+ total_users = filter_user_admin(User.query).count()
83
+
84
+ # Return the usage stats as a dictionary
85
+ return {
86
+ "today": {"usage": today_stats[0], "online": users_online_today},
87
+ "h24": {"usage": 0, "online": users_online_h24},
88
+ "m5": {"usage": 0, "online": users_online_m5},
89
+ "yesterday": {"usage": yesterday_stats[0], "online": yesterday_stats[1]},
90
+ "last_30_days": {"usage": last_30_days_stats[0], "online": users_online_last_month},
91
+ "total": {"usage": total_stats[0], "online": users_online_last_10_years, "users": total_users}
92
+ }
@@ -107,22 +107,21 @@ class Actions(FlaskView):
107
107
  flash((_('Your domains changed. Please do not forget to copy admin links, otherwise you can not access to the panel anymore.')), 'info')
108
108
  # flash(f'complete_install={complete_install} domain_changed={domain_changed} ', 'info')
109
109
  # return render_template("result.html")
110
- hiddify.add_temporary_access()
110
+ # hiddify.add_temporary_access()
111
111
  file = "install.sh" if complete_install else "apply_configs.sh"
112
112
  try:
113
113
  server_ip = urllib.request.urlopen('https://v4.ident.me/').read().decode('utf8')
114
114
  except:
115
115
  server_ip = "server_ip"
116
116
 
117
- admin_proxy_path = hconfig(ConfigEnum.proxy_path_admin)
118
117
  admin_links = f"<h5 >{_('Admin Links')}</h5><ul>"
119
- username, password = hiddify.current_account_user_pass()
120
- admin_links += f"<li><span class='badge badge-danger'>{_('Not Secure')}</span>: <a class='badge ltr share-link' href='http://{username}:{password}@{server_ip}/{admin_proxy_path}/admin/'>http://{username}:{password}@{server_ip}/{admin_proxy_path}/admin/</a></li>"
118
+
119
+ admin_links += f"<li><span class='badge badge-danger'>{_('Not Secure')}</span>: <a class='badge ltr share-link' href='{hiddify.get_account_panel_link(g.account, server_ip,is_https=False)}'>{hiddify.get_account_panel_link(g.account, server_ip,is_https=False)}</a></li>"
121
120
  domains = get_panel_domains()
122
121
  # domains=[*domains,f'{server_ip}.sslip.io']
123
122
 
124
123
  for d in domains:
125
- link = f'https://{username}:{password}@{d}/{admin_proxy_path}/admin/'
124
+ link = hiddify.get_account_panel_link(g.account, d)
126
125
  admin_links += f"<li><a target='_blank' class='badge ltr' href='{link}'>{link}</a></li>"
127
126
 
128
127
  resp = render_template("result.html",
@@ -169,7 +168,7 @@ class Actions(FlaskView):
169
168
  return self.update2()
170
169
 
171
170
  def update2(self):
172
- hiddify.add_temporary_access()
171
+ # hiddify.add_temporary_access()
173
172
  # run update.sh
174
173
  commander(Command.update)
175
174
 
@@ -82,19 +82,19 @@ class AdminstratorAdmin(AdminLTEModelView):
82
82
 
83
83
  def _ul_formatter(view, context, model, name):
84
84
 
85
- return Markup(" ".join([hiddify.get_user_link(model.uuid, d, 'admin', model.name).replace('/admin/', '/', 1) for d in get_panel_domains()]))
85
+ return Markup(" ".join([hiddify.get_html_user_link(model, d) for d in get_panel_domains()]))
86
86
 
87
87
  @property
88
88
  def can_create(self):
89
89
  return g.account.can_add_admin or g.account.mode == AdminMode.super_admin
90
90
 
91
91
  def _name_formatter(view, context, model, name):
92
- admin_proxy_path = hconfig(ConfigEnum.proxy_path_admin)
93
- d = get_panel_domains()[0]
92
+
93
+ d = request.host
94
94
  if d:
95
- # link = f"<a target='_blank' href='https://{model.username}:{model.password}@{d}/{admin_proxy_path}/#{model.name}'>{model.name} <i class='fa-solid fa-arrow-up-right-from-square'></i></a>"
96
- href = f'https://{d}/{admin_proxy_path}/{model.uuid}/#{model.name}'
97
- link = f"<a target='_blank' class='copy-link' data-copy='{href}' href='{href}'>{model.name} <i class='fa-solid fa-arrow-up-right-from-square'></i></a>"
95
+
96
+ href = hiddify.get_account_panel_link(model, d) + f'/#{model.name}'
97
+ link = f"<a target='_blank' class='share-link' data-copy='{href}' href='{href}'>{model.name} <i class='fa-solid fa-arrow-up-right-from-square'></i></a>"
98
98
  if model.parent_admin:
99
99
  return Markup(model.parent_admin.name + "&rlm;&lrm; / &rlm;&lrm;"+link)
100
100
  return Markup(link)
@@ -58,11 +58,11 @@ class Backup(FlaskView):
58
58
 
59
59
  from flask_babel import refresh
60
60
  refresh()
61
- return redirect(f'/{hconfig(ConfigEnum.proxy_path_admin)}/admin/actions/reinstall2/', code=302)
62
- from . import Actions
63
- action = Actions()
64
- return action.reinstall(complete_install=True, domain_changed=True)
65
- # hiddify.flash_config_success(full_install=True)
61
+ return redirect(url_for("admin.Actions:reinstall2"))
62
+ # from . import Actions
63
+ # action = Actions()
64
+ # return action.reinstall(complete_install=True, domain_changed=True)
65
+ # # hiddify.flash_config_success(full_install=True)
66
66
  else:
67
67
  flash(_('Config file is incorrect'), category='error')
68
68
  return render_template('backup.html', restore_form=restore_form)
@@ -51,8 +51,7 @@ class ChildAdmin(AdminLTEModelView):
51
51
  form_columns = ['domain', 'show_domains']
52
52
 
53
53
  def _domain_admin_link(view, context, model, name):
54
- username, password = hiddify.current_account_user_pass()
55
- admin_link = f'https://{username}:{password}@{model.domain}{hiddify.get_admin_path()}'
54
+ admin_link = hiddify.get_account_panel_link(g.account, model.domain)
56
55
  return Markup(f'<div class="btn-group"><a href="{admin_link}" class="btn btn-xs btn-secondary">' + _("admin link") +
57
56
  f'</a><a href="{admin_link}" class="btn btn-xs btn-info ltr" target="_blank">{model.domain}</a></div>')
58
57
 
@@ -24,7 +24,7 @@ class Dashboard(FlaskView):
24
24
 
25
25
  # return jsonify(dict(
26
26
  # stats={'system': hiddify.system_stats(), 'top5': hiddify.top_processes()},
27
- # usage_history=get_daily_usage_stats(admin_id)
27
+ # usage_history=DailyUsage.get_daily_usage_stats(admin_id)
28
28
  # ))
29
29
 
30
30
  @login_required(roles={Role.super_admin, Role.admin, Role.agent})
@@ -52,7 +52,7 @@ class Dashboard(FlaskView):
52
52
  for d in c.domains:
53
53
  if d.mode == DomainType.fake:
54
54
  continue
55
- remote = f"https://{d.domain}/{hconfig(ConfigEnum.proxy_path_admin,c.id)}/{hconfig(ConfigEnum.admin_secret,c.id)}"
55
+ remote = hiddify.get_account_panel_link(g.account, d.domain, child_id=c.id)
56
56
  d.is_active = hiddify.check_connection_to_remote(remote)
57
57
  if d.is_active:
58
58
  c.is_active = True
@@ -74,8 +74,7 @@ class Dashboard(FlaskView):
74
74
  flash(_("Please understand that parent panel is under test and the plan and the condition of use maybe change at anytime."), "danger")
75
75
  elif def_user:
76
76
  d = domains[0]
77
- u = def_user.uuid
78
- flash((_('It seems that you have not created any users yet. Default user link: %(default_link)s', default_link=hiddify.get_user_link(u, d))), 'secondary')
77
+ flash((_('It seems that you have not created any users yet. Default user link: %(default_link)s', default_link=hiddify.get_html_user_link(def_user, d))), 'secondary')
79
78
  if hiddify.is_ssh_password_authentication_enabled():
80
79
  flash(_('ssh.password-login.warning.'), "warning")
81
80
 
@@ -83,7 +82,7 @@ class Dashboard(FlaskView):
83
82
  # flash((_('Error!!!')),'info')
84
83
 
85
84
  stats = {'system': hiddify.system_stats(), 'top5': hiddify.top_processes()}
86
- return render_template('index.html', stats=stats, usage_history=get_daily_usage_stats(admin_id, child_id), childs=childs)
85
+ return render_template('index.html', stats=stats, usage_history=DailyUsage.get_daily_usage_stats(admin_id, child_id), childs=childs)
87
86
 
88
87
  @login_required(roles={Role.super_admin})
89
88
  @route('remove_child', methods=['POST'])
@@ -92,7 +92,7 @@ class DomainAdmin(AdminLTEModelView):
92
92
  d = model.domain
93
93
  if "*" in d:
94
94
  d = d.replace("*", hiddify.get_random_string(5, 15))
95
- admin_link = f'https://{d}{hiddify.get_admin_path()}'
95
+ admin_link = hiddify.get_account_panel_link(g.account, d)
96
96
  return Markup(
97
97
  f'<div class="btn-group"><a href="{admin_link}" class="btn btn-xs btn-secondary">' + _("admin link") +
98
98
  f'</a><a href="{admin_link}" class="btn btn-xs btn-info ltr" target="_blank">{model.domain}</a></div>')
@@ -75,11 +75,6 @@ class QuickSetup(FlaskView):
75
75
  ])
76
76
 
77
77
  db.session.commit()
78
- # hiddify.flash_config_success()
79
- # proxy_path = hconfig(ConfigEnum.proxy_path_admin)
80
- # uuid=User.query.first().uuid
81
- # userlink=f"<a class='btn btn-secondary share-link' target='_blank' href='https://{quick_form.domain.data}/{proxy_path}/{uuid}/'>{_('default user link')}</a>"
82
- # flash((_('The default user link is %(link)s. To add or edit more users, please visit users from menu.',link=userlink)),'info')
83
78
 
84
79
  from . import Actions
85
80
  action = Actions.Actions()
@@ -153,7 +148,4 @@ def validate_domain(form, field):
153
148
 
154
149
  def admin_link():
155
150
  domains = get_panel_domains()
156
- if len(domains):
157
- return "https://"+domains[0].domain+hiddify.get_admin_path()
158
- else:
159
- return "https://"+hutils.ip.get_ip(4)+hiddify.get_admin_path()
151
+ return hiddify.get_account_panel_link(g.account, domains[0] if len(domains)else hutils.ip.get_ip(4))
@@ -134,15 +134,15 @@ class UserAdmin(AdminLTEModelView):
134
134
  else:
135
135
  link = '<i class="fa-solid fa-circle-xmark text-danger"></i> '
136
136
 
137
- client_proxy_path = hconfig(ConfigEnum.proxy_path_client)
138
- href = f'https://{request.host}/{client_proxy_path}/{model.uuid}/#{model.name}'
139
- link += f"<a target='_blank' class='copy-link' data-copy='{href}' href='{href}'>{model.name} <i class='fa-solid fa-arrow-up-right-from-square'></i></a>"
140
- # link += f"<a target='_blank' class='copy-link' href='https://{model.username}:{model.password}@{d}/{client_proxy_path}/#{model.name}'>{model.name} <i class='fa-solid fa-arrow-up-right-from-square'></i></a>"
137
+ href = hiddify.get_account_panel_link(model, request.host, is_https=True, prefere_path_only=True)+f"#{model.name}"
138
+
139
+ link += f"<a target='_blank' class='share-link' data-copy='{href}' href='{href}'>{model.name} <i class='fa-solid fa-arrow-up-right-from-square'></i></a>"
140
+
141
141
  return Markup(extra+link)
142
142
 
143
143
  def _ul_formatter(view, context, model, name):
144
144
  domains = get_panel_domains()
145
- return Markup(" ".join([hiddify.get_user_link(model.uuid, d, 'new', model.name) for d in domains]))
145
+ return Markup(" ".join([hiddify.get_html_user_link(model, d) for d in domains]))
146
146
 
147
147
  def _uuid_formatter(view, context, model, name):
148
148
  return Markup(f"<span>{model.uuid}</span>")
@@ -1,7 +1,6 @@
1
1
  {% macro admin_btn(child,domain) -%}
2
2
  <div class="btn-group">
3
-
4
- <a href="https://{{domain}}/{{hconfig(ConfigEnum.proxy_path_admin,child.id)}}/admin/" class="btn btn-xs btn-{{" success" if child.is_active else "warning" }} orig-link ltr" target="_blank">{{domain}}</a>
3
+ <a href="{hiddify.get_account_panel_link(g.account,domain,child_id=child.id)}" class="btn btn-xs btn-{{" success" if child.is_active else "warning" }} orig-link ltr" target="_blank">{{domain}}</a>
5
4
  </div>
6
5
  {%- endmacro -%}
7
6
 
@@ -8,6 +8,7 @@
8
8
  {{out_msg|safe}}
9
9
  </div>
10
10
 
11
+ {#
11
12
  %if g.temp_admin_link
12
13
  {% macro temp_link() -%}
13
14
  <div class="btn-group">
@@ -24,6 +25,7 @@
24
25
 
25
26
  {{modal('save_emergency',_('This action is not yet finished.'),_("Please copy the emergency link before leaving this page."),temp_link(),show=False)}}
26
27
  %endif
28
+ #}
27
29
 
28
30
  %if g.temp_admin_link
29
31
  <div class="callout callout-success">
@@ -145,7 +147,7 @@
145
147
  // //x.contentWindow.scrollTo( 0, 999999 );
146
148
  }
147
149
  setInterval(refresh, 1000);
148
- %if g.temp_admin_link
150
+ {%if g.temp_admin_link %}
149
151
  window.addEventListener('beforeunload', function (e) {
150
152
  // // Cancel the event
151
153
  console.log("Finished", finished)
@@ -153,12 +155,12 @@
153
155
 
154
156
  e.preventDefault(); // If you prevent default behavior in Mozilla Firefox prompt will always be shown
155
157
  // // Chrome requires returnValue to be set
156
- $("#save_emergency").modal()
158
+ //$("#save_emergency").modal()
157
159
  e.returnValue = 'Save';
158
160
  return "save"
159
161
  }
160
162
  });
161
- % endif
163
+ {% endif %}
162
164
 
163
165
  $("#logbtn").on("click", function (event) {
164
166
  event.preventDefault()