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.
 
 

53 lines
1.7 KiB

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
import requests
from Tester import Shadowsocks
from Basis.Logger import logging
def test(testObj: dict) -> None:
logging.warning(testObj['title'])
testObj['client'].start()
testObj['server'].start()
time.sleep(1)
errFlag = False
try:
request = requests.get(
'http://baidu.com',
proxies = {
'http': 'socks5://127.0.0.1:%i' % testObj['socks']['port'],
'https': 'socks5://127.0.0.1:%i' % testObj['socks']['port'],
},
timeout = 10
)
request.raise_for_status()
logging.info('socks5 127.0.0.1:%i -> ok' % testObj['socks']['port'])
except Exception as exp:
logging.error('socks5 127.0.0.1:%i -> error' % testObj['socks']['port'])
logging.error('requests exception\n' + str(exp))
errFlag = True
testObj['client'].quit()
testObj['server'].quit()
if errFlag:
logging.warning('client info')
logging.error('command -> ' + str(testObj['client'].cmd))
logging.error('envVar -> ' + str(testObj['client'].env))
logging.error('file -> ' + str(testObj['client'].file))
logging.warning('client capture output')
logging.error('\n' + str(testObj['client'].output))
logging.warning('server info')
logging.error('command -> ' + str(testObj['server'].cmd))
logging.error('envVar -> ' + str(testObj['server'].env))
logging.error('file -> ' + str(testObj['server'].file))
logging.warning('server capture output')
logging.error('\n' + str(testObj['server'].output))
testList = Shadowsocks.load(isExtra = True)
for testObject in testList:
test(testObject)