Browse Source

feat: add tester of Brook

master
Dnomd343 3 years ago
parent
commit
39891ee21f
  1. 93
      ProxyTester/Brook.py
  2. 3
      ProxyTester/tester.py
  3. 1
      Test.py

93
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()),
]

3
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 []

1
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',

Loading…
Cancel
Save