mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: Fail2ban 配置文件区分系统 (#3202)
This commit is contained in:
parent
a74ed6a317
commit
8a24342b85
@ -134,7 +134,7 @@ func initLocalFile() error {
|
|||||||
bantime = 600
|
bantime = 600
|
||||||
findtime = 300
|
findtime = 300
|
||||||
maxretry = 5
|
maxretry = 5
|
||||||
banaction = firewallcmd-ipset
|
banaction = $banaction
|
||||||
action = %(action_mwl)s
|
action = %(action_mwl)s
|
||||||
#DEFAULT-END
|
#DEFAULT-END
|
||||||
|
|
||||||
@ -148,6 +148,16 @@ findtime = 300
|
|||||||
bantime = 600
|
bantime = 600
|
||||||
action = %(action_mwl)s
|
action = %(action_mwl)s
|
||||||
logpath = /var/log/secure`
|
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 {
|
if err := os.WriteFile(defaultPath, []byte(initFile), 0640); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user