hiddifypanel 10.80.0.dev14__py3-none-any.whl → 10.80.0.dev16__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 (29) hide show
  1. hiddifypanel/VERSION +1 -1
  2. hiddifypanel/VERSION.py +1 -1
  3. hiddifypanel/hutils/proxy/__init__.py +1 -0
  4. hiddifypanel/hutils/proxy/wireguard.py +34 -0
  5. hiddifypanel/models/config.py +4 -1
  6. hiddifypanel/panel/admin/DomainAdmin.py +2 -1
  7. hiddifypanel/panel/admin/QuickSetup.py +1 -1
  8. hiddifypanel/panel/common.py +1 -1
  9. hiddifypanel/panel/user/user.py +6 -18
  10. hiddifypanel/translations/en/LC_MESSAGES/messages.mo +0 -0
  11. hiddifypanel/translations/en/LC_MESSAGES/messages.po +602 -0
  12. hiddifypanel/translations/fa/LC_MESSAGES/messages.mo +0 -0
  13. hiddifypanel/translations/fa/LC_MESSAGES/messages.po +612 -0
  14. hiddifypanel/translations/pt/LC_MESSAGES/messages.mo +0 -0
  15. hiddifypanel/translations/pt/LC_MESSAGES/messages.po +603 -0
  16. hiddifypanel/translations/ru/LC_MESSAGES/messages.mo +0 -0
  17. hiddifypanel/translations/ru/LC_MESSAGES/messages.po +610 -0
  18. hiddifypanel/translations/zh/LC_MESSAGES/messages.mo +0 -0
  19. hiddifypanel/translations/zh/LC_MESSAGES/messages.po +570 -0
  20. hiddifypanel/translations.i18n/en.json +345 -1
  21. hiddifypanel/translations.i18n/fa.json +345 -1
  22. hiddifypanel/translations.i18n/pt.json +345 -1
  23. hiddifypanel/translations.i18n/ru.json +345 -1
  24. hiddifypanel/translations.i18n/zh.json +345 -1
  25. {hiddifypanel-10.80.0.dev14.dist-info → hiddifypanel-10.80.0.dev16.dist-info}/METADATA +1 -1
  26. {hiddifypanel-10.80.0.dev14.dist-info → hiddifypanel-10.80.0.dev16.dist-info}/RECORD +29 -28
  27. {hiddifypanel-10.80.0.dev14.dist-info → hiddifypanel-10.80.0.dev16.dist-info}/LICENSE.md +0 -0
  28. {hiddifypanel-10.80.0.dev14.dist-info → hiddifypanel-10.80.0.dev16.dist-info}/WHEEL +0 -0
  29. {hiddifypanel-10.80.0.dev14.dist-info → hiddifypanel-10.80.0.dev16.dist-info}/entry_points.txt +0 -0
hiddifypanel/VERSION CHANGED
@@ -1 +1 @@
1
- 10.80.0.dev14
1
+ 10.80.0.dev16
hiddifypanel/VERSION.py CHANGED
@@ -2,5 +2,5 @@ import importlib.metadata
2
2
  from datetime import datetime
3
3
 
4
4
  __version__ = importlib.metadata.version(__package__ or __name__)
5
- __release_time__= datetime.strptime('2024-11-18T03:24:43','%Y-%m-%dT%H:%M:%S')
5
+ __release_time__= datetime.strptime('2024-12-09T01:13:52','%Y-%m-%dT%H:%M:%S')
6
6
  is_released_version=True
@@ -3,3 +3,4 @@ from . import xray
3
3
  from . import xrayjson
4
4
  from . import singbox
5
5
  from . import clash
