From 39891ee21f11cb799a232d2f358ed4d321ace738 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 3 Mar 2022 12:01:23 +0800 Subject: [PATCH] feat: add tester of Brook --- ProxyTester/Brook.py | 93 +++++++++++++++++++++++++++++++++++++++++++ ProxyTester/tester.py | 3 ++ Test.py | 1 + 3 files changed, 97 insertions(+) create mode 100644 ProxyTester/Brook.py diff --git a/ProxyTester/Brook.py b/ProxyTester/Brook.py new file mode 100644 index 0000000..8be4f70 --- /dev/null +++ b/ProxyTester/Brook.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +testConfig = {} + +def __originConfig() -> dict: + return { + 'caption': 'Brook original', + 'client': { + 'type': 'brook', + 'server': testConfig['host'], + 'port': testConfig['port'], + 'passwd': testConfig['passwd'] + }, + 'server': [ + 'brook', 'server', + '--listen', testConfig['bind'] + ':' + str(testConfig['port']), + '--password', testConfig['passwd'] + ] + } + + +def __wsConfig() -> dict: + return { + 'caption': 'Brook websocket', + 'client': { + 'type': 'brook', + 'server': testConfig['host'], + 'port': testConfig['port'], + 'passwd': testConfig['passwd'], + 'ws': { + 'host': testConfig['host'], + 'path': testConfig['path'] + } + }, + 'server': [ + 'brook', 'wsserver', + '--listen', testConfig['bind'] + ':' + str(testConfig['port']), + '--password', testConfig['passwd'], + '--path', testConfig['path'] + ] + } + + +def __wssConfig() -> dict: + return { + 'caption': 'Brook websocket with TLS', + 'client': { + 'type': 'brook', + 'server': testConfig['host'], + 'port': testConfig['port'], + 'passwd': testConfig['passwd'], + 'ws': { + 'host': testConfig['host'], + 'path': testConfig['path'], + 'secure': { + 'verify': True + } + } + }, + 'server': [ + 'brook', 'wssserver', + '--domainaddress', testConfig['host'] + ':' + str(testConfig['port']), + '--cert', testConfig['cert'], + '--certkey', testConfig['key'], + '--password', testConfig['passwd'], + '--path', testConfig['path'] + ] + } + + +def __brookConfig(brookConfig: dict) -> dict: + return { + 'caption': brookConfig['caption'], + 'proxy': brookConfig['client'], + 'server': { + 'startCommand': brookConfig['server'], + 'fileContent': None, + 'filePath': None, + 'envVar': {} + }, + 'aider': None + } + + +def test(config: dict) -> list: + global testConfig + testConfig = config + return [ + __brookConfig(__originConfig()), + __brookConfig(__wsConfig()), + __brookConfig(__wssConfig()), + ] diff --git a/ProxyTester/tester.py b/ProxyTester/tester.py index 3258937..dd4fd81 100644 --- a/ProxyTester/tester.py +++ b/ProxyTester/tester.py @@ -7,6 +7,7 @@ from ProxyTester import VMess from ProxyTester import VLESS from ProxyTester import Trojan from ProxyTester import TrojanGo +from ProxyTester import Brook def test(key: str, config: dict) -> list: if key in ['ss', 'shadowsocks']: @@ -21,5 +22,7 @@ def test(key: str, config: dict) -> list: return Trojan.trojanTest(config) elif key == 'trojan-go': return TrojanGo.trojanGoTest(config) + elif key == 'brook': + return Brook.test(config) else: return [] diff --git a/Test.py b/Test.py index d755efd..4b95dc5 100644 --- a/Test.py +++ b/Test.py @@ -15,6 +15,7 @@ testConfig = { 'passwd': 'dnomd343', 'host': 'local.343.re', 'path': '/test', + 'bind': '127.0.0.1', 'service': 'dnomd343', 'file': '/tmp/proxycTest.json', 'cert': '/etc/ssl/certs/343.re/fullchain.pem',