Skip to content

Commit 8f0c799

Browse files
committed
Merge branch 'main' of github.com:hiddify/Hiddify-Panel
2 parents 753d53e + d2771ca commit 8f0c799

File tree

9 files changed

+134
-382
lines changed

9 files changed

+134
-382
lines changed

hiddifypanel/hutils/proxy/xrayjson.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def add_stream_settings(base: dict, proxy: dict):
271271
add_httpupgrade_stream(ss, proxy)
272272
if proxy['transport'] == ProxyTransport.xhttp:
273273
ss['network'] = proxy['transport']
274+
ss['transport'] = "xhttp"
274275
add_xhttp_stream(ss, proxy)
275276
if proxy['transport'] == 'ws':
276277
ss['network'] = proxy['transport']

hiddifypanel/panel/commercial/restapi/v2/user/apps_api.py

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ def get(self, data):
111111
singbox_dto = self.__get_singbox_app_dto()
112112
# hiddifyng_dto = self.__get_hiddifyng_app_dto()
113113
v2rayng_dto = self.__get_v2rayng_app_dto()
114+
cmfa_dto = self.__get_cmfa_app_dto()
114115
# hiddify_clash_android_dto = self.__get_hiddify_clash_android_app_dto()
115116
nekobox_dto = self.__get_nekobox_app_dto()
116-
apps_data += ([hiddify_next_dto, singbox_dto, v2rayng_dto, nekobox_dto])
117+
apps_data += ([hiddify_next_dto, singbox_dto, v2rayng_dto, cmfa_dto, nekobox_dto])
117118
case Platform.windows:
118119
hiddify_next_dto = self.__get_hiddify_next_app_dto()
120+
clash_verge_rev_dto = self.__get_clash_verge_rev_app_dto()
119121
# hiddify_clash_dto = self.__get_hiddify_clash_desktop_app_dto()
120122
# hiddifyn_dto = self.__get_hiddifyn_app_dto()
121123
v2rayn_dto = self.__get_v2rayn_app_dto()
122-
apps_data += ([hiddify_next_dto, v2rayn_dto])
124+
apps_data += ([hiddify_next_dto, v2rayn_dto, clash_verge_rev_dto ])
123125
case Platform.ios:
124126
hiddify_next_dto = self.__get_hiddify_next_app_dto()
125127
singbox_dto = self.__get_singbox_app_dto()
@@ -131,13 +133,15 @@ def get(self, data):
131133
apps_data += ([hiddify_next_dto, singbox_dto, streisand_dto, stash_dto, shadowrocket_dto, foxray_dto, loon_dto])
132134
case Platform.linux:
133135
hiddify_next_dto = self.__get_hiddify_next_app_dto()
136+
clash_verge_rev_dto = self.__get_clash_verge_rev_app_dto()
134137
# hiddify_clash_dto = self.__get_hiddify_clash_desktop_app_dto()
135-
apps_data += ([hiddify_next_dto])
138+
apps_data += ([hiddify_next_dto, clash_verge_rev_dto ])
136139
case Platform.mac:
137140
hiddify_next_dto = self.__get_hiddify_next_app_dto()
138141
singbox_dto = self.__get_singbox_app_dto()
142+
clash_verge_rev_dto = self.__get_clash_verge_rev_app_dto()
139143
# hiddify_clash_dto = self.__get_hiddify_clash_desktop_app_dto()
140-
apps_data += ([hiddify_next_dto, singbox_dto])
144+
apps_data += ([hiddify_next_dto, singbox_dto, clash_verge_rev_dto ])
141145

142146
return apps_data
143147

@@ -168,11 +172,13 @@ def __get_all_apps_dto(self):
168172
stash_app_dto = self.__get_stash_app_dto()
169173
# hiddify_clash_app_dto = self.__get_hiddify_clash_desktop_app_dto()
170174
singbox_app_dto = self.__get_singbox_app_dto()
175+
cmfa_app_dto = self.__get_cmfa_app_dto()
176+
clash_verge_rev_app_dto = self.__get_clash_verge_rev_app_dto()
171177
hiddify_next_app_dto = self.__get_hiddify_next_app_dto()
172178
return [
173179
v2rayn_app_dto, v2rayng_app_dto,
174180
foxray_app_dto, shadowrocket_app_dto, streisand_app_dto,
175-
loon_app_dto, stash_app_dto, singbox_app_dto, hiddify_next_app_dto
181+
loon_app_dto, stash_app_dto, singbox_app_dto, cmfa_app_dto, clash_verge_rev_app_dto, hiddify_next_app_dto
176182
]
177183

