From e24044013082ffef011239d83fc00d878749a7f3 Mon Sep 17 00:00:00 2001 From: hiddify-com <114227601+hiddify-com@users.noreply.github.com> Date: Mon, 18 Nov 2024 02:30:52 +0330 Subject: [PATCH] rename splithttp to xhttp --- hiddifypanel/hutils/proxy/clash.py | 4 +-- hiddifypanel/hutils/proxy/shared.py | 12 ++++----- hiddifypanel/hutils/proxy/singbox.py | 2 +- hiddifypanel/hutils/proxy/xray.py | 4 +-- hiddifypanel/hutils/proxy/xrayjson.py | 8 +++--- hiddifypanel/models/config_enum.py | 4 +-- hiddifypanel/models/proxy.py | 2 +- hiddifypanel/panel/init_db.py | 35 ++++++++++++++------------ hiddifypanel/translations.i18n/fr.json | 4 +-- hiddifypanel/translations.i18n/my.json | 4 +-- 10 files changed, 41 insertions(+), 38 deletions(-) diff --git a/hiddifypanel/hutils/proxy/clash.py b/hiddifypanel/hutils/proxy/clash.py index 4336eff49..90b264ea1 100644 --- a/hiddifypanel/hutils/proxy/clash.py +++ b/hiddifypanel/hutils/proxy/clash.py @@ -33,7 +33,7 @@ def to_clash(proxy, meta_or_normal): if proxy['l3'] in ["kcp", ProxyL3.h3_quic]: return {'name': name, 'msg': f"clash does not support {proxy['l3']}", 'type': 'debug'} - if proxy['transport'] in [ProxyTransport.splithttp, ProxyTransport.httpupgrade]: + if proxy['transport'] in [ProxyTransport.xhttp, ProxyTransport.httpupgrade]: return {'name': name, 'msg': f"clash does not support {proxy['transport']}", 'type': 'debug'} # if proxy['proto'] in [Proxy.shado]: @@ -44,7 +44,7 @@ def to_clash(proxy, meta_or_normal): return {'name': name, 'msg': f"clash does not support {proxy['proto']}", 'type': 'debug'} if proxy['proto'] in ["vless", 'tuic', 'hysteria2']: return {'name': name, 'msg': f"{proxy['proto']} not supported in clash", 'type': 'debug'} - if proxy['transport'] in ["shadowtls", "splithttp"]: + if proxy['transport'] in ["shadowtls", "xhttp"]: return {'name': name, 'msg': f"{proxy['transport']} not supported in clash", 'type': 'debug'} if proxy['l3'] == ProxyL3.tls_h2 and proxy['proto'] in [ProxyProto.vmess, ProxyProto.vless] and proxy['dbe'].cdn == ProxyCDN.direct: return {'name': name, 'msg': "bug tls_h2 vmess and vless in clash meta", 'type': 'warning'} diff --git a/hiddifypanel/hutils/proxy/shared.py b/hiddifypanel/hutils/proxy/shared.py index 7fe022ca2..7b5c98281 100644 --- a/hiddifypanel/hutils/proxy/shared.py +++ b/hiddifypanel/hutils/proxy/shared.py @@ -134,8 +134,8 @@ def get_proxies(child_id: int = 0, only_enabled=False) -> list['Proxy']: proxies = [c for c in proxies if 'trojan' not in c.proto] if not hconfig(ConfigEnum.httpupgrade_enable, child_id): proxies = [c for c in proxies if ProxyTransport.httpupgrade not in c.transport] - if not hconfig(ConfigEnum.splithttp_enable, child_id): - proxies = [c for c in proxies if ProxyTransport.splithttp not in c.transport] + if not hconfig(ConfigEnum.xhttp_enable, child_id): + proxies = [c for c in proxies if ProxyTransport.xhttp not in c.transport] if not hconfig(ConfigEnum.ws_enable, child_id): proxies = [c for c in proxies if ProxyTransport.WS not in c.transport] # if not hconfig(ConfigEnum.xtls_enable, child_id): @@ -189,7 +189,7 @@ def get_valid_proxies(domains: list[Domain]) -> list[dict]: noDomainProxies = False if proxy.proto in [ProxyProto.ssh, ProxyProto.wireguard]: noDomainProxies = True - if proxy.proto in [ProxyProto.ss] and proxy.transport not in [ProxyTransport.grpc, ProxyTransport.h2, ProxyTransport.WS, ProxyTransport.httpupgrade, ProxyTransport.splithttp]: + if proxy.proto in [ProxyProto.ss] and proxy.transport not in [ProxyTransport.grpc, ProxyTransport.h2, ProxyTransport.WS, ProxyTransport.httpupgrade, ProxyTransport.xhttp]: noDomainProxies = True options = [] key = f'{proxy.proto}{proxy.transport}{proxy.cdn}{proxy.l3}' @@ -413,9 +413,9 @@ def make_proxy(hconfigs: dict, proxy: Proxy, domain_db: Domain, phttp=80, ptls=4 base['path'] = f'/{path[base["proto"]]}{hconfigs[ConfigEnum.path_httpupgrade]}' base["host"] = domain return base - if proxy.transport in [ProxyTransport.splithttp]: - base['transport'] = 'splithttp' - base['path'] = f'/{path[base["proto"]]}{hconfigs[ConfigEnum.path_splithttp]}' + if proxy.transport in [ProxyTransport.xhttp]: + base['transport'] = 'xhttp' + base['path'] = f'/{path[base["proto"]]}{hconfigs[ConfigEnum.path_xhttp]}' # if 0 and 'h2' in base['alpn'] or 'h3' in base['alpn']: # base['path'] += "2" # else: diff --git a/hiddifypanel/hutils/proxy/singbox.py b/hiddifypanel/hutils/proxy/singbox.py index b20aac485..015195772 100644 --- a/hiddifypanel/hutils/proxy/singbox.py +++ b/hiddifypanel/hutils/proxy/singbox.py @@ -47,7 +47,7 @@ def configs_as_json(domains: list[Domain], **kwargs) -> str: def is_xray_proxy(proxy: dict): if g.user_agent.get('is_hiddify_prefere_xray'): return True - if proxy['transport'] == ProxyTransport.splithttp: + if proxy['transport'] == ProxyTransport.xhttp: return True return False diff --git a/hiddifypanel/hutils/proxy/xray.py b/hiddifypanel/hutils/proxy/xray.py index 7942bc6d0..8618d72a8 100644 --- a/hiddifypanel/hutils/proxy/xray.py +++ b/hiddifypanel/hutils/proxy/xray.py @@ -126,10 +126,10 @@ def to_link(proxy: dict) -> str | dict: baseurl += "&encryption=none" if proxy.get('fingerprint', 'none') != 'none': baseurl += "&fp=" + proxy['fingerprint'] - if proxy.get('transport') in {ProxyTransport.splithttp}: + if proxy.get('transport') in {ProxyTransport.xhttp}: baseurl += "&core=xray" if proxy['l3'] != 'quic': - if proxy.get('l3') != ProxyL3.reality and (proxy.get('transport') in {ProxyTransport.tcp, ProxyTransport.httpupgrade, ProxyTransport.splithttp}) and proxy['proto'] in [ProxyProto.vless, ProxyProto.trojan]: + if proxy.get('l3') != ProxyL3.reality and (proxy.get('transport') in {ProxyTransport.tcp, ProxyTransport.httpupgrade, ProxyTransport.xhttp}) and proxy['proto'] in [ProxyProto.vless, ProxyProto.trojan]: baseurl += '&headerType=http' else: baseurl += '&headerType=None' diff --git a/hiddifypanel/hutils/proxy/xrayjson.py b/hiddifypanel/hutils/proxy/xrayjson.py index b06f87e07..3a238e355 100644 --- a/hiddifypanel/hutils/proxy/xrayjson.py +++ b/hiddifypanel/hutils/proxy/xrayjson.py @@ -262,9 +262,9 @@ def add_stream_settings(base: dict, proxy: dict): if proxy['transport'] == ProxyTransport.httpupgrade: ss['network'] = proxy['transport'] add_httpupgrade_stream(ss, proxy) - if proxy['transport'] == ProxyTransport.splithttp: + if proxy['transport'] == ProxyTransport.xhttp: ss['network'] = proxy['transport'] - add_splithttp_stream(ss, proxy) + add_xhttp_stream(ss, proxy) if proxy['transport'] == 'ws': ss['network'] = proxy['transport'] add_ws_stream(ss, proxy) @@ -338,8 +338,8 @@ def add_httpupgrade_stream(ss: dict, proxy: dict): } -def add_splithttp_stream(ss: dict, proxy: dict): - ss['splithttpSettings'] = { +def add_xhttp_stream(ss: dict, proxy: dict): + ss['xhttpSettings'] = { 'path': proxy['path'], 'host': proxy['host'], "headers": { diff --git a/hiddifypanel/models/config_enum.py b/hiddifypanel/models/config_enum.py index cac07cd3c..bda9c8c10 100644 --- a/hiddifypanel/models/config_enum.py +++ b/hiddifypanel/models/config_enum.py @@ -239,7 +239,7 @@ def dbvalues(cls): ws_enable = _BoolConfigDscr(ConfigCategory.proxies, ApplyMode.apply_config) grpc_enable = _BoolConfigDscr(ConfigCategory.proxies, ApplyMode.apply_config) httpupgrade_enable = _BoolConfigDscr(ConfigCategory.proxies, ApplyMode.apply_config) - splithttp_enable = _BoolConfigDscr(ConfigCategory.proxies, ApplyMode.apply_config) + xhttp_enable = _BoolConfigDscr(ConfigCategory.proxies, ApplyMode.apply_config) vless_enable = _BoolConfigDscr(ConfigCategory.proxies, ApplyMode.apply_config) trojan_enable = _BoolConfigDscr(ConfigCategory.proxies, ApplyMode.apply_config) @@ -262,7 +262,7 @@ def dbvalues(cls): path_v2ray = _StrConfigDscr(ConfigCategory.hidden, ApplyMode.apply_config, hide_in_virtual_child=True) # deprecated path_ss = _StrConfigDscr(ConfigCategory.hidden, ApplyMode.apply_config, hide_in_virtual_child=True) - path_splithttp = _StrConfigDscr(ConfigCategory.too_advanced, ApplyMode.apply_config, hide_in_virtual_child=True) + path_xhttp = _StrConfigDscr(ConfigCategory.too_advanced, ApplyMode.apply_config, hide_in_virtual_child=True) path_httpupgrade = _StrConfigDscr(ConfigCategory.too_advanced, ApplyMode.apply_config, hide_in_virtual_child=True) path_ws = _StrConfigDscr(ConfigCategory.too_advanced, ApplyMode.apply_config, hide_in_virtual_child=True) path_tcp = _StrConfigDscr(ConfigCategory.too_advanced, ApplyMode.apply_config, hide_in_virtual_child=True) diff --git a/hiddifypanel/models/proxy.py b/hiddifypanel/models/proxy.py index 566da8ea6..6891a3b13 100644 --- a/hiddifypanel/models/proxy.py +++ b/hiddifypanel/models/proxy.py @@ -20,7 +20,7 @@ class ProxyTransport(StrEnum): tcp = auto() ssh = auto() httpupgrade = auto() - splithttp = auto() + xhttp = auto() custom = auto() shadowsocks = auto() diff --git a/hiddifypanel/panel/init_db.py b/hiddifypanel/panel/init_db.py index 82b9911af..55afb2383 100644 --- a/hiddifypanel/panel/init_db.py +++ b/hiddifypanel/panel/init_db.py @@ -77,7 +77,7 @@ def _v94(child_id): def _v93(child_id): set_hconfig(ConfigEnum.quic_enable, True) - set_hconfig(ConfigEnum.splithttp_enable, True) + set_hconfig(ConfigEnum.xhttp_enable, True) def _v92(child_id): @@ -85,9 +85,9 @@ def _v92(child_id): def _v89(child_id): - set_hconfig(ConfigEnum.path_splithttp, + set_hconfig(ConfigEnum.path_xhttp, hutils.random.get_random_string(7, 15)) - set_hconfig(ConfigEnum.splithttp_enable, False) + set_hconfig(ConfigEnum.xhttp_enable, False) pass @@ -218,7 +218,7 @@ def _v65(): add_config_if_not_exist(ConfigEnum.mux_min_streams, '4') add_config_if_not_exist(ConfigEnum.mux_max_streams, '0') add_config_if_not_exist(ConfigEnum.mux_padding_enable, False) - add_config_if_not_exist(ConfigEnum.mux_brutal_enable, True) + add_config_if_not_exist(ConfigEnum.mux_brutal_enable, False) add_config_if_not_exist(ConfigEnum.mux_brutal_up_mbps, '100') add_config_if_not_exist(ConfigEnum.mux_brutal_down_mbps, '100') @@ -571,9 +571,9 @@ def get_proxy_rows_v1(): "httpupgrade direct vless", # "httpupgrade direct trojan", "httpupgrade direct vmess", - "splithttp direct vless", - "splithttp direct trojan", - "splithttp direct vmess", + "xhttp direct vless", + "xhttp direct trojan", + "xhttp direct vmess", "tcp direct vless", "tcp direct trojan", "tcp direct vmess", @@ -591,9 +591,9 @@ def get_proxy_rows_v1(): # "httpupgrade relay trojan", "httpupgrade relay vmess", - "splithttp relay vless", - "splithttp relay trojan", - "splithttp relay vmess", + "xhttp relay vless", + "xhttp relay trojan", + "xhttp relay vmess", "tcp relay vless", "tcp relay trojan", @@ -615,9 +615,9 @@ def get_proxy_rows_v1(): # "httpupgrade CDN trojan", "httpupgrade CDN vmess", - "splithttp CDN vless", - "splithttp CDN trojan", - "splithttp CDN vmess", + "xhttp CDN vless", + "xhttp CDN trojan", + "xhttp CDN vmess", "grpc CDN vless", "grpc CDN trojan", @@ -663,7 +663,7 @@ def make_proxy_rows(cfgs): for l3 in [ProxyL3.h3_quic, "tls_h2", "tls", "http", "reality"]: for c in cfgs: transport, cdn, proto = c.split(" ") - if transport != ProxyTransport.splithttp and l3 == ProxyL3.h3_quic: + if transport != ProxyTransport.xhttp and l3 == ProxyL3.h3_quic: continue if l3 in ["kcp", 'reality'] and cdn != "direct": continue @@ -750,8 +750,11 @@ def add_new_enum_values(): continue # Add the new value to the enum column in the database - enumstr = ','.join([f"'{a}'" for a in [*existing_values, *old_values]]) - + # enumstr = ','.join([f"'{a}'" for a in [*existing_values, *old_values]]) + enumstr = ','.join([f"'{a}'" for a in [*existing_values]]) + expired_enumstr = ','.join([f"'{a}'" for a in [*old_values]]) + db_execute( + f"delete from {table_name} where `{column_name}` in ({expired_enumstr});", commit=True) db_execute( f"ALTER TABLE {table_name} MODIFY COLUMN `{column_name}` ENUM({enumstr});", commit=True) diff --git a/hiddifypanel/translations.i18n/fr.json b/hiddifypanel/translations.i18n/fr.json index 2a174043f..8ca157cce 100644 --- a/hiddifypanel/translations.i18n/fr.json +++ b/hiddifypanel/translations.i18n/fr.json @@ -642,7 +642,7 @@ "description": "ça devrait être aléatoire", "label": "ℹ️ Chemin de mise à niveau HTTP" }, - "path_splithttp": { + "path_xhttp": { "description": "Cette option définit le chemin pour Split HTTP", "label": "Chemin pour le HTTP fractionné" }, @@ -778,7 +778,7 @@ "description": "Autorisez vos utilisateurs à effectuer des tests de vitesse. Cela les aide à identifier la qualité du lien", "label": "🚀 Test de vitesse" }, - "splithttp_enable": { + "xhttp_enable": { "description": "Ce protocole envoie et reçoit des informations dans des canaux individuels ", "label": "🈁 Split HTTP" }, diff --git a/hiddifypanel/translations.i18n/my.json b/hiddifypanel/translations.i18n/my.json index cc0f16b04..1fd8e381f 100644 --- a/hiddifypanel/translations.i18n/my.json +++ b/hiddifypanel/translations.i18n/my.json @@ -642,7 +642,7 @@ "description": "ကျပန်းဖြစ်သင့်သည်", "label": "ℹ️ HTTP အဆင့်မြှင့်တင်မှု လမ်းကြောင်း" }, - "path_splithttp": { + "path_xhttp": { "description": "ဤရွေးချယ်မှုသည် Split HTTP အတွက် လမ်းကြောင်းကို သတ်မှတ်သည်။", "label": "ℹ️ Split HTTP အတွက် လမ်းကြောင်း" }, @@ -778,7 +778,7 @@ "description": "သင့်အသုံးပြုသူများကို အမြန်နှုန်းစမ်းသပ်မှု ပြုလုပ်ခွင့်ပြုရန်။ ၎င်းသည် ၎င်းတို့အား လင့်ခ်အရည်အသွေးကို ခွဲခြားသတ်မှတ်ရန် ကူညီပေးသည်။", "label": "🚀 အမြန်နှုန်း စမ်းသပ်" }, - "splithttp_enable": { + "xhttp_enable": { "description": "ဤပရိုတိုကောသည် ချန်နယ်တစ်ခုချင်းစီတွင် အချက်အလက်များကို ပေးပို့လက်ခံသည်", "label": "🈁 Split HTTP" },