From a6e2efa6c9bae00e696cc2401706bc68de967f78 Mon Sep 17 00:00:00 2001 From: zhudaguanren <50785811@qq.com> Date: Tue, 1 Sep 2026 18:15:32 +0800 Subject: [PATCH] fix(fail2ban): treat process as active when client ping succeeds (#13679) Fail2ban UI currently keys isActive only on systemd fail2ban.service. If the daemon is alive under another process manager, whitelist and blacklist stay disabled. Detect liveness with fail2ban-client ping. Fixes #13678 Co-authored-by: zhudaguaneren <218366267+zhudaguaneren@users.noreply.github.com> --- agent/utils/toolbox/fail2ban.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/agent/utils/toolbox/fail2ban.go b/agent/utils/toolbox/fail2ban.go index 93ae33344..8c4a65dcc 100644 --- a/agent/utils/toolbox/fail2ban.go +++ b/agent/utils/toolbox/fail2ban.go @@ -42,10 +42,21 @@ func (f *Fail2ban) Status() (bool, bool, bool) { isEnable, _ := controller.CheckEnable("fail2ban.service") isActive, _ := controller.CheckActive("fail2ban.service") isExist, _ := controller.CheckExist("fail2ban.service") + if !isActive && isFail2banAlive() { + isActive = true + } return isEnable, isActive, isExist } +func isFail2banAlive() bool { + stdout, err := cmd.NewCommandMgr(cmd.WithTimeout(5*time.Second)).RunWithStdout("fail2ban-client", "ping") + if err != nil { + return false + } + return strings.Contains(strings.ToLower(stdout), "pong") +} + func (f *Fail2ban) Version() string { stdout, err := cmd.NewCommandMgr(cmd.WithTimeout(20*time.Second)).RunWithStdout("fail2ban-client", "version") if err != nil {