fix: Fail2ban 配置文件区分系统 (#3202)

pull/3203/head
ssongliu 12 months ago committed by GitHub
parent a74ed6a317
commit 8a24342b85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -134,7 +134,7 @@ func initLocalFile() error {
bantime = 600
findtime = 300
maxretry = 5
banaction = firewallcmd-ipset
banaction = $banaction
action = %(action_mwl)s
#DEFAULT-END
@ -148,6 +148,16 @@ findtime = 300
bantime = 600
action = %(action_mwl)s
logpath = /var/log/secure`
banaction := ""
if active, _ := systemctl.IsActive("firewalld"); active {
banaction = "firewallcmd-ipset"
} else if active, _ := systemctl.IsActive("ufw"); active {
banaction = "ufw"
} else {
banaction = "iptables-allports"
}
initFile = strings.ReplaceAll(initFile, "$banaction", banaction)
if err := os.WriteFile(defaultPath, []byte(initFile), 0640); err != nil {
return err
}

Loading…
Cancel
Save