diff --git a/ProxyChecker/Http.py b/ProxyChecker/Http.py deleted file mode 100644 index da60bab..0000000 --- a/ProxyChecker/Http.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- - -import time -import requests - -def httpPing(port, url = 'http://gstatic.com/generate_204', timeout = 30): - ''' - HTTP请求延迟测试 - - 检测异常: return None, {reason} - - 服务错误: return False, {reason} - - 连接正常: return True, httpDelay - ''' - try: - startTime = time.time_ns() # 请求开始时间 - socks5 = 'socks5://127.0.0.1:' + str(port) - httpRequest = requests.get(url, proxies = { # http请求 - 'http': socks5, - 'https': socks5, - }, timeout = timeout) - except NameError: # 模块无效 - return None, 'Missing modules' - except requests.exceptions.InvalidSchema: # 缺失pysocks包 - return None, 'Missing dependencies for SOCKS support' - except requests.exceptions.ConnectTimeout: # 请求超时 - return False, 'Request timeout' - except requests.exceptions.ReadTimeout: # 请求超时 - return False, 'Request timeout' - except requests.exceptions.Timeout: # 请求超时 - return False, 'Request timeout' - except: # 未知错误 - return False, 'Request error' - - try: - statusCode = httpRequest.status_code # 获取http状态码 - except: - return None, 'Http request error' - if 'statusCode' in vars() and statusCode >= 200 and statusCode < 300: # http测试成功 - delay = (time.time_ns() - startTime) / (10 ** 6) - return True, round(delay, 2) # 保留小数点后两位 - else: - return False, 'Http status code not 204' - -def httpCheck(port, url = 'http://gstatic.com/generate_204', timeout = 30): - ''' - HTTP请求测试 - - 测试异常: return None, {reason} - - 测试完成: return health, delay - ''' - result = [] - failNum = 0 - timeout = timeout * 64 / 119 # 4/64 + 2/64 + 1/64 + 1/4 + 1/2 + 1/1 - for i in [4, 2, 1]: # 三次测试 - time.sleep(timeout / 64 * i) - status, delay = httpPing(port, url, timeout / i) - if status == None: # 测试异常 - return None, delay - elif status == False: # 连接失败 - result.append(-1) - else: # 连接成功 - result.append(delay) - for ret in result: # 计算失败次数 - if ret < 0: - failNum += 1 - - if failNum == 3: # 全部失败 - return False, -1 - elif failNum == 2: # 仅成功一次 - for ret in result: - if ret > 0: # 返回成功单次延迟 - return False, ret - elif failNum == 1: # 存在一次失败 - sum = 0 - for ret in result: - if ret > 0: - sum += ret - return False, round(sum / 2, 2) # 返回成功延迟均值 - else: # 全部成功 - return True, min(min(result[0], result[1]), result[2]) # 返回最低延迟 diff --git a/ProxyChecker/__init__.py b/ProxyChecker/__init__.py deleted file mode 100644 index dadffdf..0000000 --- a/ProxyChecker/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- - -from ProxyChecker.Http import * - -__all__ = [ 'httpPing', 'httpCheck' ] diff --git a/demo.py b/demo.py deleted file mode 100755 index a3dae6c..0000000 --- a/demo.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import time -from Builder import Builder -from Basis.Logger import logging - -proxySS = { - 'server': '127.0.0.1', - 'port': 12345, - 'passwd': 'dnomd343', - 'method': 'aes-128-ctr', - 'plugin': None -} - -proxySSR = { - 'server': '127.0.0.1', - 'port': 12345, - 'passwd': 'dnomd343', - 'method': 'aes-128-ctr', - 'protocol': 'origin', - 'protocolParam': '', - 'obfs': 'plain', - 'obfsParam': '', -} - -proxyVMess = { - 'server': '127.0.0.1', - 'port': 12345, - 'method': 'auto', - 'id': '614d3a56-8a04-4c65-88a2-45896f0bd13c', - 'aid': 0, - 'stream': { - 'type': 'tcp', - 'obfs': None, - 'secure': { - 'sni': '343.re', - 'alpn': None, - 'verify': True, - }, - } -} - -proxyVLESS = { - 'server': '127.0.0.1', - 'port': 12345, - 'method': 'none', - 'id': '614d3a56-8a04-4c65-88a2-45896f0bd13c', - 'stream': { - 'type': 'tcp', - 'obfs': None, - 'secure': { - 'type': 'xtls', - 'sni': '343.re', - 'alpn': None, - 'verify': True, - 'flow': 'xtls-direct', - 'udp443': False - }, - } -} - -proxyTrojan = { - 'server': '127.0.0.1', - 'port': 12345, - 'passwd': 'dnomd343', - 'stream': { - 'type': 'tcp', - 'obfs': None, - 'secure': { - 'type': 'tls', - 'sni': '343.re', - 'alpn': None, - 'verify': True, - }, - } -} - -proxyTrojanGo = { - 'server': '127.0.0.1', - 'port': 12345, - 'passwd': 'dnomd343', - 'sni': '343.re', - 'alpn': None, - 'verify': True, - 'ws': { - 'host': '343.re', - 'path': '/test', - }, - 'ss': { - 'method': 'AES-128-GCM', - 'passwd': 'dnomd343', - }, - 'plugin': { - 'type': 'obfs-local', - 'param': 'obfs=http;obfs-host=www.bing.com' - }, -} - -proxyBrook = { - 'server': '::1', - 'port': 12345, - 'passwd': 'dnomd343', - 'stream': { - 'type': 'ws', - 'host': '343.re', - 'path': '/test', - 'raw': True, - 'secure': { - 'verify': False - }, - } -} - -proxyHysteria = { - 'server': '127.0.0.1', - 'port': 12345, - 'protocol': 'udp', - 'obfs': 'obfs', - 'passwd': 'dnomd343', - 'up': 10, - 'down': 50, - 'sni': '343.re', - 'alpn': 'h3', - 'verify': False, -} - -# client = Builder('ss', proxySS) -# client = Builder('ssr', proxySSR) -# client = Builder('vmess', proxyVMess) -# client = Builder('vless', proxyVLESS) -# client = Builder('trojan', proxyTrojan) -# client = Builder('trojan-go', proxyTrojanGo) -# client = Builder('brook', proxyBrook) -# client = Builder('hysteria', proxyHysteria) -# -# logging.critical(client.id) -# logging.critical(client.proxyType) -# logging.critical(client.proxyInfo) -# logging.critical(client.socksAddr) -# logging.critical(client.socksPort) -# -# time.sleep(15) -# logging.critical(client.status()) -# -# client.destroy() -# logging.critical(client.status()) -# logging.critical('Client output:\n' + str(client.output)) - -from Basis.Check import Check -Check('ss', proxySS, {})