From d08c809ee20eadaa04283dd10f8eeafb560da4aa Mon Sep 17 00:00:00 2001 From: HayaseYuuka Date: Thu, 12 Feb 2026 19:48:04 +0800 Subject: [PATCH] fix --- .gitignore | 2 ++ ncatbot/utils/config/models.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5aa3253d..734c1a0a 100644 --- a/.gitignore +++ b/.gitignore @@ -180,3 +180,5 @@ dev/ *.sqlite3 *.sqlite3-journal *.DS_Store +test_config.yaml +test_main.py diff --git a/ncatbot/utils/config/models.py b/ncatbot/utils/config/models.py index 191b6e28..23bc418d 100644 --- a/ncatbot/utils/config/models.py +++ b/ncatbot/utils/config/models.py @@ -133,20 +133,23 @@ def get_security_issues(self, auto_fix: bool = True) -> List[str]: """ issues = [] can_auto_fix = auto_fix + need_fix = False # WS Token 检查 if self.ws_listen_ip == "0.0.0.0" and not strong_password_check(self.ws_token): if self.ws_token != DEFAULT_WS_TOKEN: can_auto_fix = False issues.append("WS 令牌强度不足") + need_fix = True # WebUI Token 检查 if self.enable_webui and not strong_password_check(self.webui_token): if self.webui_token != DEFAULT_WEBUI_TOKEN: can_auto_fix = False issues.append("WebUI 令牌强度不足") + need_fix = True - if can_auto_fix: + if can_auto_fix and need_fix: self.fix_security_issues() return [] @@ -178,7 +181,9 @@ def _coerce_to_str(cls, v) -> str: def is_local(self) -> bool: """NapCat 是否为本地服务。""" - return self.napcat.ws_host in ("localhost", "127.0.0.1") + if self.napcat.remote_mode is None: + return self.napcat.ws_host in ("localhost", "127.0.0.1") + return self.napcat.remote_mode def is_default_uin(self) -> bool: """是否使用默认 QQ 号。"""