From 961e180dfbc10ba64ff49b4618db6363ce80c97e Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 3 Mar 2022 19:33:42 +0800 Subject: [PATCH] fix: IPv6 for Brook server --- ProxyBuilder/Brook.py | 8 ++++++++ ProxyFilter/Brook.py | 2 +- ProxyFilter/filter.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ProxyBuilder/Brook.py b/ProxyBuilder/Brook.py index 044525a..da1aa42 100644 --- a/ProxyBuilder/Brook.py +++ b/ProxyBuilder/Brook.py @@ -1,6 +1,8 @@ #!/usr/bin/python # -*- coding:utf-8 -*- +import copy + def __originConfig(proxyInfo: dict) -> list: return [ 'client', @@ -36,6 +38,12 @@ def load(proxyInfo: dict, socksPort: int, configFile: str) -> tuple[list, str or return startCommand, fileContent, envVar """ + proxyInfo = copy.deepcopy(proxyInfo) + if proxyInfo['server'].find(':') >= 0: + proxyInfo['server'] = '[' + proxyInfo['server'] + ']' # IPv6 + if proxyInfo['ws'] is not None and proxyInfo['ws']['host'].find(':') >= 0: + proxyInfo['ws']['host'] = '[' + proxyInfo['ws']['host'] + ']' # IPv6 + command = [ 'brook', '--debug', '--listen', 'skip success', # debug on diff --git a/ProxyFilter/Brook.py b/ProxyFilter/Brook.py index 47b8786..317b163 100644 --- a/ProxyFilter/Brook.py +++ b/ProxyFilter/Brook.py @@ -67,7 +67,7 @@ brookFilterRules = { } } -def brookFilter(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: +def filte(rawInfo: dict, isExtra: bool) -> tuple[bool, str or dict]: """ Brook节点合法性检查 diff --git a/ProxyFilter/filter.py b/ProxyFilter/filter.py index a57c7e5..0ebcbe1 100644 --- a/ProxyFilter/filter.py +++ b/ProxyFilter/filter.py @@ -39,7 +39,7 @@ def filte(raw: dict, isExtra: bool = False) -> tuple[bool, str or dict]: elif raw['type'] == 'trojan-go': return TrojanGo.trojanGoFilter(raw, isExtra) elif raw['type'] == 'brook': - return Brook.brookFilter(raw, isExtra) + return Brook.filte(raw, isExtra) else: return False, 'Unknown proxy type' except: