Browse Source

feat: test of ss and ssr

master
Dnomd343 3 years ago
parent
commit
2826f720b7
  1. 11
      demo.py
  2. 66
      test.py
  3. 1
      test/ShadowsocksR.py
  4. 2
      test/docker/shadowsocks.py
  5. 3
      test/docker/shadowsocksr.py
  6. 1
      test/docker/sip003.py

11
demo.py

@ -1,3 +1,6 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import time
import socket
import requests
@ -28,10 +31,6 @@ testInfo = {
}
print("start")
print(dir(Builder))
print(dir(Checker))
print(testInfo)
task = Builder.build(testInfo, '/tmp/ProxyC')
print(task)
@ -40,7 +39,7 @@ if Builder.check(task) == False:
print("error exit")
Builder.destroy(task)
else:
print("test with gstatic")
print("http check")
health, delay = Checker.httpCheck(task['port'])
print("health = " + str(health))
if delay < 0:
@ -48,4 +47,4 @@ else:
else:
print("delay = " + format(delay, '.2f') + 'ms')
Builder.destroy(task)
print("stop")
print("done")

66
test.py

@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import time
import subprocess
@ -8,34 +9,43 @@ import test as Tester
import ProxyBuilder as Builder
import ProxyChecker as Checker
# print(dir(Tester))
defaultPort = 10808
defaultPasswd = 'dnomd343'
data = Tester.Shadowsocks(1081, 'dnomd343')
# data = Tester.ShadowsocksR(1081, 'dnomd343')
def startTest(testList):
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:
# print(field['proxyInfo'])
# print(field['serverCommand'])
# print('')
if len(sys.argv) <= 1:
print("no param")
sys.exit(0)
for field in data:
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()
testName = sys.argv[1]
if testName == 'ss':
testList = Tester.Shadowsocks(defaultPort, defaultPasswd)
elif testName == 'ssr':
testList = Tester.ShadowsocksR(defaultPort, defaultPasswd)
else:
print("unknown test name")
sys.exit(1)
startTest(testList)

1
test/ShadowsocksR.py

@ -1,7 +1,6 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
ssrMethodList = [
"aes-128-cfb",
"aes-192-cfb",

2
test/docker/shadowsocks.py

@ -1,4 +1,6 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
method_list = {
"ss-python": [
"aes-128-gcm",

3
test/docker/shadowsocksr.py

@ -1,3 +1,6 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
method_list = [
"aes-128-cfb",
"aes-192-cfb",

1
test/docker/sip003.py

@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
testHost = "dns.343.re"
testCert = "/etc/ssl/certs/dns.343.re/certificate.crt"

Loading…
Cancel
Save