Skip to content

Commit ff5d03d

Browse files
committed
fix: merge
2 parents 4b22ce1 + 35ea2cb commit ff5d03d

32 files changed

Lines changed: 860 additions & 43 deletions

File tree

HISTORY.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -586,29 +586,29 @@
586586
_enhancements for xray, sing-box, clash configs_
587587

588588
* Enhancements for xray, sing-box, clash configs.
589-
_clash config:
590-
replace zh to cn for correct create config
591-
add geoip&geosite rule-sets for ir,cn,ru with DIRECT route
592-
GEOIP,IR & DOMAIN-SUFFIX,.ir replace to rule-sets
593-
594-
sing-box:
595-
replace zh to cn for correct create config
596-
replace .srs links to .srs from hiddify-geo
597-
fix rule-set sing-box 1.8+ for .cn
598-
599-
xray config:
589+
_clash config:
590+
replace zh to cn for correct create config
591+
add geoip&geosite rule-sets for ir,cn,ru with DIRECT route
592+
GEOIP,IR & DOMAIN-SUFFIX,.ir replace to rule-sets
593+
594+
sing-box:
595+
replace zh to cn for correct create config
596+
replace .srs links to .srs from hiddify-geo
597+
fix rule-set sing-box 1.8+ for .cn
598+
599+
xray config:
600600
add geoip:ru & geosite:category-ru for DIRECT_
601601

602602
* Merge pull request #5 from legiz-ru/mihomo.
603603
_add mihomo and fix sb_
604604

605605
* Add mihomo and fix sb.
606-
_fix subname for sing-box app
607-
add clash meta for android
606+
_fix subname for sing-box app
607+
add clash meta for android
608608
add clash verge rev_
609609

610610
* Add clash icons.
611-
_add clash meta for android
611+
_add clash meta for android
612612
add clash verge rev_
613613

614614
* Update translations.
@@ -2480,8 +2480,8 @@ add clash verge rev_
24802480
_Update base_singbox_config.json.j2_
24812481

24822482
* Update base_singbox_config.json.j2.
2483-
_Correctly bypass geoip and geosite download url.
2484-
2483+
_Correctly bypass geoip and geosite download url.
2484+
24852485
The default bypass list only includes `githubusercontent.com` but it should also contain `raw.githubusercontent.com`. Note that this problem only manifests in clients which have just recently installed singbox. For those who already had singbox with a working hiddify installation, they already have the cache files and the file updates flawlessly._
24862486

24872487
* Fink 🐦: update translations.
@@ -4565,9 +4565,9 @@ with A2_
45654565
_Update UserAdmin.py_
45664566

45674567
* Update UserAdmin.py.
4568-
_Shows Telegram icons for all users in the admin panel, if Telegram is enabled.
4569-
4570-
Users which are not registered for Telegram are shown with greyed out disabled buttons, registered users with blue buttons.
4568+
_Shows Telegram icons for all users in the admin panel, if Telegram is enabled.
4569+
4570+
Users which are not registered for Telegram are shown with greyed out disabled buttons, registered users with blue buttons.
45714571
It is a visual improvement to have all users aligned in the table._
45724572

45734573
* Merge branch 'main' of github.com:Iam54r1n4/HiddifyPanel.
@@ -5519,8 +5519,8 @@ It is a visual improvement to have all users aligned in the table._
55195519
_fixing IPv6 issue for resolving IPv6's behind domain in auto cdn_
55205520

55215521
* Fixing IPv6 issue for resolving IPv6's behind domain in auto cdn.
5522-
_adding brackets to avoid errors when converting domains to ipv6.
5523-
5522+
_adding brackets to avoid errors when converting domains to ipv6.
5523+
55245524
aaaa:bbbb:cccc:dddd -> [aaaa:bbbb:cccc:dddd]_
55255525

55265526
* Fix; v2ray bug.

hiddifypanel/hutils/network/net.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,45 @@ def get_ech_info(domain):
439439
pass
440440

441441
return None
442+
443+
444+
def all_public_ports():
445+
tcp_ports={80:"http",443:"tls"}
446+
udp_ports={443:"quic",}
447+
log=[]
448+
if hconfig(ConfigEnum.wireguard_enable):
449+
udp_ports[hconfig(ConfigEnum.wireguard_port)]="wireguard"
450+
451+
452+
if hconfig(ConfigEnum.shadowsocks2022_enable) and (p:=hconfig(ConfigEnum.shadowsocks2022_port)):
453+
udp_ports[p]="shadowsocks_2022"
454+
tcp_ports[p]="shadowsocks_2022"
455+
if hconfig(ConfigEnum.mieru_enable):
456+
for p in hconfig(ConfigEnum.mieru_tcp_ports).split(","):
457+
tcp_ports[p]="mieru"
458+
for p in hconfig(ConfigEnum.mieru_udp_ports).split(","):
459+
udp_ports[p]="mieru"
460+
if hconfig(ConfigEnum.ssh_server_enable):
461+
tcp_ports[hconfig(ConfigEnum.ssh_server_port)]="ssh"
462+
463+
for p in (hconfig(ConfigEnum.tls_ports)).split(','):
464+
tcp_ports[p]="tls"
465+
udp_ports[p]="quic"
466+
for p in hconfig(ConfigEnum.http_ports).split(','):
467+
tcp_ports[p]="http"
468+
469+
for d in Domain.query.all():
470+
udp_ports[d.internal_port_tuic]="tuic"
471+
udp_ports[d.internal_port_naive]="naive"
472+
udp_ports[d.internal_port_hysteria2]="hysteria"
473+
474+
def to_int(ports):
475+
r={}
476+
for p,v in ports.items():
477+
try:
478+
if ip:=int(p):
479+
r[ip]=v
480+
except:
481+
pass
482+
return {k:v for k,v in sorted(r.items())}
483+
return {"tcp":to_int(tcp_ports),"udp":to_int(udp_ports)}

