This commit is contained in:
本间白猫 2025-03-14 15:36:28 +08:00
parent aaddbbe723
commit 1c74d622ce
4 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,9 @@
### 2025/03/14
- 修复'_last_used'报错问题,连接关闭方式修正
- 修复本地代理读取时切换逻辑失效问题
- 增加切换时间间隔设置为0时进入每次请求都更换IP
### 2025/03/03
- 美化 Web管理界面

2
app.py
View File

@ -523,7 +523,7 @@ def check_version():
original_level = httpx_logger.level
httpx_logger.setLevel(logging.WARNING)
CURRENT_VERSION = "ProxyCat-V2.0.1"
CURRENT_VERSION = "ProxyCat-V2.0.2"
try:
client = httpx.Client(transport=httpx.HTTPTransport(retries=3))

View File

@ -480,7 +480,6 @@ def load_config(config_file='config/config.ini'):
result = dict(config.items('Server'))
# 添加用户配置
if config.has_section('Users'):
result['Users'] = dict(config.items('Users'))
@ -638,7 +637,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-V2.0.1"
CURRENT_VERSION = "ProxyCat-V2.0.2"
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}{Style.RESET_ALL}")
print(f"{Fore.YELLOW}{get_message('visit_quark', language)}{Style.RESET_ALL}")

View File

@ -185,11 +185,12 @@ class AsyncProxyServer:
try:
current_time = time.time()
if self.switching_proxy or (current_time - self.last_switch_attempt < self.switch_cooldown):
if self.interval != 0 and (self.switching_proxy or (current_time - self.last_switch_attempt < self.switch_cooldown)):
return self.current_proxy
if (self.use_getip and (not self.current_proxy or
current_time - self.last_switch_time >= self.interval)):
current_time - self.last_switch_time >= self.interval)) or \
(not self.use_getip and self.interval == 0):
try:
self.switching_proxy = True
self.last_switch_attempt = current_time
@ -337,7 +338,7 @@ class AsyncProxyServer:
else:
proxy_url = f"{proxy_type}://{proxy_addr}"
return httpx.AsyncClient(
client = httpx.AsyncClient(
proxies={"all://": proxy_url},
limits=httpx.Limits(
max_keepalive_connections=100,
@ -348,6 +349,8 @@ class AsyncProxyServer:
http2=True,
verify=False
)
client._last_used = time.time()
return client
async def _cleanup_connections(self):
current_time = time.time()
@ -903,6 +906,7 @@ class AsyncProxyServer:
if proxy in self.proxy_pool:
conn = self.proxy_pool[proxy]
if not conn.is_closed:
conn._last_used = time.time()
return conn
proxy_type, proxy_addr = proxy.split('://')
@ -928,6 +932,7 @@ class AsyncProxyServer:
)
if len(self.proxy_pool) < self.max_pool_size:
conn._last_used = time.time()
self.proxy_pool[proxy] = conn
return conn