mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-11 13:47:05 +02:00
Add missing banaction_allports setting to update settings function
This commit is contained in:
@@ -756,13 +756,16 @@ func ensureJailLocalStructure() error {
|
||||
existingContent = string(content)
|
||||
}
|
||||
|
||||
// Check if file already has our banner (indicating it's already structured)
|
||||
hasBanner := strings.Contains(existingContent, "Fail2Ban-UI") || strings.Contains(existingContent, "fail2ban-ui")
|
||||
// Check if file already has our full banner (indicating it's already properly structured)
|
||||
// Check for the complete banner pattern with hash line separators
|
||||
hasFullBanner := strings.Contains(existingContent, "################################################################################") &&
|
||||
strings.Contains(existingContent, "Fail2Ban-UI Managed Configuration") &&
|
||||
strings.Contains(existingContent, "DO NOT EDIT THIS FILE MANUALLY")
|
||||
hasActionMwlg := strings.Contains(existingContent, "action_mwlg") && strings.Contains(existingContent, "ui-custom-action")
|
||||
hasActionOverride := strings.Contains(existingContent, "action = %(action_mwlg)s")
|
||||
|
||||
// If file is already properly structured, just ensure DEFAULT section is up to date
|
||||
if hasBanner && hasActionMwlg && hasActionOverride {
|
||||
if hasFullBanner && hasActionMwlg && hasActionOverride {
|
||||
DebugLog("jail.local already has proper structure, updating DEFAULT section if needed")
|
||||
// Update DEFAULT section values without changing structure
|
||||
return updateJailLocalDefaultSection(settings)
|
||||
@@ -848,14 +851,30 @@ func updateJailLocalDefaultSection(settings AppSettings) error {
|
||||
inDefault := false
|
||||
defaultUpdated := false
|
||||
|
||||
// Convert IgnoreIPs array to space-separated string
|
||||
ignoreIPStr := strings.Join(settings.IgnoreIPs, " ")
|
||||
if ignoreIPStr == "" {
|
||||
ignoreIPStr = "127.0.0.1/8 ::1"
|
||||
}
|
||||
// Set default banaction values if not set
|
||||
banaction := settings.Banaction
|
||||
if banaction == "" {
|
||||
banaction = "iptables-multiport"
|
||||
}
|
||||
banactionAllports := settings.BanactionAllports
|
||||
if banactionAllports == "" {
|
||||
banactionAllports = "iptables-allports"
|
||||
}
|
||||
// Keys to update
|
||||
keysToUpdate := map[string]string{
|
||||
"bantime.increment": fmt.Sprintf("bantime.increment = %t", settings.BantimeIncrement),
|
||||
"ignoreip": fmt.Sprintf("ignoreip = %s", strings.Join(settings.IgnoreIPs, " ")),
|
||||
"bantime": fmt.Sprintf("bantime = %s", settings.Bantime),
|
||||
"findtime": fmt.Sprintf("findtime = %s", settings.Findtime),
|
||||
"maxretry": fmt.Sprintf("maxretry = %d", settings.Maxretry),
|
||||
"destemail": fmt.Sprintf("destemail = %s", settings.Destemail),
|
||||
"bantime.increment": fmt.Sprintf("bantime.increment = %t", settings.BantimeIncrement),
|
||||
"ignoreip": fmt.Sprintf("ignoreip = %s", ignoreIPStr),
|
||||
"bantime": fmt.Sprintf("bantime = %s", settings.Bantime),
|
||||
"findtime": fmt.Sprintf("findtime = %s", settings.Findtime),
|
||||
"maxretry": fmt.Sprintf("maxretry = %d", settings.Maxretry),
|
||||
"destemail": fmt.Sprintf("destemail = %s", settings.Destemail),
|
||||
"banaction": fmt.Sprintf("banaction = %s", banaction),
|
||||
"banaction_allports": fmt.Sprintf("banaction_allports = %s", banactionAllports),
|
||||
}
|
||||
keysUpdated := make(map[string]bool)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user