From 68e28873dcc20659e8c574944fab3cbd4e7713bd Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Mon, 1 Aug 2022 12:13:46 +0800 Subject: [PATCH] feat: ipv6 test option --- Tester/Settings.py | 4 ++-- Tester/__init__.py | 11 ++++++++--- test.py | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Tester/Settings.py b/Tester/Settings.py index 34515fc..abf7a91 100644 --- a/Tester/Settings.py +++ b/Tester/Settings.py @@ -3,8 +3,8 @@ Settings = { 'workDir': '/tmp/ProxyC', - 'serverBind': '127.0.0.1', - 'clientBind': '127.0.0.1', + 'serverBind': '', + 'clientBind': '', 'site': 'www.bing.com', 'host': '', 'cert': '', diff --git a/Tester/__init__.py b/Tester/__init__.py index 0f9c949..e538ed2 100644 --- a/Tester/__init__.py +++ b/Tester/__init__.py @@ -39,7 +39,7 @@ def waitPort(port: int, times: int = 100, delay: int = 100) -> bool: # wait unt return False # timeout -def httpCheck(socksInfo: dict, url: str, timeout: int = 10): +def httpCheck(socksInfo: dict, url: str, timeout: int = 10) -> None: socksProxy = 'socks5://%s:%i' % (hostFormat(socksInfo['addr'], v6Bracket = True), socksInfo['port']) try: proxy = { @@ -90,7 +90,7 @@ def runTest(testInfo: dict, testUrl: str, testFilter: set or None, delay: int = logging.error('\n%s' % testInfo['server'].output) -def test(testIter: iter, threadNum: int, testUrl: str, testFilter: set or None = None): +def test(testIter: iter, threadNum: int, testUrl: str, testFilter: set or None = None) -> None: threads = [] while True: # infinite loop try: @@ -112,7 +112,12 @@ def test(testIter: iter, threadNum: int, testUrl: str, testFilter: set or None = thread.join() -def loadCert(host: str = 'proxyc.net', remark: str = 'ProxyC'): +def loadBind(serverV6: bool = False, clientV6: bool = False) -> None: + Settings['serverBind'] = '::1' if serverV6 else '127.0.0.1' + Settings['clientBind'] = '::1' if clientV6 else '127.0.0.1' + + +def loadCert(host: str = 'proxyc.net', remark: str = 'ProxyC') -> None: loadPath = lambda x: os.path.join(Settings['workDir'], x) certFlag = genFlag(length = 8) caCert = loadPath('proxyc_%s_ca.pem' % certFlag) diff --git a/test.py b/test.py index 9c030c8..7eca8c2 100755 --- a/test.py +++ b/test.py @@ -20,6 +20,7 @@ helpMsg = ''' --url URL http check url --filter ID1[,ID2...] test the specified id --all test extra shadowsocks items + --ipv6 test on ipv6 network --help show this message ''' @@ -44,6 +45,8 @@ if getArg('--thread') is not None: if getArg('--filter') is not None: testFilter = set(getArg('--filter').split(',')) +isV6 = '--ipv6' in sys.argv +Tester.loadBind(serverV6 = isV6, clientV6 = isV6) Tester.loadCert('proxyc.net', 'ProxyC') logging.critical('TEST ITEM: ' + ('all' if testItem is None else testItem)) logging.critical('FILTER: %s' % testFilter)