From a6d7bf67fc30c0c89c010ad599ab072ad9aa88ea Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 24 Feb 2022 18:26:02 +0800 Subject: [PATCH] feat: new ProxyTester --- Checker.py | 15 +- ProxyFilter/filter.py | 2 +- ProxyTester/Plugin.py | 287 ++++++++++++++++++++++++++ ProxyTester/Shadowsocks.py | 200 ++++++++++++++++++ {test => ProxyTester}/ShadowsocksR.py | 0 ProxyTester/__init__.py | 6 + ProxyTester/tester.py | 20 ++ test.py | 109 +++++----- test/Shadowsocks.py | 130 ------------ test/__init__.py | 5 - test/entry.py | 11 - 11 files changed, 585 insertions(+), 200 deletions(-) create mode 100644 ProxyTester/Plugin.py create mode 100644 ProxyTester/Shadowsocks.py rename {test => ProxyTester}/ShadowsocksR.py (100%) create mode 100644 ProxyTester/__init__.py create mode 100644 ProxyTester/tester.py delete mode 100644 test/Shadowsocks.py delete mode 100644 test/__init__.py delete mode 100644 test/entry.py diff --git a/Checker.py b/Checker.py index 0570850..8a967a6 100644 --- a/Checker.py +++ b/Checker.py @@ -6,6 +6,7 @@ import time import ProxyBuilder as Builder import ProxyChecker as Checker +import ProxyFilter as Filter def __loadDir(folderPath: str) -> bool: # 创建文件夹 try: @@ -66,8 +67,14 @@ def proxyTest( return None client = None + status, proxyInfo = Filter.filte(rawInfo['info'], isExtra = True) + if not status: # 输入节点错误 + return { + 'success': False, + 'info': None + } try: - status, client = Builder.build(rawInfo['info'], workDir) + status, client = Builder.build(proxyInfo, workDir) except: # 构建发生未知错误 Builder.destroy(client) return None @@ -77,7 +84,7 @@ def proxyTest( elif not status: # 节点信息有误 return { 'success': False, - 'info': rawInfo['info'] + 'info': proxyInfo } time.sleep(startDelay) # 延迟等待客户端启动 @@ -89,7 +96,7 @@ def proxyTest( Builder.destroy(client) return { 'success': False, - 'info': rawInfo['info'] + 'info': proxyInfo } if 'check' not in rawInfo: # 缺少检测项目 @@ -110,5 +117,5 @@ def proxyTest( return { 'success': True, 'check': checkResult, - 'info': rawInfo['info'] + 'info': proxyInfo } diff --git a/ProxyFilter/filter.py b/ProxyFilter/filter.py index 53b87db..198a0a5 100644 --- a/ProxyFilter/filter.py +++ b/ProxyFilter/filter.py @@ -5,7 +5,7 @@ from ProxyFilter import Shadowsocks from ProxyFilter import ShadowsocksR from ProxyFilter import VMess -def filte(raw: dict, isExtra: bool = False) -> tuple[bool, str]: +def filte(raw: dict, isExtra: bool = False) -> tuple[bool, str or dict]: """ 代理信息过滤并格式化 diff --git a/ProxyTester/Plugin.py b/ProxyTester/Plugin.py new file mode 100644 index 0000000..b041093 --- /dev/null +++ b/ProxyTester/Plugin.py @@ -0,0 +1,287 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +import re +import json + +gqConfig = { + 'key': 'dnomd343' +} + +ckConfig = { + 'BypassUID': [ + 'Q3iw2bAbC3KZvpm58XR6+Q==' + ], + 'RedirAddr': 'www.bing.com', + 'PrivateKey': 'SFMUZ2g7e0jqzXXhBh5/rh/Odslnyu8A3LuZqH4ySVM=' +} + +pluginConfig = { + 'obfs-local': [ + { + 'caption': 'http mode', + 'server': '--plugin obfs-server --plugin-opts "obfs=http"', + 'client': '--plugin obfs-local --plugin-opts "obfs=http;obfs-host=www.bing.com"', + }, + { + 'caption': 'tls mode', + 'server': '--plugin obfs-server --plugin-opts "obfs=tls"', + 'client': '--plugin obfs-local --plugin-opts "obfs=tls;obfs-host=www.bing.com"', + }, + { + 'caption': 'http mode with URI', + 'server': '--plugin obfs-server --plugin-opts "obfs=http"', + 'client': '--plugin obfs-local --plugin-opts "obfs=http;obfs-host=www.bing.com;obfs-uri=/test"', + }, + { + 'caption': 'http mode with POST method', + 'server': '--plugin obfs-server --plugin-opts "obfs=http"', + 'client': '--plugin obfs-local --plugin-opts "obfs=http;http-method=POST;obfs-host=www.bing.com"', + } + ], + 'simple-tls': [ + { + 'caption': 'basic mode', + 'server': '--plugin simple-tls --plugin-opts "s;n=$HOST"', + 'client': '--plugin simple-tls --plugin-opts "n=$HOST;no-verify"', + }, + { + 'caption': 'with auth key', + 'server': '--plugin simple-tls --plugin-opts "s;n=$HOST;auth=dnomd343"', + 'client': '--plugin simple-tls --plugin-opts "n=$HOST;no-verify;auth=dnomd343"', + }, + { + 'caption': 'wss mode', + 'server': '--plugin simple-tls --plugin-opts "s;n=$HOST;ws;ws-path=/test"', + 'client': '--plugin simple-tls --plugin-opts "n=$HOST;no-verify;ws;ws-path=/test"', + } + ], + 'v2ray-plugin': [ + { + 'caption': 'basic mode', + 'server': '--plugin v2ray-plugin --plugin-opts "server"', + 'client': '--plugin v2ray-plugin', + }, + { + 'caption': 'basic with path', + 'server': '--plugin v2ray-plugin --plugin-opts "server;path=/test"', + 'client': '--plugin v2ray-plugin --plugin-opts "path=/test"', + }, + { + 'caption': 'basic mode with tls', + 'server': '--plugin v2ray-plugin --plugin-opts "server;tls;host=$HOST;cert=$CERT;key=$KEY"', + 'client': '--plugin v2ray-plugin --plugin-opts "tls;host=$HOST"', + }, + { + 'caption': 'quic mode', + 'server': '--plugin v2ray-plugin --plugin-opts "server;mode=quic;host=$HOST;cert=$CERT;key=$KEY"', + 'client': '--plugin v2ray-plugin --plugin-opts "mode=quic;host=$HOST"', + } + ], + 'xray-plugin': [ + { + 'caption': 'basic mode', + 'server': '--plugin xray-plugin --plugin-opts "server"', + 'client': '--plugin xray-plugin', + }, + { + 'caption': 'basic mode with tls', + 'server': '--plugin xray-plugin --plugin-opts "server;tls;host=$HOST;cert=$CERT;key=$KEY"', + 'client': '--plugin xray-plugin --plugin-opts "tls;host=$HOST"', + }, + { + 'caption': 'quic mode', + 'server': '--plugin xray-plugin --plugin-opts "server;mode=quic;host=$HOST;cert=$CERT;key=$KEY"', + 'client': '--plugin xray-plugin --plugin-opts "mode=quic;host=$HOST"', + }, + { + 'caption': 'grpc mode', + 'server': '--plugin xray-plugin --plugin-opts "server;mode=grpc;host=$HOST;cert=$CERT;key=$KEY"', + 'client': '--plugin xray-plugin --plugin-opts "mode=grpc"', + }, + { + 'caption': 'grpc mode with tls', + 'server': '--plugin xray-plugin --plugin-opts "server;tls;mode=grpc;host=$HOST;cert=$CERT;key=$KEY"', + 'client': '--plugin xray-plugin --plugin-opts "tls;mode=grpc;host=$HOST"', + } + ], + 'kcptun-client': [ + { + 'caption': 'basic mode', + 'server': '--plugin kcptun-server', + 'client': '--plugin kcptun-client', + }, + { + 'caption': 'with nocomp', + 'server': '--plugin kcptun-server --plugin-opts "nocomp"', + 'client': '--plugin kcptun-client --plugin-opts "nocomp"', + }, + { + 'caption': 'with key', + 'server': '--plugin kcptun-server --plugin-opts "key=dnomd343"', + 'client': '--plugin kcptun-client --plugin-opts "key=dnomd343"', + }, + { + 'caption': 'fast3 mode with twofish crypt', + 'server': '--plugin kcptun-server --plugin-opts "crypt=twofish;mode=fast3"', + 'client': '--plugin kcptun-client --plugin-opts "crypt=twofish;mode=fast3"', + } + ], + 'gost-plugin': [ + { + 'caption': 'ws mode', + 'server': '--plugin gost-plugin --plugin-opts "server;mode=ws"', + 'client': '--plugin gost-plugin --plugin-opts "mode=ws"', + }, + { + 'caption': 'mws mode', + 'server': '--plugin gost-plugin --plugin-opts "server;mode=mws"', + 'client': '--plugin gost-plugin --plugin-opts "mode=mws;mux=1"', + }, + { + 'caption': 'tls mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=tls"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=tls"', + }, + { + 'caption': 'xtls mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=xtls"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=xtls"', + }, + { + 'caption': 'mtls mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=mtls"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=mtls;mux=1"', + }, + { + 'caption': 'h2 mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=h2"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=h2"', + }, + { + 'caption': 'wss mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=wss"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=wss"', + }, + { + 'caption': 'mwss mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=mwss"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=mwss;mux=1"', + }, + { + 'caption': 'quic mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=quic"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=quic"', + }, + { + 'caption': 'grpc mode', + 'server': '--plugin gost-plugin --plugin-opts "server;cert=$CERT;key=$KEY;mode=grpc"', + 'client': '--plugin gost-plugin --plugin-opts "serverName=$HOST;mode=grpc"', + } + ], + 'ck-client': [ + { + 'caption': 'basic mode', + 'server': '--plugin ck-server --plugin-opts "$CONFIG"', + 'client': '--plugin ck-client --plugin-opts "UID=Q3iw2bAbC3KZvpm58XR6+Q==;' + 'PublicKey=xTbqKW4Sg/xjDXDhys26ChXUQSrgxO+mBflTUeQpfWQ=;' + 'ServerName=www.bing.com;BrowserSig=chrome;' + 'NumConn=4;EncryptionMethod=plain;StreamTimeout=300"', + } + ], + 'gq-client': [ + { + 'caption': 'basic mode', + 'server': '--plugin gq-server --plugin-opts "$CONFIG"', + 'client': '--plugin gq-client --plugin-opts "ServerName=www.bing.com;' + 'key=dnomd343;TicketTimeHint=300;Browser=chrome"', + } + ], + 'mtt-client': [ + { + 'caption': 'basic mode', + 'server': '--plugin mtt-server --plugin-opts "cert=$CERT;key=$KEY"', + 'client': '--plugin mtt-client --plugin-opts "n=$HOST"', + }, + { + 'caption': 'wss mode', + 'server': '--plugin mtt-server --plugin-opts "wss;cert=$CERT;key=$KEY"', + 'client': '--plugin mtt-client --plugin-opts "wss;n=$HOST"', + }, + { + 'caption': 'wss mode with path', + 'server': '--plugin mtt-server --plugin-opts "wss;wss-path=/test;cert=$CERT;key=$KEY"', + 'client': '--plugin mtt-client --plugin-opts "wss;wss-path=/test;n=$HOST"', + } + ], + 'qtun-client': [ + { + 'caption': 'basic mode', + 'server': '--plugin qtun-server --plugin-opts "cert=$CERT;key=$KEY"', + 'client': '--plugin qtun-client --plugin-opts "host=$HOST"', + } + ], + 'gun-plugin': [ + { + 'caption': 'basic mode', + 'server': '--plugin gun-plugin --plugin-opts "server:cleartext"', + 'client': '--plugin gun-plugin --plugin-opts "client:cleartext"', + }, + { + 'caption': 'basic mode with tls', + 'server': '--plugin gun-plugin --plugin-opts "server:$CERT:$KEY"', + 'client': '--plugin gun-plugin --plugin-opts "client:$HOST"', + } + ] +} + +def loadPluginConfig(plugin: str, host: str, cert: str, key: str) -> list: # without rabbit-tcp + result = [] + filePath = None + fileContent = None + if plugin == 'ck-client': # Cloak + filePath = '/tmp/ck-test.json' + fileContent = json.dumps(ckConfig) + if plugin == 'gq-client': # GoQuiet + filePath = '/tmp/gq-test.json' + fileContent = json.dumps(gqConfig) + + for pluginInfo in pluginConfig[plugin]: + pluginInfo['server'] = pluginInfo['server'].replace('$HOST', host).replace('$CERT', cert).replace('$KEY', key) + pluginInfo['client'] = pluginInfo['client'].replace('$HOST', host).replace('$CERT', cert).replace('$KEY', key) + if filePath is not None: + pluginInfo['server'] = pluginInfo['server'].replace('$CONFIG', filePath) + + content = re.search(r'^--plugin ([\s\S]*) --plugin-opts "([\s\S]*)"$', pluginInfo['server']) + if content is None: + content = re.search(r'^--plugin ([\s\S]*)$', pluginInfo['server']) + serverOption = { + 'type': content[1], + 'param': '' + } + else: + serverOption = { + 'type': content[1], + 'param': content[2] + } + content = re.search(r'^--plugin ([\s\S]*) --plugin-opts "([\s\S]*)"$', pluginInfo['client']) + if content is None: + content = re.search(r'^--plugin ([\s\S]*)$', pluginInfo['client']) + clientOption = { + 'type': content[1], + 'param': '' + } + else: + clientOption = { + 'type': content[1], + 'param': content[2] + } + + result.append({ + 'caption': pluginInfo['caption'], + 'server': serverOption, + 'client': clientOption, + 'file': fileContent, + 'path': filePath + }) + return result diff --git a/ProxyTester/Shadowsocks.py b/ProxyTester/Shadowsocks.py new file mode 100644 index 0000000..c219635 --- /dev/null +++ b/ProxyTester/Shadowsocks.py @@ -0,0 +1,200 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +import copy +import ProxyTester.Plugin as sip003 + +defaultHost = 'dns.343.re' +defaultCert = '/etc/ssl/certs/dns.343.re/certificate.crt' +defaultKey = '/etc/ssl/certs/dns.343.re/private.key' + +ssMethodList = [ + 'aes-128-gcm', + 'aes-192-gcm', + 'aes-256-gcm', + 'aes-128-ctr', + 'aes-192-ctr', + 'aes-256-ctr', + 'aes-128-ocb', + 'aes-192-ocb', + 'aes-256-ocb', + 'aes-128-ofb', + 'aes-192-ofb', + 'aes-256-ofb', + 'aes-128-cfb', + 'aes-192-cfb', + 'aes-256-cfb', + 'aes-128-cfb1', + 'aes-192-cfb1', + 'aes-256-cfb1', + 'aes-128-cfb8', + 'aes-192-cfb8', + 'aes-256-cfb8', + 'aes-128-cfb128', + 'aes-192-cfb128', + 'aes-256-cfb128', + 'camellia-128-cfb', + 'camellia-192-cfb', + 'camellia-256-cfb', + 'camellia-128-cfb128', + 'camellia-192-cfb128', + 'camellia-256-cfb128', + 'plain', + 'none', + 'table', + 'rc4', + 'rc4-md5', + 'rc2-cfb', + 'bf-cfb', + 'cast5-cfb', + 'des-cfb', + 'idea-cfb', + 'seed-cfb', + 'salsa20', + 'salsa20-ctr', + 'xchacha20', + 'chacha20', + 'chacha20-ietf', + 'chacha20-poly1305', + 'chacha20-ietf-poly1305', + 'xchacha20-ietf-poly1305' +] + +sip003PluginList = [ # SIP003插件列表 + 'obfs-local', + 'simple-tls', + 'v2ray-plugin', + 'xray-plugin', + 'kcptun-client', + 'gost-plugin', + 'ck-client', + 'gq-client', + 'mtt-client', + 'rabbit-plugin', + 'qtun-client', + 'gun-plugin' +] + +def __ssServerConfig(method: str, plugin: str or None) -> list: + port = 12345 + rabbitPort = 20191 + passwd = 'dnomd343' + + proxyInfo = { + 'type': 'ss', + 'server': '127.0.0.1', + 'port': port, + 'passwd': passwd, + 'method': method + } + serverCommand = [] + caption = 'Shadowsocks method ' + method + if method in ['plain', 'none']: # plain / none -> ss-rust + serverCommand = [ + 'ss-rust-server', + '-s', '0.0.0.0:' + str(port), + '-k', passwd, + '-m', method + ] + elif method == 'salsa20-ctr': # salsa20-ctr -> ss-python-legacy + serverCommand = [ + 'ss-bootstrap-server', '--no-udp', + '--shadowsocks', 'ss-python-legacy-server', + '-p', str(port), + '-k', passwd, + '-m', method + ] + else: # others -> ss-python + mbedtlsMethods = [ + 'aes-128-cfb128', + 'aes-192-cfb128', + 'aes-256-cfb128', + 'camellia-128-cfb128', + 'camellia-192-cfb128', + 'camellia-256-cfb128', + ] + if method in mbedtlsMethods: + method = 'mbedtls:' + method + serverCommand = [ + 'ss-bootstrap-server', '--no-udp', + '--shadowsocks', 'ss-python-server', + '-p', str(port), + '-k', passwd, + '-m', method + ] + if method == 'idea-cfb' or method == 'seed-cfb': + serverCommand.append('--libopenssl=libcrypto.so.1.0.0') + + if plugin is None: # 无插件模式 + return [{ + 'caption': caption, + 'proxy': proxyInfo, + 'server': { + 'startCommand': serverCommand, + 'fileContent': None, + 'filePath': None, + 'envVar': {} + }, + 'aider': None + }] + + if plugin == 'rabbit-plugin': # rabbit-tcp + proxyInfo['port'] = rabbitPort + proxyInfo['plugin'] = { + 'type': 'rabbit-plugin', + 'param': 'serviceAddr=127.0.0.1:' + str(port) + ';password=' + passwd + } + return [{ + 'proxy': proxyInfo, + 'caption': 'Shadowsocks plugin rabbit-plugin (basic mode)', + 'server': { + 'startCommand': serverCommand, + 'fileContent': None, + 'filePath': None, + 'envVar': {} + }, + 'aider': { + 'startCommand': [ + 'rabbit', + '-mode', 's', + '-password', passwd, + '-rabbit-addr', ':' + str(rabbitPort) + ], + 'fileContent': None, + 'filePath': None, + 'envVar': {} + } + }] + + # others plugin + result = [] + pluginConfig = sip003.loadPluginConfig(plugin, defaultHost, defaultCert, defaultKey) # 载入插件配置 + serverBaseCommand = copy.deepcopy(serverCommand) + for pluginOption in pluginConfig: + serverCommand = copy.deepcopy(serverBaseCommand) + serverCommand.append('--plugin') + serverCommand.append(pluginOption['server']['type']) + serverCommand.append('--plugin-opts') + serverCommand.append(pluginOption['server']['param']) + proxyInfo['plugin'] = pluginOption['client'] + result.append(copy.deepcopy({ + 'proxy': proxyInfo, + 'caption': 'Shadowsocks plugin ' + proxyInfo['plugin']['type'] + ' (' + pluginOption['caption'] + ')', + 'server': { + 'startCommand': serverCommand, + 'fileContent': pluginOption['file'], + 'filePath': pluginOption['path'], + 'envVar': {} + }, + 'aider': None + })) + return result + +def ssTest() -> list: + result = [] + for method in ssMethodList: + result += __ssServerConfig(method, None) + for plugin in sip003PluginList: + result += __ssServerConfig('aes-256-ctr', plugin) + # result += __ssServerConfig('aes-256-gcm', None) + return result diff --git a/test/ShadowsocksR.py b/ProxyTester/ShadowsocksR.py similarity index 100% rename from test/ShadowsocksR.py rename to ProxyTester/ShadowsocksR.py diff --git a/ProxyTester/__init__.py b/ProxyTester/__init__.py new file mode 100644 index 0000000..eab51b3 --- /dev/null +++ b/ProxyTester/__init__.py @@ -0,0 +1,6 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +from ProxyTester.tester import * + +__all__ = ['test'] diff --git a/ProxyTester/tester.py b/ProxyTester/tester.py new file mode 100644 index 0000000..ec75cba --- /dev/null +++ b/ProxyTester/tester.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +from ProxyTester import Shadowsocks + +testInfo = { + 'type': 'ss', + 'method': 'aes-256-ctr', + 'plugin': None +} + +def test(key: str) -> list: + if key == 'ss': + return Shadowsocks.ssTest() + elif key == 'ssr': + pass + elif key == 'vmess': + pass + else: + return [] diff --git a/test.py b/test.py index bcbc9ff..53d7248 100644 --- a/test.py +++ b/test.py @@ -1,55 +1,66 @@ #!/usr/bin/python # -*- coding:utf-8 -*- -import sys +import os import time import subprocess +import Checker +import ProxyTester as Tester -import test as Tester -import ProxyBuilder as Builder -import ProxyChecker as Checker - -defaultPort = 10808 -defaultPasswd = 'dnomd343' - -def startTest(testList): - for field in testList: - serverProcess = subprocess.Popen( - field['serverCommand'], - stdout = subprocess.DEVNULL, - stderr = subprocess.DEVNULL) - time.sleep(0.1) # 等待进程启动 - if serverProcess.poll() != None: # 服务端启动失败 - print("server unexpected exit") - continue - print(field['caption'] + ' => ', end = '') - status, client = Builder.build(field['proxyInfo'], '/tmp/ProxyC') - time.sleep(0.5) # 等待初始化完成 - if Builder.check(client) != True: - print("client unexpected exit") # 客户端启动失败 - else: - status, delay = Checker.httpPing(client['port']) - if status == True: - print(format(delay, '.2f') + 'ms') - else: - print(delay) - Builder.destroy(client) # 关闭客户端 - time.sleep(0.1) - serverProcess.terminate() # 关闭服务端 - time.sleep(0.1) - print() - -if len(sys.argv) <= 1: - print("no param") - sys.exit(0) - -testName = sys.argv[1] -if testName == 'ss': - testList = Tester.Shadowsocks(defaultPort, defaultPasswd) -elif testName == 'ssr': - testList = Tester.ShadowsocksR(defaultPort, defaultPasswd) -else: - print("unknown test name") - sys.exit(1) - -startTest(testList) +def testBuild(config: dict): + if config['filePath'] is not None: + with open(config['filePath'], 'w') as fileObject: # 保存文件 + fileObject.write(config['fileContent']) + return subprocess.Popen( # 进程启动 + config['startCommand'], + env = config['envVar'], + stdout = subprocess.DEVNULL, + stderr = subprocess.DEVNULL + ) + +def testDestroy(config: dict, process): + if process.poll() is None: # 未死亡 + while process.poll() is None: # 等待退出 + process.terminate() # SIGTERM + time.sleep(0.2) + if config['filePath'] is not None: + os.remove(config['filePath']) # 删除文件 + +testList = Tester.test('ss') + +aiderProcess = None +serverProcess = None +for testMethod in testList: + # print() + # print() + # print(testMethod) + # continue + print(testMethod['caption'], end = ' -> ') + + serverProcess = testBuild(testMethod['server']) + if testMethod['aider'] is not None: + aiderProcess = testBuild(testMethod['aider']) + + ret = Checker.proxyTest({ + 'check': ['http'], + 'info': testMethod['proxy'] + }) + if not ret['success']: + print('check error') + delay = ret['check']['http']['delay'] + print(str(delay) + 'ms') + + testDestroy(testMethod['server'], serverProcess) + if testMethod['aider'] is not None: + testDestroy(testMethod['aider'], aiderProcess) + +# testName = sys.argv[1] +# if testName == 'ss': +# testList = Tester.Shadowsocks(defaultPort, defaultPasswd) +# elif testName == 'ssr': +# testList = Tester.ShadowsocksR(defaultPort, defaultPasswd) +# else: +# print("unknown test name") +# sys.exit(1) +# +# startTest(testList) diff --git a/test/Shadowsocks.py b/test/Shadowsocks.py deleted file mode 100644 index 13ae286..0000000 --- a/test/Shadowsocks.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- - -ssMethodList = [ - 'aes-128-gcm', - 'aes-192-gcm', - 'aes-256-gcm', - 'aes-128-ctr', - 'aes-192-ctr', - 'aes-256-ctr', - 'aes-128-ocb', - 'aes-192-ocb', - 'aes-256-ocb', - 'aes-128-ofb', - 'aes-192-ofb', - 'aes-256-ofb', - 'aes-128-cfb', - 'aes-192-cfb', - 'aes-256-cfb', - 'aes-128-cfb1', - 'aes-192-cfb1', - 'aes-256-cfb1', - 'aes-128-cfb8', - 'aes-192-cfb8', - 'aes-256-cfb8', - 'aes-128-cfb128', - 'aes-192-cfb128', - 'aes-256-cfb128', - 'camellia-128-cfb', - 'camellia-192-cfb', - 'camellia-256-cfb', - 'camellia-128-cfb128', - 'camellia-192-cfb128', - 'camellia-256-cfb128', - 'plain', - 'none', - 'table', - 'rc4', - 'rc4-md5', - 'rc2-cfb', - 'bf-cfb', - 'cast5-cfb', - 'des-cfb', - 'idea-cfb', - 'seed-cfb', - 'salsa20', - 'salsa20-ctr', - 'xchacha20', - 'chacha20', - 'chacha20-ietf', - 'chacha20-poly1305', - 'chacha20-ietf-poly1305', - 'xchacha20-ietf-poly1305' -] - -def test(port, password): - testList = [] - for method in ssMethodList: - proxyInfo = { - 'type': 'ss', - 'server': '127.0.0.1', - 'port': int(port), - 'password': password, - 'method': method, - 'plugin': '', - 'pluginParam': '', - } - testInfo = 'Shadowsocks method ' + method - if method == 'plain' or method == 'none': - serverCommand = [ - 'ss-rust-server', '-U', - '-s', '0.0.0.0:' + str(port), - '-k', password, - '-m', method - ] - elif method == 'salsa20-ctr': - serverCommand = [ - 'ss-bootstrap-server', - '--shadowsocks', 'ss-python-legacy-server', - '-p', str(port), - '-k', password, - '-m', method - ] - else: - specialMethods = [ - 'aes-128-cfb128', - 'aes-192-cfb128', - 'aes-256-cfb128', - 'camellia-128-cfb128', - 'camellia-192-cfb128', - 'camellia-256-cfb128', - ] - if method in specialMethods: - method = 'mbedtls:' + method - serverCommand = [ - 'ss-bootstrap-server', - '--shadowsocks', 'ss-python-server', - '-p', str(port), - '-k', password, - '-m', method - ] - if method == 'idea-cfb' or method == 'seed-cfb': - serverCommand.append('--libopenssl=libcrypto.so.1.0.0') - testList.append({ - 'caption': testInfo, - 'proxyInfo': proxyInfo, - 'serverCommand': serverCommand - }) - testList.append({ - 'caption': 'Shadowsocks SIP003 plugin', - 'proxyInfo': { - 'type': 'ss', - 'server': '127.0.0.1', - 'port': int(port), - 'password': password, - 'method': 'aes-256-ctr', - 'plugin': 'obfs-local', - 'pluginParam': 'obfs=http;obfs-host=www.bing.com', - }, - 'serverCommand': [ - 'ss-bootstrap-server', - '--shadowsocks', 'ss-python-server', - '-p', str(port), - '-k', password, - '-m', 'aes-256-ctr', - '--plugin', 'obfs-server', - '--plugin-opts', 'obfs=http' - ] - }) - return testList diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index fb7418d..0000000 --- a/test/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- - -from test.entry import Shadowsocks -from test.entry import ShadowsocksR diff --git a/test/entry.py b/test/entry.py deleted file mode 100644 index e23d7c6..0000000 --- a/test/entry.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- - -import test.Shadowsocks as ss -import test.ShadowsocksR as ssr - -def Shadowsocks(port, password): - return ss.test(port, password) - -def ShadowsocksR(port, password): - return ssr.test(port, password)