mirror of
https://github.com/honmashironeko/ProxyCat.git
synced 2025-11-05 10:51:06 +00:00
Update
This commit is contained in:
parent
67a5049f3b
commit
1f8419d07a
@ -10,5 +10,5 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
EXPOSE 1080
|
||||
|
||||
CMD ["python", "ProxyCat.py", "-c", "/app/config/config.ini"]
|
||||
CMD ["python", "ProxyCat.py"]
|
||||
|
||||
|
||||
23
ProxyCat.py
23
ProxyCat.py
@ -30,12 +30,23 @@ logging.basicConfig(level=logging.INFO, handlers=[console_handler])
|
||||
|
||||
def update_status(server):
|
||||
while True:
|
||||
if server.mode == 'load_balance':
|
||||
status = f"\r{Fore.YELLOW}{get_message('current_proxy', server.language)}: {Fore.GREEN}{server.current_proxy}"
|
||||
else:
|
||||
time_left = server.time_until_next_switch()
|
||||
status = f"\r{Fore.YELLOW}{get_message('current_proxy', server.language)}: {Fore.GREEN}{server.current_proxy} | {Fore.YELLOW}{get_message('next_switch', server.language)}: {Fore.GREEN}{time_left:.1f}{get_message('seconds', server.language)}"
|
||||
print(status, end='', flush=True)
|
||||
try:
|
||||
if server.mode == 'load_balance':
|
||||
status = f"\r{Fore.YELLOW}{get_message('current_proxy', server.language)}: {Fore.GREEN}{server.current_proxy}"
|
||||
else:
|
||||
time_left = server.time_until_next_switch()
|
||||
if time_left == float('inf'):
|
||||
status = f"\r{Fore.YELLOW}{get_message('current_proxy', server.language)}: {Fore.GREEN}{server.current_proxy}"
|
||||
else:
|
||||
status = f"\r{Fore.YELLOW}{get_message('current_proxy', server.language)}: {Fore.GREEN}{server.current_proxy} | {Fore.YELLOW}{get_message('next_switch', server.language)}: {Fore.GREEN}{time_left:.1f}{get_message('seconds', server.language)}"
|
||||
|
||||
if os.path.exists('/.dockerenv'):
|
||||
logging.info(status)
|
||||
else:
|
||||
print(status, end='', flush=True)
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Status update error: {e}")
|
||||
time.sleep(1)
|
||||
|
||||
async def handle_client_wrapper(server, reader, writer, clients):
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
version: '3'
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
container_name: proxycat
|
||||
ports:
|
||||
- "1080:1080"
|
||||
volumes:
|
||||
- "./config:/app/config"
|
||||
network_mode: host
|
||||
command: ["python", "ProxyCat.py", "-c", "/app/config/config.ini"]
|
||||
restart: always
|
||||
- ./config:/app/config
|
||||
restart: unless-stopped
|
||||
network_mode: "bridge"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import asyncio, httpx, logging, re, socket, struct, time, socket, base64, random
|
||||
import asyncio, httpx, logging, re, socket, struct, time, socket, base64, random, os
|
||||
from modules.modules import get_message, load_ip_list
|
||||
from asyncio import TimeoutError
|
||||
from itertools import cycle
|
||||
@ -612,3 +612,16 @@ class AsyncProxyServer:
|
||||
print(f"{direction} 数据传输超时")
|
||||
except Exception as e:
|
||||
print(f"{direction} 数据传输错误: {e}")
|
||||
|
||||
def is_docker():
|
||||
return os.path.exists('/.dockerenv')
|
||||
|
||||
async def get_proxy_status(self):
|
||||
if self.mode == 'load_balance':
|
||||
return f"{get_message('current_proxy', self.language)}: {self.current_proxy}"
|
||||
else:
|
||||
time_left = self.time_until_next_switch()
|
||||
if time_left == float('inf'):
|
||||
return f"{get_message('current_proxy', self.language)}: {self.current_proxy}"
|
||||
else:
|
||||
return f"{get_message('current_proxy', self.language)}: {self.current_proxy} | {get_message('next_switch', self.language)}: {time_left:.1f}{get_message('seconds', self.language)}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user