|
@ -1,6 +1,7 @@ |
|
|
#!/usr/bin/python |
|
|
#!/usr/bin/python |
|
|
# -*- coding:utf-8 -*- |
|
|
# -*- coding:utf-8 -*- |
|
|
|
|
|
|
|
|
|
|
|
import sys |
|
|
import time |
|
|
import time |
|
|
import subprocess |
|
|
import subprocess |
|
|
|
|
|
|
|
@ -8,34 +9,43 @@ import test as Tester |
|
|
import ProxyBuilder as Builder |
|
|
import ProxyBuilder as Builder |
|
|
import ProxyChecker as Checker |
|
|
import ProxyChecker as Checker |
|
|
|
|
|
|
|
|
# print(dir(Tester)) |
|
|
defaultPort = 10808 |
|
|
|
|
|
defaultPasswd = 'dnomd343' |
|
|
|
|
|
|
|
|
data = Tester.Shadowsocks(1081, 'dnomd343') |
|
|
def startTest(testList): |
|
|
# data = Tester.ShadowsocksR(1081, 'dnomd343') |
|
|
for field in testList: |
|
|
|
|
|
serverProcess = subprocess.Popen( |
|
|
|
|
|
field['serverCommand'], |
|
|
|
|
|
stdout = subprocess.DEVNULL, |
|
|
|
|
|
stderr = subprocess.DEVNULL) |
|
|
|
|
|
time.sleep(0.1) # 等待进程启动 |
|
|
|
|
|
if serverProcess.poll() != None: # 服务端启动失败 |
|
|
|
|
|
print("server unexpected exit") |
|
|
|
|
|
continue |
|
|
|
|
|
print(field['caption'] + ' => ', end = '') |
|
|
|
|
|
client = Builder.build(field['proxyInfo'], '/tmp/ProxyC') |
|
|
|
|
|
time.sleep(0.5) # 等待初始化完成 |
|
|
|
|
|
if not Builder.check(client): |
|
|
|
|
|
print("client unexpected exit") # 客户端启动失败 |
|
|
|
|
|
else: |
|
|
|
|
|
print(format(Checker.httpPing(client['port']), '.2f') + 'ms') |
|
|
|
|
|
Builder.destroy(client) # 关闭客户端 |
|
|
|
|
|
time.sleep(0.1) |
|
|
|
|
|
serverProcess.terminate() # 关闭服务端 |
|
|
|
|
|
time.sleep(0.1) |
|
|
|
|
|
print() |
|
|
|
|
|
|
|
|
# for field in data: |
|
|
if len(sys.argv) <= 1: |
|
|
# print(field['proxyInfo']) |
|
|
print("no param") |
|
|
# print(field['serverCommand']) |
|
|
sys.exit(0) |
|
|
# print('') |
|
|
|
|
|
|
|
|
|
|
|
for field in data: |
|
|
testName = sys.argv[1] |
|
|
serverProcess = subprocess.Popen( |
|
|
if testName == 'ss': |
|
|
field['serverCommand'], |
|
|
testList = Tester.Shadowsocks(defaultPort, defaultPasswd) |
|
|
stdout = subprocess.DEVNULL, |
|
|
elif testName == 'ssr': |
|
|
stderr = subprocess.DEVNULL) |
|
|
testList = Tester.ShadowsocksR(defaultPort, defaultPasswd) |
|
|
time.sleep(0.1) # 等待进程启动 |
|
|
else: |
|
|
if serverProcess.poll() != None: # 服务端启动失败 |
|
|
print("unknown test name") |
|
|
print("server unexpected exit") |
|
|
sys.exit(1) |
|
|
continue |
|
|
|
|
|
print(field['caption'] + ' => ', end = '') |
|
|
startTest(testList) |
|
|
client = Builder.build(field['proxyInfo'], '/tmp/ProxyC') |
|
|
|
|
|
time.sleep(0.5) # 等待初始化完成 |
|
|
|
|
|
if not Builder.check(client): |
|
|
|
|
|
print("client unexpected exit") # 客户端启动失败 |
|
|
|
|
|
else: |
|
|
|
|
|
print(format(Checker.httpPing(client['port']), '.2f') + 'ms') |
|
|
|
|
|
Builder.destroy(client) # 关闭客户端 |
|
|
|
|
|
time.sleep(0.1) |
|
|
|
|
|
serverProcess.terminate() # 关闭服务端 |
|
|
|
|
|
time.sleep(0.1) |
|
|
|
|
|
print() |
|
|
|
|
|