You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

97 lines
2.6 KiB

#!/usr/bin/python
# -*- coding:utf-8 -*-
import copy
testConfig = {}
def __originConfig() -> dict:
return {
'caption': 'Brook original',
'client': {
'type': 'brook',
'server': testConfig['bind'],
'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['bind'],
'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['bind'],
'port': testConfig['port'],
'passwd': testConfig['passwd'],
'ws': {
'host': testConfig['host'],
'path': testConfig['path'],
'secure': {
'verify': True
}
}
},
'server': [
'brook', 'wssserver',
'--domainaddress', testConfig['bind'] + ':' + 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 = copy.deepcopy(config)
if testConfig['bind'].find(':') >= 0:
testConfig['bind'] = '[' + testConfig['bind'] + ']'
return [
__brookConfig(__originConfig()),
__brookConfig(__wsConfig()),
__brookConfig(__wssConfig()),
]