From 3a6da0e8e64c01729b3df3c89186b9402cb1d417 Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Tue, 2 Aug 2022 17:34:07 +0800 Subject: [PATCH] update: compatible filter --- ProxyFilter/Brook.py | 4 +--- ProxyFilter/Hysteria.py | 4 +--- ProxyFilter/Shadowsocks.py | 4 +--- ProxyFilter/ShadowsocksR.py | 4 +--- ProxyFilter/Trojan.py | 4 +--- ProxyFilter/TrojanGo.py | 4 +--- ProxyFilter/VLESS.py | 4 +--- ProxyFilter/VMess.py | 4 +--- ProxyFilter/filter.py | 17 +++++++++-------- 9 files changed, 17 insertions(+), 32 deletions(-) diff --git a/ProxyFilter/Brook.py b/ProxyFilter/Brook.py index 20008e2..5ba774a 100644 --- a/ProxyFilter/Brook.py +++ b/ProxyFilter/Brook.py @@ -83,9 +83,7 @@ def filte(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: try: if not isExtra: # 去除非必要参数 brookFilterRules['rootObject'].pop('remark') - status, result = baseFunc.ruleFilter(rawInfo, brookFilterRules, { - 'type': 'brook' - }) + status, result = baseFunc.ruleFilter(rawInfo, brookFilterRules, {}) if not status: # 节点格式错误 return False, result if result['ws'] is not None and result['ws']['host'] == '': diff --git a/ProxyFilter/Hysteria.py b/ProxyFilter/Hysteria.py index 87a7a91..5498f5b 100644 --- a/ProxyFilter/Hysteria.py +++ b/ProxyFilter/Hysteria.py @@ -85,8 +85,6 @@ def filte(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: try: if not isExtra: # 去除非必要参数 hysteriaFilterRules['rootObject'].pop('remark') - return baseFunc.ruleFilter(rawInfo, hysteriaFilterRules, { - 'type': 'hysteria' - }) + return baseFunc.ruleFilter(rawInfo, hysteriaFilterRules, {}) except: return False, 'Unknown error' diff --git a/ProxyFilter/Shadowsocks.py b/ProxyFilter/Shadowsocks.py index 3f39f39..257f871 100644 --- a/ProxyFilter/Shadowsocks.py +++ b/ProxyFilter/Shadowsocks.py @@ -130,8 +130,6 @@ def ssFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: try: if not isExtra: # 去除非必要参数 ssFilterRules['rootObject'].pop('remark') - return baseFunc.ruleFilter(rawInfo, ssFilterRules, { - 'type': 'ss' - }) + return baseFunc.ruleFilter(rawInfo, ssFilterRules, {}) except: return False, 'Unknown error' diff --git a/ProxyFilter/ShadowsocksR.py b/ProxyFilter/ShadowsocksR.py index af238aa..4d598f5 100644 --- a/ProxyFilter/ShadowsocksR.py +++ b/ProxyFilter/ShadowsocksR.py @@ -173,9 +173,7 @@ def ssrFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: if not isExtra: # 去除非必要参数 ssrFilterRules['rootObject'].pop('remark') ssrFilterRules['rootObject'].pop('group') - status, result = baseFunc.ruleFilter(rawInfo, ssrFilterRules, { - 'type': 'ssr' - }) + status, result = baseFunc.ruleFilter(rawInfo, ssrFilterRules, {}) if not status: # 节点格式错误 return False, result if result['protocol'] == 'origin': # origin无参数 diff --git a/ProxyFilter/Trojan.py b/ProxyFilter/Trojan.py index 39e356b..cc2e8a5 100644 --- a/ProxyFilter/Trojan.py +++ b/ProxyFilter/Trojan.py @@ -66,9 +66,7 @@ def trojanFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: trojanFilterRules['rootObject'].pop('remark') for key, obj in Xray.xrayStreamRules.items(): # xray.stream -> trojan trojanFilterRules[key] = obj - status, result = baseFunc.ruleFilter(rawInfo, trojanFilterRules, { - 'type': 'trojan' - }) + status, result = baseFunc.ruleFilter(rawInfo, trojanFilterRules, {}) if not status: # 节点格式错误 return False, result Xray.addSni(result) diff --git a/ProxyFilter/TrojanGo.py b/ProxyFilter/TrojanGo.py index 653e589..de0b532 100644 --- a/ProxyFilter/TrojanGo.py +++ b/ProxyFilter/TrojanGo.py @@ -133,8 +133,6 @@ def trojanGoFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: try: if not isExtra: # 去除非必要参数 trojanGoFilterRules['rootObject'].pop('remark') - return baseFunc.ruleFilter(rawInfo, trojanGoFilterRules, { - 'type': 'trojan-go' - }) + return baseFunc.ruleFilter(rawInfo, trojanGoFilterRules, {}) except: return False, 'Unknown error' diff --git a/ProxyFilter/VLESS.py b/ProxyFilter/VLESS.py index 8f2d19a..1a87779 100644 --- a/ProxyFilter/VLESS.py +++ b/ProxyFilter/VLESS.py @@ -76,9 +76,7 @@ def vlessFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: vlessFilterRules['rootObject'].pop('remark') for key, obj in Xray.xrayStreamRules.items(): # xray.stream -> vless vlessFilterRules[key] = obj - status, result = baseFunc.ruleFilter(rawInfo, vlessFilterRules, { - 'type': 'vless' - }) + status, result = baseFunc.ruleFilter(rawInfo, vlessFilterRules, {}) if not status: # 节点格式错误 return False, result Xray.addSni(result) diff --git a/ProxyFilter/VMess.py b/ProxyFilter/VMess.py index eacef70..3cb8dfd 100644 --- a/ProxyFilter/VMess.py +++ b/ProxyFilter/VMess.py @@ -90,9 +90,7 @@ def vmessFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: vmessFilterRules['rootObject'].pop('remark') for key, obj in V2ray.v2rayStreamRules.items(): # v2ray.stream -> vmess vmessFilterRules[key] = obj - status, result = baseFunc.ruleFilter(rawInfo, vmessFilterRules, { - 'type': 'vmess' - }) + status, result = baseFunc.ruleFilter(rawInfo, vmessFilterRules, {}) if not status: # 节点格式错误 return False, result V2ray.addSni(result) diff --git a/ProxyFilter/filter.py b/ProxyFilter/filter.py index df9997b..c4713b0 100644 --- a/ProxyFilter/filter.py +++ b/ProxyFilter/filter.py @@ -28,23 +28,24 @@ def filte(raw: dict, isExtra: bool = False) -> tuple[bool, str or dict]: if 'type' not in raw: return False, 'Missing `type` option' if raw['type'] == 'ss': - return Shadowsocks.ssFilter(raw, isExtra) + status, raw['info'] = Shadowsocks.ssFilter(raw['info'], isExtra) elif raw['type'] == 'ssr': - return ShadowsocksR.ssrFilter(raw, isExtra) + status, raw['info'] = ShadowsocksR.ssrFilter(raw['info'], isExtra) elif raw['type'] == 'vmess': - return VMess.vmessFilter(raw, isExtra) + status, raw['info'] = VMess.vmessFilter(raw['info'], isExtra) elif raw['type'] == 'vless': - return VLESS.vlessFilter(raw, isExtra) + status, raw['info'] = VLESS.vlessFilter(raw['info'], isExtra) elif raw['type'] == 'trojan': - return Trojan.trojanFilter(raw, isExtra) + status, raw['info'] = Trojan.trojanFilter(raw['info'], isExtra) elif raw['type'] == 'trojan-go': - return TrojanGo.trojanGoFilter(raw, isExtra) + status, raw['info'] = TrojanGo.trojanGoFilter(raw['info'], isExtra) elif raw['type'] == 'brook': - return Brook.filte(raw, isExtra) + status, raw['info'] = Brook.filte(raw['info'], isExtra) elif raw['type'] == 'hysteria': - return Hysteria.filte(raw, isExtra) + status, raw['info'] = Hysteria.filte(raw['info'], isExtra) else: return False, 'Unknown proxy type' + return status, raw except: pass return False, 'Unknown error'