From d08a53f2b2497aa24ef454d6dd37ad653bb16b39 Mon Sep 17 00:00:00 2001 From: duorameng <2997944583@qq.com> Date: Thu, 14 May 2026 09:02:16 +0800 Subject: [PATCH] chore: update dev host --- internal/constant/constant.go | 8 ++++---- internal/utils/network.go | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/constant/constant.go b/internal/constant/constant.go index d26c54f..5751c9c 100644 --- a/internal/constant/constant.go +++ b/internal/constant/constant.go @@ -75,8 +75,8 @@ const ( // Notify Templates Keys KeyNotifyTemplateUserLoginTitle = "notify_template_user_login_title" KeyNotifyTemplateUserLoginText = "notify_template_user_login_text" - KeyNotifyTemplateBruteForceLoginTitle = "notify_template_brute_force_login_title" - KeyNotifyTemplateBruteForceLoginText = "notify_template_brute_force_login_text" + KeyNotifyTemplateBruteForceLoginTitle = "notify_template_brute_force_login_title" + KeyNotifyTemplateBruteForceLoginText = "notify_template_brute_force_login_text" KeyNotifyTemplatePasswordChangedTitle = "notify_template_password_changed_title" KeyNotifyTemplatePasswordChangedText = "notify_template_password_changed_text" KeyNotifyTemplateTaskSuccessTitle = "notify_template_task_success_title" @@ -228,8 +228,8 @@ var DefaultSettings = map[string]map[string]string{ // Login KeyNotifyTemplateUserLoginTitle: "用户登录(成功/失败)", KeyNotifyTemplateUserLoginText: "用户 {{username}} 在 IP {{ip}} 登录{{status_label}}\n{{message}}", - KeyNotifyTemplateBruteForceLoginTitle: "系统安全警告", - KeyNotifyTemplateBruteForceLoginText: "检测到 IP {{ip}} 正在尝试暴力破解用户 {{username}}", + KeyNotifyTemplateBruteForceLoginTitle: "系统安全警告", + KeyNotifyTemplateBruteForceLoginText: "检测到 IP {{ip}} 正在尝试暴力破解用户 {{username}}", KeyNotifyTemplatePasswordChangedTitle: "账户安全通知", KeyNotifyTemplatePasswordChangedText: "用户 {{username}} 刚刚修改了密码", // Task diff --git a/internal/utils/network.go b/internal/utils/network.go index 193e9ea..b4c7947 100644 --- a/internal/utils/network.go +++ b/internal/utils/network.go @@ -49,8 +49,11 @@ func CheckWSOrigin(r *http.Request) bool { } } - // 3. 允许来自 localhost 和 127.0.0.1 的请求 (方便本地开发和同机部署) - if strings.HasPrefix(u.Host, "localhost") || strings.HasPrefix(u.Host, "127.0.0.1") { + // 3. 允许来自 localhost、127.0.0.1 以及局域网内网 IP 的请求 (方便本地开发、虚拟机调试和局域网部署) + hostname := u.Hostname() + if strings.HasPrefix(hostname, "localhost") || strings.HasPrefix(hostname, "127.0.0.1") || + strings.HasPrefix(hostname, "192.168.") || strings.HasPrefix(hostname, "10.") || + strings.HasPrefix(hostname, "172.") { return true }