From e5b2da225ca8429b90c4fab3a12fc332ccfb9d93 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Wed, 21 May 2025 19:42:04 +0800 Subject: [PATCH] perf: no longer get host ip --- pkg/core/app.py | 17 +++++------------ pkg/utils/ip.py | 10 ---------- 2 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 pkg/utils/ip.py diff --git a/pkg/core/app.py b/pkg/core/app.py index 910caa75..37970008 100644 --- a/pkg/core/app.py +++ b/pkg/core/app.py @@ -23,7 +23,7 @@ from ..api.http.service import model as model_service from ..api.http.service import pipeline as pipeline_service from ..api.http.service import bot as bot_service from ..discover import engine as discover_engine -from ..utils import logcache, ip +from ..utils import logcache from . import taskmgr from . import entities as core_entities @@ -166,23 +166,16 @@ class Application: host_ip = '127.0.0.1' - public_ip = await ip.get_myip() - port = self.instance_config.data['api']['port'] tips = f""" ======================================= -✨ 您可通过以下方式访问管理面板 +✨ Access WebUI / 访问管理面板 -🏠 本地地址:http://{host_ip}:{port}/ -🌐 公网地址:http://{public_ip}:{port}/ +🏠 Local Address: http://{host_ip}:{port}/ +🌐 Public Address: http://:{port}/ -📌 如果您在容器中运行此程序,请确保容器的 {port} 端口已对外暴露 -🔗 若要使用公网地址访问,请阅读以下须知 - 1. 公网地址仅供参考,请以您的主机公网 IP 为准; - 2. 要使用公网地址访问,请确保您的主机具有公网 IP,并且系统防火墙已放行 {port} 端口; - -🤯 WebUI 仍处于 Beta 测试阶段,如有问题或建议请反馈到 https://github.com/RockChinQ/LangBot/issues +📌 Running this program in a container? Please ensure that the {port} port is exposed ======================================= """.strip() for line in tips.split('\n'): diff --git a/pkg/utils/ip.py b/pkg/utils/ip.py deleted file mode 100644 index c67fe687..00000000 --- a/pkg/utils/ip.py +++ /dev/null @@ -1,10 +0,0 @@ -import aiohttp - - -async def get_myip() -> str: - try: - async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10)) as session: - async with session.get('https://ip.useragentinfo.com/myip') as response: - return await response.text() - except Exception: - return '0.0.0.0'