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

66
test.py

@ -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()

1
test/ShadowsocksR.py

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

2
test/docker/shadowsocks.py

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

3
test/docker/shadowsocksr.py

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

1
test/docker/sip003.py

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

Loading…
Cancel
Save