Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,5 @@ dev/
*.sqlite3
*.sqlite3-journal
*.DS_Store
test_config.yaml
test_main.py
9 changes: 7 additions & 2 deletions ncatbot/utils/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []

Expand Down Expand Up @@ -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 号。"""
Expand Down
Loading