Browse Source

update: compatible decoder

master
dnomd343 2 years ago
parent
commit
6f8d2ce939
  1. 4
      ProxyDecoder/Brook.py
  2. 4
      ProxyDecoder/Shadowsocks.py
  3. 10
      ProxyDecoder/ShadowsocksR.py
  4. 4
      ProxyDecoder/Trojan.py
  5. 4
      ProxyDecoder/TrojanGo.py
  6. 4
      ProxyDecoder/VLESS.py
  7. 4
      ProxyDecoder/VMess.py
  8. 2
      ProxyDecoder/__init__.py
  9. 2
      ProxyDecoder/decoder.py

4
ProxyDecoder/Brook.py

@ -81,6 +81,6 @@ def decode(url: str) -> dict:
if url.split('://')[0] != 'brook': if url.split('://')[0] != 'brook':
raise Exception('Unexpected scheme') raise Exception('Unexpected scheme')
return { return {
**{'type': 'brook'}, 'type': 'brook',
**__brookDecode(url) 'info': __brookDecode(url),
} }

4
ProxyDecoder/Shadowsocks.py

@ -137,6 +137,6 @@ def decode(url: str, compatible: bool = False) -> dict or None:
if compatible and 'remark' in ssInfo: # 向后兼容部分客户端 if compatible and 'remark' in ssInfo: # 向后兼容部分客户端
ssInfo['remark'] = ssInfo['remark'].replace('+', ' ') ssInfo['remark'] = ssInfo['remark'].replace('+', ' ')
return { return {
**{'type': 'ss'}, 'type': 'ss',
**ssInfo 'info': ssInfo,
} }

10
ProxyDecoder/ShadowsocksR.py

@ -44,7 +44,13 @@ def __ssrDecode(url: str) -> dict: # SSR分享链接解码
def decode(url: str) -> dict: def decode(url: str) -> dict:
if url.split('://')[0] != 'ssr': if url.split('://')[0] != 'ssr':
raise Exception('Unexpected scheme') raise Exception('Unexpected scheme')
ssrObject = __ssrDecode(url)
group = ''
if 'group' in ssrObject:
group = ssrObject['group']
ssrObject.pop('group')
return { return {
**{'type': 'ssr'}, 'type': 'ssr',
**__ssrDecode(url) 'group': group,
'info': ssrObject,
} }

4
ProxyDecoder/Trojan.py

@ -129,6 +129,6 @@ def decode(url: str) -> dict:
if url.split('://')[0] != 'trojan': if url.split('://')[0] != 'trojan':
raise Exception('Unexpected scheme') raise Exception('Unexpected scheme')
return { return {
**{'type': 'trojan'}, 'type': 'trojan',
**__trojanDecode(url) 'info': __trojanDecode(url),
} }

4
ProxyDecoder/TrojanGo.py

@ -77,6 +77,6 @@ def decode(url: str) -> dict:
if url.split('://')[0] != 'trojan-go': if url.split('://')[0] != 'trojan-go':
raise Exception('Unexpected scheme') raise Exception('Unexpected scheme')
return { return {
**{'type': 'trojan-go'}, 'type': 'trojan-go',
**__trojanGoDecode(url) 'info': __trojanGoDecode(url),
} }

4
ProxyDecoder/VLESS.py

@ -127,6 +127,6 @@ def decode(url: str) -> dict:
if url.split('://')[0] != 'vless': if url.split('://')[0] != 'vless':
raise Exception('Unexpected scheme') raise Exception('Unexpected scheme')
return { return {
**{'type': 'vless'}, 'type': 'vless',
**__vlessDecode(url) 'info': __vlessDecode(url),
} }

4
ProxyDecoder/VMess.py

@ -222,6 +222,6 @@ def decode(url: str) -> dict:
except: except:
raise Exception('Url could not be parsed') raise Exception('Url could not be parsed')
return { return {
**{'type': 'vmess'}, 'type': 'vmess',
**vmessInfo 'info': vmessInfo,
} }

2
ProxyDecoder/__init__.py

@ -1,6 +1,8 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
# TODO: this module will refactor in the future
from ProxyDecoder.decoder import * from ProxyDecoder.decoder import *
__all__ = ['decode'] __all__ = ['decode']

2
ProxyDecoder/decoder.py

@ -20,7 +20,7 @@ def decode(url: str) -> dict or None:
链接有效: 链接有效:
return { return {
'type': ..., 'type': ...,
... 'info': {...},
} }
""" """
try: try:

Loading…
Cancel
Save