6
+ from . import wireguard
@@ -0,0 +1,34 @@
1
+
2
+ def generate_wireguard_config(proxy: dict) -> str:
3
+ """
4
+ Generates a WireGuard configuration from a given proxy dictionary.
5
+
6
+ Args:
7
+ proxy (dict): Dictionary containing WireGuard and proxy details.
8
+
9
+ Returns:
10
+ str: A WireGuard configuration string.
11
+ """
12
+ name=f'{proxy["extra_info"]} {proxy["name"]}'
13
+ addrs = f"{proxy['wg_ipv4']}/32"
14
+ if proxy['wg_ipv6']:
15
+ addrs += f", {proxy['wg_ipv6']}/128"
16
+ config = f"""[Interface]
17
+ # Name = {name}
18
+ Address= {addrs}
19
+ PrivateKey = {proxy["wg_pk"]}
20
+ MTU = {proxy.get("mtu", 1380)}
21
+ DNS = {proxy.get("dns", "1.1.1.1")}
22
+
23
+ [Peer]
24
+ # Name = Public Peer for {name}
25
+ Endpoint = {proxy["server"]}:{proxy["port"]}
26
+ PublicKey = {proxy["wg_server_pub"]}
27
+ PresharedKey = {proxy['wg_psk']}
28
+ #PersistentKeepalive = {proxy.get("keep_alive", 25)}
29
+ """
30
+
31
+ #Address = {proxy.get("wg_ipv4", "0.0.0.0/32")}
32
+ #AllowedIPs = {proxy.get("allowed_ips", "0.0.0.0/0")}
33
+
34
+ return config
@@ -153,7 +153,10 @@ def add_or_update_config(commit: bool = True, child_id: int | None = None, overr
153
153
  if child_id is None:
154
154
  child_id = Child.current().id
155
155
  c = config['key']
156
- ckey = ConfigEnum(c)
156
+ try:
157
+ ckey = ConfigEnum(c)
158
+ except:
159
+ return
157
160
  if c == ConfigEnum.unique_id and not override_unique_id:
158
161
  return
159
162
 
@@ -281,7 +281,8 @@ class DomainAdmin(AdminLTEModelView):
281
281
  # Skip validation for wildcard or empty domains
282
282
  if model.domain.startswith('*') or not model.domain:
283
283
  return True
284
-
284
+ if model.mode in [DomainType.fake, DomainType.reality, DomainType.relay]:
285
+ return True
285
286
  # Resolve domain IPs with timeout
286
287
  try:
287
288
  dips = hutils.network.get_domain_ips(model.domain, timeout=10)
@@ -72,7 +72,7 @@ def get_lang_form(empty=False):
72
72
  default=hconfig(ConfigEnum.admin_lang))
73
73
  # lang=wtf.SelectField(_("config.lang.label"),choices=[("en",_("lang.en")),("fa",_("lang.fa"))],description=_("config.lang.description"),default=hconfig(ConfigEnum.lang))
74
74
  country = wtf.SelectField(
75
- _("config.country.label"), choices=[("ir", _("Iran")), ("zh", _("China")), ("other", "Others")],
75
+ _("config.country.label"), choices=[("ir", _("Iran")), ("zh", _("China")), ("ru", _("Russia")), ("other", "Others")],
76
76
  description=_("config.country.description"),
77
77
  default=hconfig(ConfigEnum.country))
78
78
  lang_submit = wtf.SubmitField(_('Submit'))
@@ -65,7 +65,7 @@ def init_app(app: APIFlask):
65
65
  'version': hiddifypanel.__version__,
66
66
  }), 500
67
67
 
68
- trace = traceback.format_exc(e)
68
+ trace = traceback.format_exc()
69
69
 
70
70
  # Create github issue link
71
71
  issue_link = hutils.github_issue.generate_github_issue_link_for_500_error(e, trace)
@@ -86,27 +86,15 @@ class UserView(FlaskView):
86
86
  continue
87
87
  wireguards.append(pinfo)
88
88
 
89
- servers.add(pinfo['server'])
89
+
90
90
 
91
91
  if not len(wireguards):
92
92
  abort(404)
93
- wg = wireguards[0]
94
- addrs = f"{wg['wg_ipv4']}/32"
95
- if wg['wg_ipv6']:
96
- addrs += f", {wg['wg_ipv6']}/128"
97
- resp = f"""
98
- [Interface]
99
- PrivateKey = {wg['wg_pk']}
100
- Address = {addrs}
101
- DNS = 1.1.1.1
102
- MTU = 1390
103
-
104
- [Peer]
105
- PublicKey = {wg['wg_pub']}
106
- PresharedKey = {wg['wg_psk']}
107
- AllowedIPs = 0.0.0.0/1, 128.0.0.0/1, ::/1, 8000::/1
108
- Endpoint = {next(iter(servers))}:61339 #{servers}
109
- """
93
+ resp =""
94
+ for wg in wireguards:
95
+ resp +=f'#========={wg["extra_info"]} {wg["name"]}================\n'
96
+ resp+=hutils.proxy.wireguard.generate_wireguard_config(wg)
97
+ resp+="\n\n"
110
98
  return add_headers(resp, c)
111
99
 
112
100
  # return self.singbox_ssh_imp()