diff --git a/astrbot/cli/commands/cmd_run.py b/astrbot/cli/commands/cmd_run.py index 6039d2eff..68b71dca9 100644 --- a/astrbot/cli/commands/cmd_run.py +++ b/astrbot/cli/commands/cmd_run.py @@ -52,8 +52,10 @@ def run(reload: bool, host: str, port: str, backend_only: bool) -> None: os.environ["ASTRBOT_ROOT"] = str(astrbot_root) sys.path.insert(0, str(astrbot_root)) - os.environ["DASHBOARD_PORT"] = port or "6185" - os.environ["DASHBOARD_HOST"] = host or "::" + if port is not None: + os.environ["DASHBOARD_PORT"] = port + if host is not None: + os.environ["DASHBOARD_HOST"] = host os.environ["DASHBOARD_ENABLE"] = str(not backend_only) if reload: diff --git a/astrbot/core/utils/io.py b/astrbot/core/utils/io.py index 9b0efb6b2..04adca634 100644 --- a/astrbot/core/utils/io.py +++ b/astrbot/core/utils/io.py @@ -254,8 +254,10 @@ async def get_public_ip_address() -> list[IPv4Address | IPv6Address]: ip = ip_address(raw_ip) if ip.version not in found_ips: found_ips[ip.version] = ip - except Exception: - pass + except Exception as e: + # Ignore errors from individual services so that a single failing + # endpoint does not prevent discovering the public IP from others. + logger.debug("Failed to fetch public IP from %s: %s", url, e) async with aiohttp.ClientSession() as session: tasks = [fetch(session, url) for url in urls] diff --git a/astrbot/dashboard/routes/route.py b/astrbot/dashboard/routes/route.py index 530a0807c..8a22e1fa5 100644 --- a/astrbot/dashboard/routes/route.py +++ b/astrbot/dashboard/routes/route.py @@ -59,4 +59,5 @@ class Response: return self def to_json(self): - return jsonify(asdict(self)) + # Return a plain dict so callers can safely wrap with jsonify() + return asdict(self) diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index db747b61e..71ae398fb 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -1,5 +1,4 @@ import asyncio -import ipaddress import logging import os import platform @@ -33,6 +32,11 @@ from .routes.session_management import SessionManagementRoute from .routes.subagent import SubAgentRoute from .routes.t2i import T2iRoute + +class _AddrWithPort(Protocol): + port: int + + APP: Quart