178184
def __get_app_icon_url(self, app_name):
@@ -182,6 +188,10 @@ def __get_app_icon_url(self, app_name):
182188
url = base + static_url_for(filename='apps-icon/hiddify_next.ico')
183189
elif app_name == _('app.singbox.title'):
184190
url = base + static_url_for(filename='apps-icon/singbox.ico')
191+
elif app_name == _('app.cmfa.title'):
192+
url = base + static_url_for(filename='apps-icon/cmfa.ico')
193+
elif app_name == _('app.clash_verge_rev.title'):
194+
url = base + static_url_for(filename='apps-icon/clash_verge_rev.ico')
185195
elif app_name == _('app.hiddifyn.title'):
186196
url = base + static_url_for(filename='apps-icon/hiddifyn.ico')
187197
elif app_name == _('app.v2rayng.title'):
@@ -356,7 +366,7 @@ def __get_singbox_app_dto(self):
356366
dto.description = _('app.singbox.description')
357367
dto.icon_url = self.__get_app_icon_url(_('app.singbox.title'))
358368
dto.guide_url = ''
359-
dto.deeplink = f'sing-box://import-remote-profile/?url={self.user_panel_url}'
369+
dto.deeplink = f'sing-box://import-remote-profile/?url={self.user_panel_url}#{self.profile_title}'
360370

361371
# availabe installatoin types
362372
installation_types = []
@@ -409,6 +419,66 @@ def remove_v_from_filename(url):
409419
dto.install = install_dtos
410420
return dto
411421

422+
def __get_clash_verge_rev_app_dto(self):
423+
dto = AppSchema()
424+
dto.title = _('app.clash_verge_rev.title')
425+
dto.description = _('app.clash_verge_rev.description')
426+
dto.icon_url = self.__get_app_icon_url(_('app.clash_verge_rev.title'))
427+
dto.guide_url = ''
428+
dto.deeplink = f'clash://install-config/?url={self.user_panel_encoded_url}&name={self.profile_title}'
429+
430+
# availabe installatoin types
431+
installation_types = []
432+
if self.platform == Platform.all:
433+
installation_types = [AppInstallType.setup, AppInstallType.appimage, AppInstallType.dmg]
434+
else:
435+
match self.platform:
436+
case Platform.windows:
437+
installation_types = [AppInstallType.setup]
438+
case Platform.linux:
439+
installation_types = [AppInstallType.appimage]
440+
case Platform.mac:
441+
installation_types = [AppInstallType.dmg]
442+
443+
install_dtos = []
444+
for install_type in installation_types:
445+
install_dto = AppInstall()
446+
ins_url = ''
447+
match install_type:
448+
case AppInstallType.appimage:
449+
ins_url = 'https://www.clashverge.dev/install.html#__tabbed_1_2'
450+
case AppInstallType.setup:
451+
ins_url = 'https://www.clashverge.dev/install.html#__tabbed_1_1'
452+
case AppInstallType.dmg:
453+
ins_url = 'https://www.clashverge.dev/install.html#__tabbed_1_3'
454+
455+
install_dto = self.__get_app_install_dto(install_type, ins_url)
456+
install_dtos.append(install_dto)
457+
458+
dto.install = install_dtos
459+
return dto
460+
461+
def __get_cmfa_app_dto(self):
462+
dto = AppSchema()
463+
dto.title = _('app.cmfa.title')
464+
dto.description = _('app.cmfa.description')
465+
dto.icon_url = self.__get_app_icon_url(_('app.cmfa.title'))
466+
dto.guide_url = ''
467+
dto.deeplink = f'clash://install-config/?url={self.user_panel_encoded_url}&name={self.profile_title}'
468+
469+
latest_url, version = get_latest_release_url(f'https://github.com/MetaCubeX/ClashMetaForAndroid')
470+
ins_url = latest_url.split('releases/')[0] + f'releases/download/{version}/cmfa-{version}-meta-universal-release.apk'
471+
def remove_v_from_filename(url):
472+
parts = url.split('/')
473+
filename = parts[-1]
474+
new_filename = filename.replace('cmfa-v', 'cmfa-')
475+
parts[-1] = new_filename
476+
new_url = '/'.join(parts)
477+
return new_url
478+
ins_url = remove_v_from_filename(ins_url)
479+
dto.install = [self.__get_app_install_dto(AppInstallType.apk, ins_url)]
480+
return dto
481+
412482
def __get_hiddify_next_app_dto(self):
413483
dto = AppSchema()
414484
dto.title = _('app.hiddify.next.title')

