mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-11 13:47:05 +02:00
In test filters also priorize .local filters over .conf filters and return always also the explicit used filter path in results
This commit is contained in:
@@ -278,18 +278,25 @@ func (ac *AgentConnector) GetFilters(ctx context.Context) ([]string, error) {
|
||||
}
|
||||
|
||||
// TestFilter implements Connector.
|
||||
func (ac *AgentConnector) TestFilter(ctx context.Context, filterName string, logLines []string) (string, error) {
|
||||
func (ac *AgentConnector) TestFilter(ctx context.Context, filterName string, logLines []string) (string, string, error) {
|
||||
payload := map[string]any{
|
||||
"filterName": filterName,
|
||||
"logLines": logLines,
|
||||
}
|
||||
var resp struct {
|
||||
Output string `json:"output"`
|
||||
Output string `json:"output"`
|
||||
FilterPath string `json:"filterPath"`
|
||||
}
|
||||
if err := ac.post(ctx, "/v1/filters/test", payload, &resp); err != nil {
|
||||
return "", err
|
||||
return "", "", err
|
||||
}
|
||||
return resp.Output, nil
|
||||
// If agent doesn't return filterPath, construct it (agent should handle .local priority)
|
||||
filterPath := resp.FilterPath
|
||||
if filterPath == "" {
|
||||
// Default to .conf path (agent should handle .local priority on its side)
|
||||
filterPath = fmt.Sprintf("/etc/fail2ban/filter.d/%s.conf", filterName)
|
||||
}
|
||||
return resp.Output, filterPath, nil
|
||||
}
|
||||
|
||||
// GetJailConfig implements Connector.
|
||||
|
||||
Reference in New Issue
Block a user