hiddifypanel/hutils/proxy/shared.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def is_proxy_valid(proxy: Proxy, domain_db: Domain, port: int) -> dict | None:
3535

3636
if proxy.proto not in {ProxyProto.mieru,ProxyProto.dnstt} and not port:
3737
return {'name': name, 'msg': "port not defined", 'type': 'error', 'proto': proxy.proto}
38+
if proxy.proto==ProxyProto.naive and not domain_db.need_valid_ssl:
39+
return {'name': name, 'msg': "naive only supports valid cert", 'type': 'error', 'proto': proxy.proto}
3840
if "reality" not in l3 and 'reality' in domain_db.mode:
3941
return {'name': name, 'msg': "1reality proxy not in reality domain", 'type': 'debug', 'proto': proxy.proto}
4042

@@ -410,9 +412,6 @@ def make_proxy(hconfigs: dict, proxy: Proxy, domain_db: Domain, phttp=80, ptls=4
410412
'params': proxy.params or {},
411413
}
412414

413-
if hconfigs.get(ConfigEnum.tls_ech_enable) and not proxy.l3 in {ProxyL3.reality}:
414-
if ech:=hutils.network.get_ech_info(base.get('sni')):
415-
base['ech'] = ech
416415

417416
if base["proto"]==ProxyProto.dnstt:
418417
base["public_key"]=get_dnstt_public_key()
@@ -428,6 +427,10 @@ def make_proxy(hconfigs: dict, proxy: Proxy, domain_db: Domain, phttp=80, ptls=4
428427
base['password']="h"
429428
return base
430429

430+
if hconfigs.get(ConfigEnum.tls_ech_enable) and not proxy.l3 in {ProxyL3.reality}:
431+
if ech:=hutils.network.get_ech_info(base.get('sni')):
432+
base['ech'] = ech
433+
431434
if base['proto'] in {ProxyProto.mieru}:
432435
base["password"]="h"
433436

hiddifypanel/hutils/proxy/singbox.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from hiddifypanel.models import ProxyProto, ProxyTransport, Domain, ConfigEnum
77

88

9-
def configs_as_json(domains: list[Domain], **kwargs) -> str:
9+
def configs_as_json(domains: list[Domain], **kwargs) -> dict:
1010
ua = hutils.flask.get_user_agent()
1111
base_config = json.loads(render_template('base_singbox_config.json.j2'))
1212
allphttp = [p for p in request.args.get("phttp", "").split(',') if p]
@@ -43,10 +43,10 @@ def configs_as_json(domains: list[Domain], **kwargs) -> str:
4343
"tolerance": 200
4444
}
4545
base_config['outbounds'].insert(1, smart)
46-
res = json.dumps(base_config, indent=4, cls=hutils.proxy.ProxyJsonEncoder)
46+
4747
# if ua['is_hiddify']:
4848
# res = res[:-1]+',"experimental": {}}'
49-
return res
49+
return base_config
5050

5151

5252
def is_xray_proxy(proxy: dict):

hiddifypanel/hutils/proxy/xrayjson.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .xray import is_muxable_agent, OUTBOUND_LEVEL
99

1010

11-
def configs_as_json(domains: list[Domain], user: User, expire_days: int, remarks: str) -> str:
11+
def configs_as_json(domains: list[Domain], user: User, expire_days: int, remarks: str) -> list:
1212
'''Returns xray configs as json'''
1313
all_configs = []
1414

