From 780cda9e1b125bf5b5e1e9664777e7c80a1e2d82 Mon Sep 17 00:00:00 2001 From: Amirmohammad Sadat Shokouhi Date: Fri, 16 May 2025 20:57:59 +0330 Subject: [PATCH] remove password from local logs and tgbot logs --- web/controller/index.go | 7 +++---- web/service/tgbot.go | 3 +-- web/translation/translate.ar_EG.toml | 1 - web/translation/translate.en_US.toml | 1 - web/translation/translate.es_ES.toml | 1 - web/translation/translate.fa_IR.toml | 1 - web/translation/translate.id_ID.toml | 1 - web/translation/translate.ja_JP.toml | 1 - web/translation/translate.pt_BR.toml | 1 - web/translation/translate.ru_RU.toml | 1 - web/translation/translate.tr_TR.toml | 1 - web/translation/translate.uk_UA.toml | 1 - web/translation/translate.vi_VN.toml | 1 - web/translation/translate.zh_CN.toml | 1 - web/translation/translate.zh_TW.toml | 1 - 15 files changed, 4 insertions(+), 19 deletions(-) diff --git a/web/controller/index.go b/web/controller/index.go index c19d1b6e..b6f4b50b 100644 --- a/web/controller/index.go +++ b/web/controller/index.go @@ -67,17 +67,16 @@ func (a *IndexController) login(c *gin.Context) { user := a.userService.CheckUser(form.Username, form.Password, form.TwoFactorCode) timeStr := time.Now().Format("2006-01-02 15:04:05") safeUser := template.HTMLEscapeString(form.Username) - safePass := template.HTMLEscapeString(form.Password) if user == nil { - logger.Warningf("wrong username: \"%s\", password: \"%s\", IP: \"%s\"", safeUser, safePass, getRemoteIp(c)) - a.tgbot.UserLoginNotify(safeUser, safePass, getRemoteIp(c), timeStr, 0) + logger.Warningf("wrong username: \"%s\", IP: \"%s\"", safeUser, getRemoteIp(c)) + a.tgbot.UserLoginNotify(safeUser, getRemoteIp(c), timeStr, 0) pureJsonMsg(c, http.StatusOK, false, I18nWeb(c, "pages.login.toasts.wrongUsernameOrPassword")) return } logger.Infof("%s logged in successfully, Ip Address: %s\n", safeUser, getRemoteIp(c)) - a.tgbot.UserLoginNotify(safeUser, ``, getRemoteIp(c), timeStr, 1) + a.tgbot.UserLoginNotify(safeUser, getRemoteIp(c), timeStr, 1) sessionMaxAge, err := a.settingService.GetSessionMaxAge() if err != nil { diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 2f36697e..097314ef 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -1975,7 +1975,7 @@ func (t *Tgbot) prepareServerUsageInfo() string { return info } -func (t *Tgbot) UserLoginNotify(username string, password string, ip string, time string, status LoginStatus) { +func (t *Tgbot) UserLoginNotify(username string, ip string, time string, status LoginStatus) { if !t.IsRunning() { return } @@ -1997,7 +1997,6 @@ func (t *Tgbot) UserLoginNotify(username string, password string, ip string, tim } else if status == LoginFail { msg += t.I18nBot("tgbot.messages.loginFailed") msg += t.I18nBot("tgbot.messages.hostname", "Hostname=="+hostname) - msg += t.I18nBot("tgbot.messages.password", "Password=="+password) } msg += t.I18nBot("tgbot.messages.username", "Username=="+username) msg += t.I18nBot("tgbot.messages.ip", "IP=="+ip) diff --git a/web/translation/translate.ar_EG.toml b/web/translation/translate.ar_EG.toml index c8e28a5a..24f3e7d8 100644 --- a/web/translation/translate.ar_EG.toml +++ b/web/translation/translate.ar_EG.toml @@ -612,7 +612,6 @@ "traffic" = "🚦 الترافيك: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ الحالة: {{ .State }}\r\n" "username" = "👤 اسم المستخدم: {{ .Username }}\r\n" -"password" = "👤 الباسورد: {{ .Password }}\r\n" "time" = "⏰ الوقت: {{ .Time }}\r\n" "inbound" = "📍 الإدخال: {{ .Remark }}\r\n" "port" = "🔌 البورت: {{ .Port }}\r\n" diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index ec7507f4..846a5393 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -611,7 +611,6 @@ "traffic" = "🚦 Traffic: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Status: {{ .State }}\r\n" "username" = "👤 Username: {{ .Username }}\r\n" -"password" = "👤 Password: {{ .Password }}\r\n" "time" = "⏰ Time: {{ .Time }}\r\n" "inbound" = "📍 Inbound: {{ .Remark }}\r\n" "port" = "🔌 Port: {{ .Port }}\r\n" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index 376bd115..8a5d0024 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 Tráfico: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Estado de Xray: {{ .State }}\r\n" "username" = "👤 Nombre de usuario: {{ .Username }}\r\n" -"password" = "👤 Contraseña: {{ .Password }}\r\n" "time" = "⏰ Hora: {{ .Time }}\r\n" "inbound" = "📍 Inbound: {{ .Remark }}\r\n" "port" = "🔌 Puerto: {{ .Port }}\r\n" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index e7b479af..3fc8c7b3 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 ترافیک: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ وضعیت‌ایکس‌ری: {{ .State }}\r\n" "username" = "👤 نام‌کاربری: {{ .Username }}\r\n" -"password" = "👤 رمز عبور: {{ .Password }}\r\n" "time" = "⏰ زمان: {{ .Time }}\r\n" "inbound" = "📍 نام‌ورودی: {{ .Remark }}\r\n" "port" = "🔌 پورت: {{ .Port }}\r\n" diff --git a/web/translation/translate.id_ID.toml b/web/translation/translate.id_ID.toml index 4bba61a0..4656d642 100644 --- a/web/translation/translate.id_ID.toml +++ b/web/translation/translate.id_ID.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 Lalu Lintas: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Status: {{ .State }}\r\n" "username" = "👤 Nama Pengguna: {{ .Username }}\r\n" -"password" = "👤 Kata Sandi: {{ .Password }}\r\n" "time" = "⏰ Waktu: {{ .Time }}\r\n" "inbound" = "📍 Inbound: {{ .Remark }}\r\n" "port" = "🔌 Port: {{ .Port }}\r\n" diff --git a/web/translation/translate.ja_JP.toml b/web/translation/translate.ja_JP.toml index ca4385c4..eb085e96 100644 --- a/web/translation/translate.ja_JP.toml +++ b/web/translation/translate.ja_JP.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 トラフィック:{{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Xrayステータス:{{ .State }}\r\n" "username" = "👤 ユーザー名:{{ .Username }}\r\n" -"password" = "👤 パスワード: {{ .Password }}\r\n" "time" = "⏰ 時間:{{ .Time }}\r\n" "inbound" = "📍 インバウンド:{{ .Remark }}\r\n" "port" = "🔌 ポート:{{ .Port }}\r\n" diff --git a/web/translation/translate.pt_BR.toml b/web/translation/translate.pt_BR.toml index eb5d37ce..6f97eb50 100644 --- a/web/translation/translate.pt_BR.toml +++ b/web/translation/translate.pt_BR.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 Tráfego: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Status: {{ .State }}\r\n" "username" = "👤 Nome de usuário: {{ .Username }}\r\n" -"password" = "👤 Senha: {{ .Password }}\r\n" "time" = "⏰ Hora: {{ .Time }}\r\n" "inbound" = "📍 Inbound: {{ .Remark }}\r\n" "port" = "🔌 Porta: {{ .Port }}\r\n" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index f1d14459..89cd8526 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 Трафик: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Состояние Xray: {{ .State }}\r\n" "username" = "👤 Имя пользователя: {{ .Username }}\r\n" -"password" = "👤 Пароль: {{ .Password }}\r\n" "time" = "⏰ Время: {{ .Time }}\r\n" "inbound" = "📍 Входящий поток: {{ .Remark }}\r\n" "port" = "🔌 Порт: {{ .Port }}\r\n" diff --git a/web/translation/translate.tr_TR.toml b/web/translation/translate.tr_TR.toml index 9537b966..7ee8d009 100644 --- a/web/translation/translate.tr_TR.toml +++ b/web/translation/translate.tr_TR.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 Trafik: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Durum: {{ .State }}\r\n" "username" = "👤 Kullanıcı Adı: {{ .Username }}\r\n" -"password" = "👤 Şifre: {{ .Password }}\r\n" "time" = "⏰ Zaman: {{ .Time }}\r\n" "inbound" = "📍 Gelen: {{ .Remark }}\r\n" "port" = "🔌 Port: {{ .Port }}\r\n" diff --git a/web/translation/translate.uk_UA.toml b/web/translation/translate.uk_UA.toml index 858a95f8..6d1459f3 100644 --- a/web/translation/translate.uk_UA.toml +++ b/web/translation/translate.uk_UA.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 Трафік: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Статус: {{ .State }}\r\n" "username" = "👤 Ім'я користувача: {{ .Username }}\r\n" -"password" = "👤 Пароль: {{ .Password }}\r\n" "time" = "⏰ Час: {{ .Time }}\r\n" "inbound" = "📍 Inbound: {{ .Remark }}\r\n" "port" = "🔌 Порт: {{ .Port }}\r\n" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index 0e700ab5..82bad03f 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 Lưu lượng: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Trạng thái Xray: {{ .State }}\r\n" "username" = "👤 Tên người dùng: {{ .Username }}\r\n" -"password" = "👤 Mật khẩu: {{ .Password }}\r\n" "time" = "⏰ Thời gian: {{ .Time }}\r\n" "inbound" = "📍 Inbound: {{ .Remark }}\r\n" "port" = "🔌 Cổng: {{ .Port }}\r\n" diff --git a/web/translation/translate.zh_CN.toml b/web/translation/translate.zh_CN.toml index d9f163ee..3f6a68e5 100644 --- a/web/translation/translate.zh_CN.toml +++ b/web/translation/translate.zh_CN.toml @@ -614,7 +614,6 @@ "traffic" = "🚦 流量:{{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Xray 状态:{{ .State }}\r\n" "username" = "👤 用户名:{{ .Username }}\r\n" -"password" = "👤 密码: {{ .Password }}\r\n" "time" = "⏰ 时间:{{ .Time }}\r\n" "inbound" = "📍 入站:{{ .Remark }}\r\n" "port" = "🔌 端口:{{ .Port }}\r\n" diff --git a/web/translation/translate.zh_TW.toml b/web/translation/translate.zh_TW.toml index 34ad9472..d552e806 100644 --- a/web/translation/translate.zh_TW.toml +++ b/web/translation/translate.zh_TW.toml @@ -616,7 +616,6 @@ "traffic" = "🚦 流量:{{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n" "xrayStatus" = "ℹ️ Xray 狀態:{{ .State }}\r\n" "username" = "👤 使用者名稱:{{ .Username }}\r\n" -"password" = "👤 密碼: {{ .Password }}\r\n" "time" = "⏰ 時間:{{ .Time }}\r\n" "inbound" = "📍 入站:{{ .Remark }}\r\n" "port" = "🔌 埠:{{ .Port }}\r\n"