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: try:
if not isExtra: # 去除非必要参数 if not isExtra: # 去除非必要参数
brookFilterRules['rootObject'].pop('remark') brookFilterRules['rootObject'].pop('remark')
status, result = baseFunc.ruleFilter(rawInfo, brookFilterRules, { status, result = baseFunc.ruleFilter(rawInfo, brookFilterRules, {})
'type': 'brook'
})
if not status: # 节点格式错误 if not status: # 节点格式错误
return False, result return False, result
if result['ws'] is not None and result['ws']['host'] == '': 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: try:
if not isExtra: # 去除非必要参数 if not isExtra: # 去除非必要参数
hysteriaFilterRules['rootObject'].pop('remark') hysteriaFilterRules['rootObject'].pop('remark')
return baseFunc.ruleFilter(rawInfo, hysteriaFilterRules, { return baseFunc.ruleFilter(rawInfo, hysteriaFilterRules, {})
'type': 'hysteria'
})
except: except:
return False, 'Unknown error' return False, 'Unknown error'

4
ProxyFilter/Shadowsocks.py

@ -130,8 +130,6 @@ def ssFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]:
try: try:
if not isExtra: # 去除非必要参数 if not isExtra: # 去除非必要参数
ssFilterRules['rootObject'].pop('remark') ssFilterRules['rootObject'].pop('remark')
return baseFunc.ruleFilter(rawInfo, ssFilterRules, { return baseFunc.ruleFilter(rawInfo, ssFilterRules, {})
'type': 'ss'
})
except: except:
return False, 'Unknown error' 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: # 去除非必要参数 if not isExtra: # 去除非必要参数
ssrFilterRules['rootObject'].pop('remark') ssrFilterRules['rootObject'].pop('remark')
ssrFilterRules['rootObject'].pop('group') ssrFilterRules['rootObject'].pop('group')
status, result = baseFunc.ruleFilter(rawInfo, ssrFilterRules, { status, result = baseFunc.ruleFilter(rawInfo, ssrFilterRules, {})
'type': 'ssr'
})
if not status: # 节点格式错误 if not status: # 节点格式错误
return False, result return False, result
if result['protocol'] == 'origin': # origin无参数 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') trojanFilterRules['rootObject'].pop('remark')
for key, obj in Xray.xrayStreamRules.items(): # xray.stream -> trojan for key, obj in Xray.xrayStreamRules.items(): # xray.stream -> trojan
trojanFilterRules[key] = obj trojanFilterRules[key] = obj
status, result = baseFunc.ruleFilter(rawInfo, trojanFilterRules, { status, result = baseFunc.ruleFilter(rawInfo, trojanFilterRules, {})
'type': 'trojan'
})
if not status: # 节点格式错误 if not status: # 节点格式错误
return False, result return False, result
Xray.addSni(result) Xray.addSni(result)

4
ProxyFilter/TrojanGo.py

@ -133,8 +133,6 @@ def trojanGoFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]:
try: try:
if not isExtra: # 去除非必要参数 if not isExtra: # 去除非必要参数
trojanGoFilterRules['rootObject'].pop('remark') trojanGoFilterRules['rootObject'].pop('remark')
return baseFunc.ruleFilter(rawInfo, trojanGoFilterRules, { return baseFunc.ruleFilter(rawInfo, trojanGoFilterRules, {})
'type': 'trojan-go'
})
except: except:
return False, 'Unknown error' 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') vlessFilterRules['rootObject'].pop('remark')
for key, obj in Xray.xrayStreamRules.items(): # xray.stream -> vless for key, obj in Xray.xrayStreamRules.items(): # xray.stream -> vless
vlessFilterRules[key] = obj vlessFilterRules[key] = obj
status, result = baseFunc.ruleFilter(rawInfo, vlessFilterRules, { status, result = baseFunc.ruleFilter(rawInfo, vlessFilterRules, {})
'type': 'vless'
})
if not status: # 节点格式错误 if not status: # 节点格式错误
return False, result return False, result
Xray.addSni(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') vmessFilterRules['rootObject'].pop('remark')
for key, obj in V2ray.v2rayStreamRules.items(): # v2ray.stream -> vmess for key, obj in V2ray.v2rayStreamRules.items(): # v2ray.stream -> vmess
vmessFilterRules[key] = obj vmessFilterRules[key] = obj
status, result = baseFunc.ruleFilter(rawInfo, vmessFilterRules, { status, result = baseFunc.ruleFilter(rawInfo, vmessFilterRules, {})
'type': 'vmess'
})
if not status: # 节点格式错误 if not status: # 节点格式错误
return False, result return False, result
V2ray.addSni(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: if 'type' not in raw:
return False, 'Missing `type` option' return False, 'Missing `type` option'
if raw['type'] == 'ss': if raw['type'] == 'ss':
return Shadowsocks.ssFilter(raw, isExtra) status, raw['info'] = Shadowsocks.ssFilter(raw['info'], isExtra)
elif raw['type'] == 'ssr': elif raw['type'] == 'ssr':
return ShadowsocksR.ssrFilter(raw, isExtra) status, raw['info'] = ShadowsocksR.ssrFilter(raw['info'], isExtra)
elif raw['type'] == 'vmess': elif raw['type'] == 'vmess':
return VMess.vmessFilter(raw, isExtra) status, raw['info'] = VMess.vmessFilter(raw['info'], isExtra)
elif raw['type'] == 'vless': elif raw['type'] == 'vless':
return VLESS.vlessFilter(raw, isExtra) status, raw['info'] = VLESS.vlessFilter(raw['info'], isExtra)
elif raw['type'] == 'trojan': elif raw['type'] == 'trojan':
return Trojan.trojanFilter(raw, isExtra) status, raw['info'] = Trojan.trojanFilter(raw['info'], isExtra)
elif raw['type'] == 'trojan-go': elif raw['type'] == 'trojan-go':
return TrojanGo.trojanGoFilter(raw, isExtra) status, raw['info'] = TrojanGo.trojanGoFilter(raw['info'], isExtra)
elif raw['type'] == 'brook': elif raw['type'] == 'brook':
return Brook.filte(raw, isExtra) status, raw['info'] = Brook.filte(raw['info'], isExtra)
elif raw['type'] == 'hysteria': elif raw['type'] == 'hysteria':
return Hysteria.filte(raw, isExtra) status, raw['info'] = Hysteria.filte(raw['info'], isExtra)
else: else:
return False, 'Unknown proxy type' return False, 'Unknown proxy type'
return status, raw
except: except:
pass pass
return False, 'Unknown error' return False, 'Unknown error'

Loading…
Cancel
Save