From 1dec6f4d8d4202e7278d1ccbf45a0ad5a0851e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AC=E9=97=B4=E7=99=BD=E7=8C=AB?= <139044047+honmashironeko@users.noreply.github.com> Date: Thu, 6 Feb 2025 09:43:24 +0800 Subject: [PATCH] Update --- Dockerfile | 4 ++-- ProxyCat-Manual/logs.md | 6 ++++++ config/getip.py | 27 ++++++++++++++------------- modules/modules.py | 8 +++++--- modules/proxyserver.py | 2 +- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 58b31f5..fe6dccf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,9 @@ WORKDIR /app COPY . . -RUN pip install --upgrade pip +RUN pip install --upgrade pip -i https://pypi.mirrors.ustc.edu.cn/simple/ -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple/ EXPOSE 1080 diff --git a/ProxyCat-Manual/logs.md b/ProxyCat-Manual/logs.md index c9f26f7..5302adb 100644 --- a/ProxyCat-Manual/logs.md +++ b/ProxyCat-Manual/logs.md @@ -1,3 +1,9 @@ +### 2025/02/06 + +- Docker 安装依赖库采用国内源 +- 增加Getip方式下主动提示:当前为API模式,收到请求将自动获取代理地址 +- 修改加白方式,自动根据请求结果加白 + ### 2025/01/14 - 增加 getip 方式下自动添加白名单机制。 diff --git a/config/getip.py b/config/getip.py index a5f9fc8..3099f4a 100644 --- a/config/getip.py +++ b/config/getip.py @@ -1,10 +1,8 @@ from modules.modules import get_message, load_config import requests - -first_run_flag = True +import time def newip(): - global first_run_flag config = load_config() language = config.get('language', 'cn') @@ -14,13 +12,6 @@ def newip(): raise ValueError(f"{error_type}: {details}") try: - if first_run_flag: - appKey = "" - anquanma = "" - whitelist_url = f"https://sch.shanchendaili.com/api.html?action=addWhiteList&appKey={appKey}&anquanma={anquanma}" - requests.get(whitelist_url).raise_for_status() - first_run_flag = False - url = config.get('getip_url', '') username = config.get('proxy_username', '') password = config.get('proxy_password', '') @@ -28,9 +19,19 @@ def newip(): if not url: raise ValueError('getip_url') - response = requests.get(url) - response.raise_for_status() - proxy = response.text.split("\r\n")[0] + def get_proxy(): + response = requests.get(url) + response.raise_for_status() + return response.text.split("\r\n")[0] + + proxy = get_proxy() + if proxy == "error000x-13": + appKey = "" + anquanma = "" + whitelist_url = f"https://sch.shanchendaili.com/api.html?action=addWhiteList&appKey={appKey}&anquanma={anquanma}" + requests.get(whitelist_url).raise_for_status() + time.sleep(1) + proxy = get_proxy() if username and password: return f"socks5://{username}:{password}@{proxy}" diff --git a/modules/modules.py b/modules/modules.py index c68bb64..dd986ba 100644 --- a/modules/modules.py +++ b/modules/modules.py @@ -73,7 +73,8 @@ MESSAGES = { 'consecutive_failures': '检测到连续代理失败: {}', 'invalid_proxy': '当前代理无效: {}', 'proxy_switched': '已从代理 {} 切换到 {}', - 'whitelist_error': '添加白名单失败: {}' + 'whitelist_error': '添加白名单失败: {}', + 'api_mode_notice': '当前为API模式,收到请求将自动获取代理地址' }, 'en': { 'getting_new_proxy': 'Getting new proxy IP', @@ -145,7 +146,8 @@ MESSAGES = { 'consecutive_failures': 'Consecutive proxy failures detected for {}', 'invalid_proxy': 'Current proxy is invalid: {}', 'proxy_switched': 'Switched from proxy {} to {}', - 'whitelist_error': 'Failed to add whitelist: {}' + 'whitelist_error': 'Failed to add whitelist: {}', + 'api_mode_notice': 'Currently in API mode, proxy address will be automatically obtained upon request' } } @@ -409,7 +411,7 @@ async def check_for_updates(language='cn'): match = re.search(r'
(ProxyCat-V\d+\.\d+\.\d+)
', content) if match: latest_version = match.group(1) - CURRENT_VERSION = "ProxyCat-V1.9.4" + CURRENT_VERSION = "ProxyCat-V1.9.5" if version.parse(latest_version.split('-V')[1]) > version.parse(CURRENT_VERSION.split('-V')[1]): print(f"{Fore.YELLOW}{get_message('new_version_found', language)} 当前版本: {CURRENT_VERSION}, 最新版本: {latest_version}") print(f"{Fore.YELLOW}{get_message('visit_quark', language)}") diff --git a/modules/proxyserver.py b/modules/proxyserver.py index b0c8ded..3116627 100644 --- a/modules/proxyserver.py +++ b/modules/proxyserver.py @@ -40,7 +40,7 @@ class AsyncProxyServer: else: self.proxies = [] self.proxy_cycle = None - self.current_proxy = None + self.current_proxy = get_message('api_mode_notice', self.language) self.last_switch_time = time.time() self.rate_limiter = asyncio.Queue(maxsize=3000)