mirror of https://github.com/dnomd343/ProxyC
Dnomd343
3 years ago
3 changed files with 167 additions and 85 deletions
@ -1,50 +1,81 @@ |
|||||
#!/usr/bin/python |
#!/usr/bin/python |
||||
# -*- coding:utf-8 -*- |
# -*- coding:utf-8 -*- |
||||
|
|
||||
|
import os |
||||
import time |
import time |
||||
import socket |
|
||||
import requests |
|
||||
|
|
||||
import ProxyBuilder as Builder |
import ProxyBuilder as Builder |
||||
import ProxyChecker as Checker |
import ProxyChecker as Checker |
||||
|
|
||||
testInfo = { |
workDir = '/tmp/ProxyC' |
||||
'type': 'ss', |
|
||||
'server': '127.0.0.1', |
ssTest = { |
||||
'port': 12345, |
'tag': 'f43c9bae21ae8693', |
||||
'password': 'dnomd343', |
'check': [ |
||||
'method': 'aes-256-ctr', |
'http' |
||||
'plugin': '', |
], |
||||
'pluginParam': '', |
'info': { |
||||
|
'type': 'ss', |
||||
|
'server': '127.0.0.1', |
||||
|
'port': 12345, |
||||
|
'password': 'dnomd343', |
||||
|
'method': 'aes-256-ctr', |
||||
|
'plugin': '', |
||||
|
'pluginParam': '', |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ssrTest = { |
||||
|
'tag': 'f43c9bae21ae8693', |
||||
|
'check': [ |
||||
|
'http' |
||||
|
], |
||||
|
'info': { |
||||
|
'type': 'ssr', |
||||
|
"server": "127.0.0.1", |
||||
|
"port": 23456, |
||||
|
"password": "dnomd343", |
||||
|
"method": "table", |
||||
|
"protocol": "auth_aes128_md5", |
||||
|
"protocolParam": "", |
||||
|
"obfs": "tls1.2_ticket_auth", |
||||
|
"obfsParam": "" |
||||
|
} |
||||
} |
} |
||||
|
|
||||
# testInfo = { |
def loadDir(folderPath): # 创建文件夹 |
||||
# 'type': 'ssr', |
try: |
||||
# "server": "127.0.0.1", |
if os.path.exists(folderPath): # 文件 / 文件夹 存在 |
||||
# "port": 23456, |
if not os.path.isdir(folderPath): # 文件 |
||||
# "password": "dnomd343", |
return False # 无法创建 |
||||
# "method": "table", |
else: # 不存在 |
||||
# "protocol": "auth_aes128_md5", |
os.makedirs(folderPath) # 递归创建文件夹 |
||||
# "protocolParam": "", |
return True # 文件夹正常 |
||||
# "obfs": "tls1.2_ticket_auth", |
except: |
||||
# "obfsParam": "" |
return False |
||||
# } |
|
||||
|
def proxyTest(rawInfo, startDelay = 1, destroyDelay = 0.5): |
||||
print("start") |
if loadDir(workDir) == False: # 工作文件夹无效 |
||||
print(testInfo) |
return None |
||||
task = Builder.build(testInfo, '/tmp/ProxyC') |
if not 'info' in rawInfo: |
||||
print(task) |
return None |
||||
time.sleep(1) |
status, client = Builder.build(rawInfo['info'], workDir) |
||||
if Builder.check(task) == False: |
if status != True: |
||||
print("error exit") |
print(client) |
||||
Builder.destroy(task) |
return None |
||||
else: |
time.sleep(startDelay) |
||||
print("http check") |
if Builder.check(client) != True: |
||||
health, delay = Checker.httpCheck(task['port']) |
print("client error") |
||||
|
return None |
||||
|
health, httpDelay = Checker.httpCheck(client['port']) |
||||
print("health = " + str(health)) |
print("health = " + str(health)) |
||||
if delay < 0: |
if httpDelay < 0: |
||||
print("error") |
print("http error") |
||||
else: |
else: |
||||
print("delay = " + format(delay, '.2f') + 'ms') |
print("delay = " + format(httpDelay, '.2f') + 'ms') |
||||
Builder.destroy(task) |
if Builder.destroy(client) != True: |
||||
|
print("client destroy error") |
||||
|
time.sleep(destroyDelay) |
||||
print("done") |
print("done") |
||||
|
|
||||
|
proxyTest(ssrTest) |
||||
|
Loading…
Reference in new issue