Browse Source

fix: IPv6 for Brook

master
Dnomd343 2 years ago
parent
commit
d0d767a757
  1. 2
      ProxyFilter/Brook.py
  2. 7
      ProxyFilter/baseFunc.py
  3. 14
      ProxyTester/Brook.py
  4. 3
      Test.py

2
ProxyFilter/Brook.py

@ -14,7 +14,7 @@ brookFilterRules = {
'server': {
'optional': True,
'type': str,
'format': baseFunc.toStrTidy,
'format': baseFunc.toHost,
'filter': baseFunc.isHost,
'errMsg': 'Illegal server address'
},

7
ProxyFilter/baseFunc.py

@ -127,6 +127,13 @@ def toStrTidy(raw) -> str: # change to str with trim and lower
return toStr(raw).strip().lower()
def toHost(raw) -> str: # format to IP address or domain
raw = toStrTidy(raw)
if raw[:1] == '[' and raw[-1:] == ']': # [IPv6]
raw = raw[1:-1]
return raw
class filterException(Exception): # 检测异常
def __init__(self, reason):
self.reason = reason

14
ProxyTester/Brook.py

@ -1,6 +1,8 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import copy
testConfig = {}
def __originConfig() -> dict:
@ -8,7 +10,7 @@ def __originConfig() -> dict:
'caption': 'Brook original',
'client': {
'type': 'brook',
'server': testConfig['host'],
'server': testConfig['bind'],
'port': testConfig['port'],
'passwd': testConfig['passwd']
},
@ -25,7 +27,7 @@ def __wsConfig() -> dict:
'caption': 'Brook websocket',
'client': {
'type': 'brook',
'server': testConfig['host'],
'server': testConfig['bind'],
'port': testConfig['port'],
'passwd': testConfig['passwd'],
'ws': {
@ -47,7 +49,7 @@ def __wssConfig() -> dict:
'caption': 'Brook websocket with TLS',
'client': {
'type': 'brook',
'server': testConfig['host'],
'server': testConfig['bind'],
'port': testConfig['port'],
'passwd': testConfig['passwd'],
'ws': {
@ -60,7 +62,7 @@ def __wssConfig() -> dict:
},
'server': [
'brook', 'wssserver',
'--domainaddress', testConfig['host'] + ':' + str(testConfig['port']),
'--domainaddress', testConfig['bind'] + ':' + str(testConfig['port']),
'--cert', testConfig['cert'],
'--certkey', testConfig['key'],
'--password', testConfig['passwd'],
@ -85,7 +87,9 @@ def __brookConfig(brookConfig: dict) -> dict:
def test(config: dict) -> list:
global testConfig
testConfig = config
testConfig = copy.deepcopy(config)
if testConfig['bind'].find(':') >= 0:
testConfig['bind'] = '[' + testConfig['bind'] + ']'
return [
__brookConfig(__originConfig()),
__brookConfig(__wsConfig()),

3
Test.py

@ -15,7 +15,8 @@ testConfig = {
'passwd': 'dnomd343',
'host': 'local.343.re',
'path': '/test',
'bind': '127.0.0.1',
'bind': '::1',
# 'bind': '127.0.0.1',
'service': 'dnomd343',
'file': '/tmp/proxycTest.json',
'cert': '/etc/ssl/certs/343.re/fullchain.pem',

Loading…
Cancel
Save