mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-19 15:03:14 +02:00
Optimize error-reporting of failure when reloading fail2ban
This commit is contained in:
@@ -1458,12 +1458,10 @@ func SetJailFilterConfigHandler(c *gin.Context) {
|
||||
// Reload fail2ban
|
||||
config.DebugLog("Reloading fail2ban")
|
||||
if err := conn.Reload(c.Request.Context()); err != nil {
|
||||
config.DebugLog("Failed to reload fail2ban: %v", err)
|
||||
// Still return success but warn about reload failure
|
||||
// The config was saved successfully, user can manually reload
|
||||
log.Printf("⚠️ Config saved but fail2ban reload failed: %v", err)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "Config saved successfully, but fail2ban reload failed",
|
||||
"warning": "Please check the fail2ban configuration and reload manually: " + err.Error(),
|
||||
"warning": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -1908,13 +1906,9 @@ func UpdateJailManagementHandler(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update errMsg with detailed error output when debug mode is enabled
|
||||
settings := config.GetSettings()
|
||||
if settings.Debug && detailedErrorOutput != "" {
|
||||
errMsg = fmt.Sprintf("%s\n\nDetailed error output:\n%s", errMsg, detailedErrorOutput)
|
||||
} else if detailedErrorOutput != "" {
|
||||
// Even without debug mode, include basic error info
|
||||
errMsg = fmt.Sprintf("%s (check debug mode for details)", errMsg)
|
||||
if detailedErrorOutput != "" {
|
||||
// We use only the extracted error output
|
||||
errMsg = strings.TrimSpace(detailedErrorOutput)
|
||||
}
|
||||
|
||||
// If any jails were enabled in this request and reload failed, disable them all
|
||||
|
||||
Reference in New Issue
Block a user