Browse Source

update: compatible filter

master
dnomd343 2 years ago
parent
commit
3a6da0e8e6
  1. 4
      ProxyFilter/Brook.py
  2. 4
      ProxyFilter/Hysteria.py
  3. 4
      ProxyFilter/Shadowsocks.py
  4. 4
      ProxyFilter/ShadowsocksR.py
  5. 4
      ProxyFilter/Trojan.py
  6. 4
      ProxyFilter/TrojanGo.py
  7. 4
      ProxyFilter/VLESS.py
  8. 4
      ProxyFilter/VMess.py
  9. 17
      ProxyFilter/filter.py

4
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'] == '':

4
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'

4
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'

4
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无参数

4
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)

4
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'

4
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)

4
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)

17
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'

Loading…
Cancel
Save