Browse Source

feat: shadowsocksr of ProxyTester

master
Dnomd343 3 years ago
parent
commit
cc274eb5b7
  1. 94
      ProxyTester/ShadowsocksR.py
  2. 3
      ProxyTester/tester.py

94
ProxyTester/ShadowsocksR.py

@ -1,6 +1,8 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
config = {}
ssrMethodList = [ ssrMethodList = [
"aes-128-cfb", "aes-128-cfb",
"aes-192-cfb", "aes-192-cfb",
@ -71,57 +73,43 @@ ssrObfsList = [
"random_head", "random_head",
] ]
def test(port, password): def __ssrServerConfig(method: str, protocol: str, obfs: str, caption: str) -> list:
testList = [] proxyInfo = {
for method in ssrMethodList: 'type': 'ssr',
proxyInfo = { 'server': '127.0.0.1',
'type': 'ssr', 'port': config['port'],
'server': '127.0.0.1', 'passwd': config['passwd'],
'port': int(port), 'method': method,
'password': password, 'protocol': protocol,
'method': method, 'obfs': obfs
'protocol': 'origin', }
'protocolParam': '', serverCommand = [
'obfs': 'plain', 'ssr-server',
'obfsParam': '' '-p', str(config['port']),
} '-k', config['passwd'],
serverCommand = [ '-m', method,
'ssr-server', '-O', protocol,
'-p', str(port), '-o', obfs
'-k', password, ]
'-m', method, return [{
'-O', 'origin', 'caption': caption,
'-o', 'plain' 'proxy': proxyInfo,
] 'server': {
testList.append({ 'startCommand': serverCommand,
'caption': 'ShadowsocksR method ' + method, 'fileContent': None,
'proxyInfo': proxyInfo, 'filePath': None,
'serverCommand': serverCommand 'envVar': {}
}) },
for protocol in ssrProtocolList: 'aider': None
}]
def ssrTest(ssrConfig: dict) -> list:
result = []
for key, value in ssrConfig.items(): # ssrConfig -> config
config[key] = value
for method in ssrMethodList: # all ShadowsocksR methods
result += __ssrServerConfig(method, 'origin', 'plain', 'ShadowsocksR method ' + method)
for protocol in ssrProtocolList: # all ShadowsocksR protocol and obfs
for obfs in ssrObfsList: for obfs in ssrObfsList:
proxyInfo = { result += __ssrServerConfig('table', protocol, obfs, 'ShadowsocksR protocol ' + protocol + ' obfs ' + obfs)
'type': 'ssr', return result
'server': '127.0.0.1',
'port': int(port),
'password': password,
'method': 'table',
'protocol': protocol,
'protocolParam': '',
'obfs': obfs,
'obfsParam': ''
}
serverCommand = [
'ssr-server',
'-p', str(port),
'-k', password,
'-m', 'table',
'-O', protocol,
'-o', obfs
]
testList.append({
'caption': 'ShadowsocksR protocol ' + protocol + ' obfs ' + obfs,
'proxyInfo': proxyInfo,
'serverCommand': serverCommand
})
return testList

3
ProxyTester/tester.py

@ -2,12 +2,13 @@
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
from ProxyTester import Shadowsocks from ProxyTester import Shadowsocks
from ProxyTester import ShadowsocksR
def test(key: str, config: dict) -> list: def test(key: str, config: dict) -> list:
if key == 'ss': if key == 'ss':
return Shadowsocks.ssTest(config) return Shadowsocks.ssTest(config)
elif key == 'ssr': elif key == 'ssr':
pass return ShadowsocksR.ssrTest(config)
elif key == 'vmess': elif key == 'vmess':
pass pass
else: else:

Loading…
Cancel
Save