From bd2003c1b6d80c8fc7ed49ffacec83ca4c032e8f Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 7 Dec 2023 19:02:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=A0=A1=E9=AA=8C=E6=96=B9=E6=B3=95=20(#3217?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/fail2ban.go | 2 +- backend/app/service/logs.go | 2 +- backend/app/service/setting.go | 6 +++++- backend/utils/toolbox/fail2ban.go | 4 ++-- frontend/src/global/form-rules.ts | 4 ++-- frontend/src/lang/modules/en.ts | 7 +++---- frontend/src/lang/modules/tw.ts | 6 +++--- frontend/src/lang/modules/zh.ts | 6 +++--- frontend/src/views/setting/safe/timeout/index.vue | 2 +- frontend/src/views/toolbox/fail2ban/ban-time/index.vue | 6 +++++- frontend/src/views/toolbox/fail2ban/find-time/index.vue | 2 +- frontend/src/views/toolbox/fail2ban/max-retry/index.vue | 2 +- 12 files changed, 28 insertions(+), 21 deletions(-) diff --git a/backend/app/service/fail2ban.go b/backend/app/service/fail2ban.go index 7b151cb36..8c934dba5 100644 --- a/backend/app/service/fail2ban.go +++ b/backend/app/service/fail2ban.go @@ -120,7 +120,7 @@ func (u *Fail2BanService) UpdateConf(req dto.Fail2BanUpdate) error { newFile += fmt.Sprintf("%s = %s\n", req.Key, req.Value) continue } - if strings.HasPrefix(line, "[") || index != len(lines)-1 { + if strings.HasPrefix(line, "[") || index == len(lines)-1 { isEnd = true if !hasKey { newFile += fmt.Sprintf("%s = %s\n", req.Key, req.Value) diff --git a/backend/app/service/logs.go b/backend/app/service/logs.go index c13d0a036..41c2b7ffe 100644 --- a/backend/app/service/logs.go +++ b/backend/app/service/logs.go @@ -51,7 +51,7 @@ func (u *LogService) ListSystemLogFile() ([]string, error) { if err != nil { return err } - if !info.IsDir() && strings.HasPrefix(info.Name(), "1Panel-") { + if !info.IsDir() && strings.HasPrefix(info.Name(), "1Panel") { if info.Name() == "1Panel.log" { files = append(files, time.Now().Format("2006-01-02")) return nil diff --git a/backend/app/service/setting.go b/backend/app/service/setting.go index d7192145f..1be472be8 100644 --- a/backend/app/service/setting.go +++ b/backend/app/service/setting.go @@ -107,7 +107,10 @@ func (u *SettingService) Update(key, value string) error { switch key { case "ExpirationDays": - timeout, _ := strconv.Atoi(value) + timeout, err := strconv.Atoi(value) + if err != nil { + return err + } if err := settingRepo.Update("ExpirationTime", time.Now().AddDate(0, 0, timeout).Format("2006-01-02 15:04:05")); err != nil { return err } @@ -150,6 +153,7 @@ func (u *SettingService) UpdateBindInfo(req dto.BindInfo) error { return err } go func() { + time.Sleep(1 * time.Second) _, err := cmd.Exec("systemctl restart 1panel.service") if err != nil { global.LOG.Errorf("restart system with new bind info failed, err: %v", err) diff --git a/backend/utils/toolbox/fail2ban.go b/backend/utils/toolbox/fail2ban.go index 9ef42b2a4..00e68a906 100644 --- a/backend/utils/toolbox/fail2ban.go +++ b/backend/utils/toolbox/fail2ban.go @@ -29,9 +29,9 @@ func NewFail2Ban() (*Fail2ban, error) { if err := initLocalFile(); err != nil { return nil, err } - stdout, err := cmd.Exec("fail2ban-client reload") + stdout, err := cmd.Exec("systemctl restart fail2ban.service") if err != nil { - global.LOG.Errorf("reload fail2ban failed, err: %s", stdout) + global.LOG.Errorf("restart fail2ban failed, err: %s", stdout) return nil, err } } diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 07940006f..6c3b58c44 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -145,7 +145,7 @@ const checkUserName = (rule: any, value: any, callback: any) => { if (value === '' || typeof value === 'undefined' || value == null) { callback(new Error(i18n.global.t('commons.rule.userName'))); } else { - const reg = /[a-zA-Z0-9_\u4e00-\u9fa5]{3,30}$/; + const reg = /^[a-zA-Z0-9_\u4e00-\u9fa5]{3,30}$/; if (!reg.test(value) && value !== '') { callback(new Error(i18n.global.t('commons.rule.userName'))); } else { @@ -158,7 +158,7 @@ const checkSimpleName = (rule: any, value: any, callback: any) => { if (value === '' || typeof value === 'undefined' || value == null) { callback(new Error(i18n.global.t('commons.rule.simpleName'))); } else { - const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{1,29}$/; + const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{2,29}$/; if (!reg.test(value) && value !== '') { callback(new Error(i18n.global.t('commons.rule.simpleName'))); } else { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 917e19424..d7ef36e6f 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -158,12 +158,12 @@ const message = { illegalInput: 'There are illegal characters in the input box.', commonName: 'Support English, Chinese, numbers, .-, and _ length 1-128', userName: 'Support English, Chinese, numbers and _ length 3-30', - simpleName: 'Support English, numbers and _ length 1-30', + simpleName: 'Supports non-underscore starting, English, numbers, _, length 1-30', dbName: 'Support English, Chinese, numbers, .-, and _ length 1-64', imageName: 'Support English, numbers, :/.-_, length 1-150', volumeName: 'Support English, numbers, .-_, length 2-30', complexityPassword: - 'Longer than eight characters and contains at least two combinations of letters, digits, and special characters', + 'Please enter a password combination with a length of 8-30 characters, including letters, numbers, and at least two special characters.', commonPassword: 'Please enter a password with more than 6 characters', linuxName: 'Length 1-128, the name cannot contain symbols such as {0}', email: 'Email format error', @@ -1277,8 +1277,7 @@ const message = { '[ {0} days ] The panel password is about to expire. After the expiration, you need to reset the password', complexity: 'Complexity Verification', complexityHelper: - 'The password must contain at least eight characters and contain at least three uppercase letters, lowercase letters, digits, and special characters', - + 'After enabling, the password must have a length of 8-30 characters, including letters, numbers, and at least two special characters.', bindDomain: 'Bind Domain', unBindDomain: 'Unbind domain', panelSSL: 'Panel SSL', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index deb56ba2d..aefa8e3ec 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -159,11 +159,11 @@ const message = { illegalInput: '輸入框中存在不合法字符', commonName: '支持英文、中文、數字、.-和_,長度1-128', userName: '支持英文、中文、數字和_,長度3-30', - simpleName: '支持英文、數字、_,長度1-30', + simpleName: '支持非底線開頭,英文、數字、_,長度1-30', dbName: '支持英文、中文、數字、.-_,長度1-64', imageName: '支持英文、數字、:/.-_,長度1-150', volumeName: '支持英文、數字、.-和_,長度2-30', - complexityPassword: '請輸入長度大於 8 位且包含字母、數字、特殊字符至少兩項的密碼組合', + complexityPassword: '請輸入長度為 8-30 位,並包含字母、數字、至少兩種特殊字符的密碼組合', commonPassword: '請輸入 6 位以上長度密碼', linuxName: '長度1-128,名稱不能含有{0}等符號', email: '請輸入正確的郵箱', @@ -1240,7 +1240,7 @@ const message = { expiredHelper: '當前密碼已過期,請重新修改密碼:', timeoutHelper: '【 {0} 天後 】面板密碼即將過期,過期後需要重新設置密碼', complexity: '密碼復雜度驗證', - complexityHelper: '開啟後密碼必須滿足密碼長度大於 8 位且包含字母、數字及特殊字符', + complexityHelper: '開啟後密碼必須滿足長度為 8-30 位,並包含字母、數字、至少兩種特殊字符', bindDomain: '域名綁定', unBindDomain: '域名解綁', panelSSL: '面板 SSL', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index a1a8ef40b..79d388161 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -159,11 +159,11 @@ const message = { illegalInput: '输入框中存在不合法字符', commonName: '支持英文、中文、数字、.-和_,长度1-128', userName: '支持英文、中文、数字和_,长度3-30', - simpleName: '支持英文、数字、_,长度1-30', + simpleName: '支持非下划线开头,英文、数字、_,长度3-30', dbName: '支持英文、中文、数字、.-_,长度1-64', imageName: '支持英文、数字、:/.-_,长度1-150', volumeName: '支持英文、数字、.-和_,长度2-30', - complexityPassword: '请输入长度大于 8 位且包含字母、数字、特殊字符至少两项的密码组合', + complexityPassword: '请输入长度为 8-30 位且包含字母、数字、特殊字符至少两项的密码组合', commonPassword: '请输入 6 位以上长度密码', linuxName: '长度1-128,名称不能含有{0}等符号', email: '请输入正确的邮箱', @@ -1241,7 +1241,7 @@ const message = { expiredHelper: '当前密码已过期,请重新修改密码:', timeoutHelper: '【 {0} 天后 】面板密码即将过期,过期后需要重新设置密码', complexity: '密码复杂度验证', - complexityHelper: '开启后密码必须满足密码长度大于 8 位且包含字母、数字及特殊字符', + complexityHelper: '开启后密码必须满足长度为 8-30 位且包含字母、数字、特殊字符至少两项', bindDomain: '域名绑定', unBindDomain: '域名解绑', panelSSL: '面板 SSL', diff --git a/frontend/src/views/setting/safe/timeout/index.vue b/frontend/src/views/setting/safe/timeout/index.vue index 3b6b784e0..30c2d2bb7 100644 --- a/frontend/src/views/setting/safe/timeout/index.vue +++ b/frontend/src/views/setting/safe/timeout/index.vue @@ -10,7 +10,7 @@ {{ $t('setting.expirationHelper') }} diff --git a/frontend/src/views/toolbox/fail2ban/ban-time/index.vue b/frontend/src/views/toolbox/fail2ban/ban-time/index.vue index bd6bfaf58..c25062b76 100644 --- a/frontend/src/views/toolbox/fail2ban/ban-time/index.vue +++ b/frontend/src/views/toolbox/fail2ban/ban-time/index.vue @@ -7,7 +7,11 @@ - +