hiddifypanel/panel/user/templates/base_singbox_config.json.j2

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% set V1_7= g.user_agent['is_singbox'] and g.user_agent['singbox_version'][0]==1 and g.user_agent['singbox_version'][1]<8 %}
22
{% set V1_9= g.user_agent['is_singbox'] and g.user_agent['singbox_version'][0]==1 and g.user_agent['singbox_version'][1]<10 %}
3+
34
{
45
"outbounds": [
56
{
@@ -26,46 +27,30 @@
2627
{% if V1_7 %}
2728
"geoip": {
2829
"download_url": "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db",
29-
"download_detour": {% if hconfig(ConfigEnum.country)=='cn' %}"Select" {%else%}"bypass"{%endif%}
30+
"download_detour": {% if hconfig(ConfigEnum.country)=='zh' %}"Select" {%else%}"bypass"{%endif%}
3031
},
3132
"geosite": {
3233
"download_url": "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db",
33-
"download_detour": {% if hconfig(ConfigEnum.country)=='cn' %}"Select" {%else%}"bypass"{%endif%}
34+
"download_detour": {% if hconfig(ConfigEnum.country)=='zh' %}"Select" {%else%}"bypass"{%endif%}
3435
},
3536
{%else%}
3637
"rule_set": [
37-
{%if hconfig(ConfigEnum.country)=="ir"%}
38+
{%if hconfig(ConfigEnum.country) in ["ir","zh","ru"]%}
3839
{
39-
"tag": "geosite-ir",
40+
"tag": "geosite-{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}",
4041
"type": "remote",
4142
"format": "binary",
42-
"url": "https:\/\/raw.githubusercontent.com\/Chocolate4U\/Iran-sing-box-rules\/rule-set\/geosite-ir.srs",
43-
"download_detour": "bypass"
43+
"url": "https:\/\/github.com\/hiddify\/hiddify-geo\/raw\/rule-set\/country\/geosite-{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}.srs",
44+
"download_detour": {% if hconfig(ConfigEnum.country)=='zh' %}"Select" {%else%}"bypass"{%endif%}
4445
},
4546
{
46-
"tag": "geoip-ir",
47+
"tag": "geoip-{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}",
4748
"type": "remote",
4849
"format": "binary",
49-
"url": "https:\/\/raw.githubusercontent.com\/Chocolate4U\/Iran-sing-box-rules\/rule-set\/geoip-ir.srs",
50-
"download_detour": "bypass"
50+
"url": "https:\/\/github.com\/hiddify\/hiddify-geo\/raw\/rule-set\/country\/geoip-{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}.srs",
51+
"download_detour": {% if hconfig(ConfigEnum.country)=='zh' %}"Select" {%else%}"bypass"{%endif%}
5152
}
52-
{%endif%}
53-
{%if hconfig(ConfigEnum.country)=="ru"%}
54-
{
55-
"tag": "geosite-ru",
56-
"type": "remote",
57-
"format": "binary",
58-
"url": "https:\/\/github.com\/SagerNet\/sing-geosite\/raw\/rule-set\/geosite-category-ru.srs",
59-
"download_detour": "bypass"
60-
},
61-
{
62-
"tag": "geoip-ru",
63-
"type": "remote",
64-
"format": "binary",
65-
"url": "https:\/\/github.com\/SagerNet\/sing-geoip\/raw\/rule-set\/geoip-ru.srs",
66-
"download_detour": "bypass"
67-
}
68-
{%endif%}
53+
{%endif%}
6954
{# {
7055
"tag": "geosite-category-ads-all",
7156
"type": "remote",
@@ -88,10 +73,10 @@
8873
],
8974
"outbound": "dns-out"
9075
},
91-
{%if hconfig(ConfigEnum.country) in ["ir","cn","ru"]%}
76+
{%if hconfig(ConfigEnum.country)in ["ir","zh","ru"]%}
9277
{
9378
"domain_suffix": [
94-
"{{hconfig(ConfigEnum.country)}}"
79+
"{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}"
9580
],
9681
"outbound": "bypass"
9782
},
@@ -105,19 +90,19 @@
10590
{%endif%}
10691
"outbound": "block"
10792
}, #}
108-
{%if hconfig(ConfigEnum.country) in ["ir","cn","ru"]%}
93+
{%if hconfig(ConfigEnum.country) in ["ir","zh","ru"]%}
10994
{% if V1_7 %}
11095
{
111-
"geoip": ["{{hconfig(ConfigEnum.country)}}"],
96+
"geoip": ["{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}"],
11297
"outbound": "bypass"
11398
},
11499
{%else%}
115100
{
116-
"rule_set": "geoip-{{hconfig(ConfigEnum.country)}}",
101+
"rule_set": "geoip-{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}",
117102
"outbound": "bypass"
118103
},
119104
{
120-
"rule_set": "geosite-{{hconfig(ConfigEnum.country)}}",
105+
"rule_set": "geosite-{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}",
121106
"outbound": "bypass"
122107
},
123108
{%endif%}
@@ -192,10 +177,10 @@
192177
],
193178
"server": "dns-local"
194179
},
195-
{%if hconfig(ConfigEnum.country)in ["ir","cn","ru"]%}
180+
{%if hconfig(ConfigEnum.country)in ["ir","zh","ru"]%}
196181
{
197182
"domain_suffix": [
198-
"{{hconfig(ConfigEnum.country)}}"
183+
"{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}"
199184
],
200185
"server": "dns-local"
201186
},

