mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-11 13:47:05 +02:00
Fixed the 'Manually Block / Test' endpoint returning a 500 error. The handler didn't validate the integration configuration before attempting the test.
This commit is contained in:
@@ -252,7 +252,7 @@ Comprehensive settings management for alerts, advanced banning, and system prefe
|
||||
|
||||
Pull and run the official image from Docker Hub:
|
||||
```bash
|
||||
# Pull the image from Docker Hub (default)
|
||||
# Pull the image with podman from Docker Hub (default)
|
||||
podman pull swissmakers/fail2ban-ui:latest
|
||||
# or with Docker:
|
||||
docker pull swissmakers/fail2ban-ui:latest
|
||||
|
||||
@@ -19,7 +19,7 @@ A comprehensive guide for building and deploying Fail2Ban UI using containers (D
|
||||
|
||||
### Using Pre-built Image
|
||||
|
||||
**Pull the official image from Docker Hub (default):**
|
||||
**Pull the official image with podman from Docker Hub (default):**
|
||||
```bash
|
||||
podman pull swissmakers/fail2ban-ui:latest
|
||||
# or with Docker:
|
||||
|
||||
@@ -71,7 +71,7 @@ func (p *pfSenseIntegration) callAPI(req Request, action string, payload map[str
|
||||
return fmt.Errorf("failed to encode pfSense payload: %w", err)
|
||||
}
|
||||
|
||||
apiURL := strings.TrimSuffix(cfg.BaseURL, "/") + "/api/v1/firewall/alias/ip"
|
||||
apiURL := strings.TrimSuffix(cfg.BaseURL, "/") + "/api/v2/firewall/alias/ip"
|
||||
|
||||
httpClient := &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
|
||||
@@ -44,6 +44,7 @@ import (
|
||||
"github.com/oschwald/maxminddb-golang"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/config"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/fail2ban"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/integrations"
|
||||
"github.com/swissmakers/fail2ban-ui/internal/storage"
|
||||
)
|
||||
|
||||
@@ -1445,6 +1446,26 @@ func AdvancedActionsTestHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
settings := config.GetSettings()
|
||||
|
||||
// Check if integration is configured
|
||||
if settings.AdvancedActions.Integration == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "no integration configured. Please configure an integration (MikroTik or pfSense) in Advanced Actions settings first"})
|
||||
return
|
||||
}
|
||||
|
||||
// Verify integration exists
|
||||
integration, ok := integrations.Get(settings.AdvancedActions.Integration)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("integration %s not found or not registered", settings.AdvancedActions.Integration)})
|
||||
return
|
||||
}
|
||||
|
||||
// Validate integration configuration
|
||||
if err := integration.Validate(settings.AdvancedActions); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("integration configuration is invalid: %v", err)})
|
||||
return
|
||||
}
|
||||
|
||||
server := config.Fail2banServer{}
|
||||
if req.ServerID != "" {
|
||||
if srv, ok := config.GetServerByID(req.ServerID); ok {
|
||||
|
||||
Reference in New Issue
Block a user