mirror of https://github.com/dnomd343/ProxyC
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.
60 lines
1.4 KiB
60 lines
1.4 KiB
import time
|
|
import socket
|
|
import requests
|
|
import ProxyBuilder
|
|
|
|
def checkSocksPort(port):
|
|
try:
|
|
startTime = time.time_ns()
|
|
r = requests.get('http://gstatic.com/generate_204', proxies = {
|
|
'http': 'socks5://127.0.0.1:' + str(port),
|
|
'https': 'socks5://127.0.0.1:' + str(port),
|
|
})
|
|
if r.status_code == 204:
|
|
delay = (time.time_ns() - startTime) / (10 ** 6)
|
|
print(format(delay, '.2f') + 'ms')
|
|
return True
|
|
except: pass
|
|
return False
|
|
|
|
# testInfo = {
|
|
# 'type': 'ss',
|
|
# 'server': '127.0.0.1',
|
|
# 'port': 12345,
|
|
# 'password': 'dnomd343',
|
|
# 'method': 'aes-256-ctr',
|
|
# 'plugin': '',
|
|
# 'pluginArg': '',
|
|
# }
|
|
|
|
testInfo = {
|
|
'type': 'ssr',
|
|
"server": "127.0.0.1",
|
|
"port": 23456,
|
|
"password": "dnomd343",
|
|
"method": "table",
|
|
"protocol": "auth_aes128_md5",
|
|
"protocolParam": "",
|
|
"obfs": "tls1.2_ticket_auth",
|
|
"obfsParam": ""
|
|
}
|
|
|
|
print("start")
|
|
print(testInfo)
|
|
task = ProxyBuilder.build(testInfo, '/tmp/ProxyC')
|
|
print(task)
|
|
time.sleep(1)
|
|
if ProxyBuilder.check(task) == False:
|
|
print("error exit")
|
|
else:
|
|
print("test with gstatic")
|
|
checkSocksPort(task['port'])
|
|
checkSocksPort(task['port'])
|
|
checkSocksPort(task['port'])
|
|
if checkSocksPort(task['port']):
|
|
print("ok")
|
|
else:
|
|
print("error")
|
|
ProxyBuilder.destroy(task)
|
|
print("stop")
|
|
|