mirror of https://github.com/dnomd343/ProxyC
Dnomd343
3 years ago
3 changed files with 120 additions and 24 deletions
@ -0,0 +1,92 @@ |
|||||
|
#!/usr/bin/python |
||||
|
# -*- coding:utf-8 -*- |
||||
|
|
||||
|
from ProxyFilter import baseFunc |
||||
|
|
||||
|
hysteriaFilterRules = { |
||||
|
'rootObject': { |
||||
|
'remark': { |
||||
|
'optional': False, |
||||
|
'default': '', |
||||
|
'type': str, |
||||
|
'format': baseFunc.toStr |
||||
|
}, |
||||
|
'server': { |
||||
|
'optional': True, |
||||
|
'type': str, |
||||
|
'format': baseFunc.toHost, |
||||
|
'filter': baseFunc.isHost, |
||||
|
'errMsg': 'Illegal server address' |
||||
|
}, |
||||
|
'port': { |
||||
|
'optional': True, |
||||
|
'type': int, |
||||
|
'format': baseFunc.toInt, |
||||
|
'filter': baseFunc.isPort, |
||||
|
'errMsg': 'Illegal port number' |
||||
|
}, |
||||
|
'protocol': { |
||||
|
'optional': False, |
||||
|
'default': 'udp', |
||||
|
'type': str, |
||||
|
'format': baseFunc.toStr, |
||||
|
'filter': lambda protocol: protocol in ['udp', 'wechat-video', 'faketcp'], |
||||
|
'errMsg': 'Unknown Hysteria protocol' |
||||
|
}, |
||||
|
'obfs': { |
||||
|
'optional': False, |
||||
|
'default': None, |
||||
|
'allowNone': True, |
||||
|
'type': str, |
||||
|
'format': baseFunc.toStr |
||||
|
}, |
||||
|
'auth': { |
||||
|
'optional': False, |
||||
|
'default': None, |
||||
|
'allowNone': True, |
||||
|
'type': str, |
||||
|
'format': baseFunc.toStr |
||||
|
}, |
||||
|
'sni': { |
||||
|
'optional': False, |
||||
|
'default': '', |
||||
|
'type': str, |
||||
|
'format': baseFunc.toStr |
||||
|
}, |
||||
|
'alpn': { |
||||
|
'optional': False, |
||||
|
'default': None, |
||||
|
'allowNone': True, |
||||
|
'type': str, |
||||
|
'format': baseFunc.toStr |
||||
|
}, |
||||
|
'verify': { |
||||
|
'optional': False, |
||||
|
'default': True, |
||||
|
'type': bool, |
||||
|
'format': baseFunc.toBool |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
def filte(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: |
||||
|
""" |
||||
|
Hysteria节点合法性检查 |
||||
|
|
||||
|
不合法: |
||||
|
return False, {reason} |
||||
|
|
||||
|
合法: |
||||
|
return True, { |
||||
|
'type': 'hysteria', |
||||
|
... |
||||
|
} |
||||
|
""" |
||||
|
try: |
||||
|
if not isExtra: # 去除非必要参数 |
||||
|
hysteriaFilterRules['rootObject'].pop('remark') |
||||
|
return baseFunc.ruleFilter(rawInfo, hysteriaFilterRules, { |
||||
|
'type': 'hysteria' |
||||
|
}) |
||||
|
except: |
||||
|
return False, 'Unknown error' |
@ -1,24 +1,25 @@ |
|||||
import time |
import time |
||||
|
|
||||
import ProxyBuilder as Builder |
import ProxyBuilder as Builder |
||||
import ProxyDecoder as Decoder |
import ProxyDecoder as Decoder |
||||
import ProxyFilter as Filter |
import ProxyFilter as Filter |
||||
import Check as Checker |
import Check as Checker |
||||
|
|
||||
# url = 'brook://server?address=&insecure=&name=&password=password&server=1.2.3.4%3A9999&username=' |
# ret = Decoder.decode(url) |
||||
# url = 'brook://server?address=&insecure=&name=&password=password&server=%5B2001%3A4860%3A4860%3A%3A8888%5D%3A9999&username=' |
# print(ret) |
||||
# url = 'brook://wsserver?address=&insecure=&name=&password=password&username=&wsserver=ws%3A%2F%2F1.2.3.4%3A9999' |
|
||||
# url = 'brook://wsserver?address=&insecure=&name=&password=password&username=&wsserver=ws%3A%2F%2F%5B2001%3A4860%3A4860%3A%3A8888%5D%3A9999' |
info = { |
||||
# url = 'brook://wssserver?address=1.2.3.4%3A443&insecure=true&name=&password=password&username=&wssserver=wss%3A%2F%2Fhello.com%3A443' |
'type': 'hysteria', |
||||
# url = 'brook://wsserver?address=1.2.3.4%3A443&name=&password=password&username=&wsserver=ws%3A%2F%2Fhello.com%3A443' |
'server': '127.0.0.1', |
||||
|
'port': 443, |
||||
# url = 'ss://bf-cfb:test@192.168.100.1:8888#EXAMPLE' |
'protocol': 'faketcp', |
||||
# url = 'ss://YmYtY2ZiOnRlc3QvIUAjOkAxOTIuMTY4LjEwMC4xOjg4ODg#example-server' |
'obfs': 'dnomd343', |
||||
url = 'ss://cmM0LW1kNTpwYXNzd2Q@192.168.100.1:8888/?plugin=obfs-local%3Bobfs%3Dhttp#Example' |
'auth': 'dnomd343', |
||||
|
'sni': 'local.343.re', |
||||
ret = Decoder.decode(url) |
'alpn': 'h3', |
||||
print(ret) |
'verify': False |
||||
|
} |
||||
status, ret = Filter.filte(ret, isExtra = True) |
|
||||
print(status) |
status, ret = Filter.filte(info, isExtra = True) |
||||
print(ret) |
print(status) |
||||
|
print(ret) |
||||
|
Loading…
Reference in new issue