@@ -47,8 +47,8 @@ def configs_as_json(domains: list[Domain], user: User, expire_days: int, remarks
4747
else:
4848
# TODO: seperate codes to small functions
4949
# TODO: check what are unsupported protocols in other apps
50-
unsupported_protos = {}
51-
unsupported_transport = {}
50+
unsupported_protos:set[ProxyProto] = set()
51+
unsupported_transport:set[ProxyTransport] = set()
5252
if g.user_agent.get('is_v2rayng'):
5353
# TODO: ensure which protocols are not supported in v2rayng
5454
unsupported_protos = {ProxyProto.hysteria, ProxyProto.hysteria2,
@@ -83,13 +83,12 @@ def configs_as_json(domains: list[Domain], user: User, expire_days: int, remarks
8383

8484
else: # single outbound
8585
base_config['outbounds'].insert(0, outbounds[0])
86-
all_configs = base_config
86+
all_configs = [base_config]
8787

8888
if not all_configs:
89-
return ''
89+
return []
9090

91-
json_configs = json.dumps(all_configs, indent=2, cls=hutils.proxy.ProxyJsonEncoder)
92-
return json_configs
91+
return all_configs
9392

9493

9594
def to_xray(proxy: dict) -> dict:

hiddifypanel/models/config_enum.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class ConfigCategory(StrEnum):
7676
reality = auto()
7777
wireguard = auto()
7878
shadowsocks = auto()
79+
additional_configs=auto()
7980

8081

8182
class ApplyMode(StrEnum):
@@ -154,6 +155,10 @@ def dbvalues(cls):
154155
utls = _StrConfigDscr(ConfigCategory.advanced)
155156
telegram_bot_token = _StrConfigDscr(ConfigCategory.telegram, hide_in_virtual_child=True)
156157

158+
additional_configs_urls = _StrConfigDscr(ConfigCategory.additional_configs)
159+
additional_configs_singbox = _StrConfigDscr(ConfigCategory.additional_configs)
160+
additional_configs_xrayjson = _StrConfigDscr(ConfigCategory.additional_configs)
161+
157162
# region child-parent
158163
# deprecated
159164
is_parent = _BoolConfigDscr(ConfigCategory.hidden)

hiddifypanel/models/domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def internal_port_tuic(self):
154154

155155
@property
156156
def internal_port_naive(self):
157-
if self.mode not in [DomainType.direct, DomainType.relay, DomainType.fake]:
157+
if self.mode not in [DomainType.direct, DomainType.relay]:
158158
return 0
159159
# TODO: check validity of the range of the port
160160
return int(hconfig(ConfigEnum.naive_port, self.child_id)) + self.port_index

hiddifypanel/panel/admin/Actions.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,45 @@ def reset2(self):
5050

5151
return res
5252

53+
@login_required(roles={Role.admin})
54+
def all_public_ports(self):
55+
tcp_ports={80,443}
56+
udp_ports={443,}
57+
if hconfig(ConfigEnum.wireguard_enable):
58+
udp_ports.add(hconfig(ConfigEnum.wireguard_port))
59+
if hconfig(ConfigEnum.shadowsocks2022_enable) and (p:=hconfig(ConfigEnum.shadowsocks2022_port)):
60+
udp_ports.add(p)
61+
tcp_ports.add(p)
62+
if hconfig(ConfigEnum.mieru_enable):
63+
for p in hconfig(ConfigEnum.mieru_tcp_ports).split(","):
64+
tcp_ports.add(p)
65+
for p in hconfig(ConfigEnum.mieru_udp_ports).split(","):
66+
udp_ports.add(p)
67+
if hconfig(ConfigEnum.ssh_server_enable):
68+
tcp_ports.add(hconfig(ConfigEnum.ssh_server_port))
69+
70+
for p in (hconfig(ConfigEnum.tls_ports)).split(','):
71+
tcp_ports.add(p)
72+
udp_ports.add(p)
73+
for p in hconfig(ConfigEnum.http_ports).split(','):
74+
tcp_ports.add(p)
75+
76+
for d in Domain.query.all():
77+
udp_ports.add(d.internal_port_tuic)
78+
udp_ports.add(d.internal_port_naive)
79+
udp_ports.add(d.internal_port_hysteria2)
80+
81+
def to_int(ports):
82+
r={}
83+
for p in ports:
84+
try:
85+
if ip:=int(p):
86+
r.add(ip)
87+
except:
88+
pass
89+
return {"tcp":to_int(tcp_ports),"udp":to_int(udp_ports)}
90+
91+
5392
@login_required(roles={Role.super_admin})
5493
@route('reinstall', methods=['POST'])
5594
def reinstall(self, complete_install=True, domain_changed=False):

hiddifypanel/panel/admin/ProxyAdmin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class Meta:
106106
'tuic': 'other',
107107
'ssh': 'other',
108108
'hysteria2': 'other',
109+
"mieru":"other"
110+
109111
}
110112
protos = sorted([c for c in {pgroup.get(c.proto, c.proto): 1 for c in cdn_proxies}])
111113
for proto in protos:

hiddifypanel/panel/admin/SettingAdmin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ class Meta:
273273
render_kw = {'class': "ltr", 'maxlength': 2048}
274274
field = wtf.TextAreaField(_(f'config.{c.key}.label'), validators, default=c.value,
275275
description=_(f'config.{c.key}.description'), render_kw=render_kw)
276+
elif c.key in {ConfigEnum.additional_configs_xrayjson,ConfigEnum.additional_configs_singbox,ConfigEnum.additional_configs_urls}:
277+
render_kw = {'class': "ltr", 'maxlength': 20480}
278+
field = wtf.TextAreaField(_(f'config.{c.key}.label'), default=c.value,
279+
description=_(f'config.{c.key}.description'), render_kw=render_kw)
276280
elif c.key == ConfigEnum.branding_freetext:
277281
validators = [wtf.validators.Length(max=2048)]
278282
render_kw = {'class': "ltr", 'maxlength': 2048}

0 commit comments

Comments
 (0)