This commit is contained in:
本间白猫 2025-02-06 09:43:24 +08:00
parent ee2459aeb9
commit 1dec6f4d8d
5 changed files with 28 additions and 19 deletions

View File

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

View File

@ -1,3 +1,9 @@
### 2025/02/06
- Docker 安装依赖库采用国内源
- 增加Getip方式下主动提示当前为API模式收到请求将自动获取代理地址
- 修改加白方式,自动根据请求结果加白
### 2025/01/14
- 增加 getip 方式下自动添加白名单机制。

View File

@ -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}"

View File

@ -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'<p>(ProxyCat-V\d+\.\d+\.\d+)</p>', 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)}")

View File

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