mirror of https://github.com/dnomd343/ProxyC
dnomd343
2 years ago
5 changed files with 134 additions and 54 deletions
@ -1,5 +1,58 @@ |
|||
#!/usr/bin/env python3 |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
import copy |
|||
from Basis.Functions import toStr |
|||
from Basis.Filter import rulesFilter |
|||
from Basis.Constant import pluginClients |
|||
|
|||
pluginAlias = { |
|||
'obfs-local': {'obfs', 'simple-obfs'}, |
|||
'simple-tls': {'tls', 'simple-tls'}, |
|||
'v2ray-plugin': {'v2ray'}, |
|||
'xray-plugin': {'xray'}, |
|||
'kcptun-client': {'kcptun'}, |
|||
'gost-plugin': {'gost'}, |
|||
'ck-client': {'ck', 'cloak'}, |
|||
'gq-client': {'gq', 'goquiet', 'go-quiet'}, |
|||
'mtt-client': {'mtt', 'mos-tls-tunnel'}, |
|||
'rabbit-plugin': {'rabbit', 'rabbit-tcp'}, |
|||
'qtun-client': {'qtun'}, |
|||
'gun-plugin': {'gun'}, |
|||
} |
|||
|
|||
pluginObject = rulesFilter({ |
|||
'type': { |
|||
'type': str, |
|||
'format': lambda s: pluginFormat(toStr(s)), |
|||
'filter': lambda s: s in pluginClients, |
|||
'errMsg': 'Unknown SIP003 plugin' |
|||
}, |
|||
'param': { |
|||
'optional': True, |
|||
'default': '', |
|||
'type': str, |
|||
'format': toStr, |
|||
'errMsg': 'Invalid SIP003 param' |
|||
} |
|||
}) |
|||
|
|||
|
|||
def loadAlias() -> None: |
|||
for plugin in pluginAlias: |
|||
for alias in copy.copy(pluginAlias[plugin]): |
|||
pluginAlias[plugin].update({ # better compatibility |
|||
alias + '-local', alias + '-plugin', |
|||
alias + '-client', alias + '-server', |
|||
}) |
|||
|
|||
|
|||
def pluginFormat(pluginName: str) -> str: |
|||
return pluginName |
|||
pluginName = pluginName.strip().lower().replace('_', '-') |
|||
for plugin, alias in pluginAlias.items(): |
|||
if pluginName in alias: |
|||
return plugin |
|||
return pluginName # alias not found |
|||
|
|||
|
|||
loadAlias() |
|||
|
@ -1,7 +1,22 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
import Filter.Shadowsocks |
|||
from pprint import pprint |
|||
from Basis.Filter import Filter |
|||
from Basis.Filter import filterObject |
|||
from Filter.Shadowsocks import ssObject |
|||
|
|||
# from pprint import pprint |
|||
# from Basis.Filter import filterObject |
|||
# pprint(ssObject, sort_dicts = False) |
|||
# pprint(filterObject, sort_dicts = False) |
|||
|
|||
ssProxy = { |
|||
'server': '1.1.1.1', |
|||
'port': '12345', |
|||
'method': 'none', |
|||
'passwd': 'dnomd343', |
|||
'plugin': { |
|||
'type': 'obfs', |
|||
|
|||
} |
|||
} |
|||
ret = Filter(ssProxy, ssObject) |
|||
pprint(ret, sort_dicts = False) |
|||
|
Loading…
Reference in new issue