hiddifypanel/panel/user/templates/base_xray_config.json.j2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"outboundTag": "direct",
9999
"domain": [
100100
"domain:ir",
101-
"geosite:cn"
101+
"geosite:cn",
102+
"geosite:category-ru"
102103
],
103104
"enabled": true
104105
},
@@ -109,7 +110,8 @@
109110
"ip": [
110111
"geoip:private",
111112
"geoip:cn",
112-
"geoip:ir"
113+
"geoip:ir",
114+
"geoip:ru"
113115
],
114116
"enabled": true
115117
},

hiddifypanel/panel/user/templates/clash_config.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,33 @@ proxy-groups:
135135
# %endfor
136136
# %endfor
137137
rule-providers:
138-
138+
{% if hconfig(ConfigEnum.country) in ["ir","zh","ru"] %}
139+
geoip_{{hconfig(ConfigEnum.country)}}:
140+
type: http
141+
behavior: classical
142+
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geoip/classical/{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}}.yaml"
143+
path: ./geoip/{{hconfig(ConfigEnum.country)}}.yaml
144+
interval: 432000
145+
146+
{% endif %}
147+
{% if hconfig(ConfigEnum.country)=="zh" %}
148+
geosite_cn:
149+
type: http
150+
behavior: classical
151+
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo-lite/geosite/classical/cn.yaml"
152+
path: ./geosite/zh.yaml
153+
interval: 86400
154+
155+
{% endif %}
156+
{% if hconfig(ConfigEnum.country) in ["ir","ru"] %}
157+
geosite_{{hconfig(ConfigEnum.country)}}:
158+
type: http
159+
behavior: classical
160+
url: "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geosite/classical/category-{{hconfig(ConfigEnum.country)}}.yaml"
161+
path: ./geosite/{{hconfig(ConfigEnum.country)}}.yaml
162+
interval: 86400
163+
164+
{% endif %}
139165
blocked:
140166
type: http
141167
behavior: classical
@@ -175,9 +201,13 @@ rules:
175201
# - IP-CIDR,10.10.34.0/24,{{OnProxyIssue}}
176202
# - RULE-SET,tmpblocked,{{OnProxyIssue}}
177203
# - RULE-SET,blocked,{{OnProxyIssue}}
178-
- GEOIP,IR,{{OnIranSites}}
179-
- DOMAIN-SUFFIX,.ir,{{OnIranSites}}
204+
{% if hconfig(ConfigEnum.country) in ["ir","zh","ru"] %}
205+
- RULE-SET,geoip_{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}},DIRECT
206+
- RULE-SET,geosite_{{hconfig(ConfigEnum.country)|replace('zh', 'cn')}},DIRECT
207+
{% endif %}
208+
{% if hconfig(ConfigEnum.country)=="ir" %}
180209
- RULE-SET,open,{{OnIranSites}}
210+
{% endif %}
181211
# - RULE-SET,ads,REJECT
182212
- MATCH,{{OnNotFilteredSites}}
183213

Binary file not shown.
17.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)