mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-19 06:53:14 +02:00
Add sections to integrations
This commit is contained in:
@@ -20,6 +20,10 @@ func init() {
|
||||
Register(&opnsenseIntegration{})
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Interface Implementation
|
||||
// =========================================================================
|
||||
|
||||
func (o *opnsenseIntegration) ID() string {
|
||||
return "opnsense"
|
||||
}
|
||||
@@ -41,6 +45,10 @@ func (o *opnsenseIntegration) Validate(cfg config.AdvancedActionsConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Block/Unblock
|
||||
// =========================================================================
|
||||
|
||||
func (o *opnsenseIntegration) BlockIP(req Request) error {
|
||||
if err := o.Validate(req.Config); err != nil {
|
||||
return err
|
||||
@@ -55,6 +63,10 @@ func (o *opnsenseIntegration) UnblockIP(req Request) error {
|
||||
return o.callAPI(req, "delete", req.IP)
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// OPNsense API
|
||||
// =========================================================================
|
||||
|
||||
func (o *opnsenseIntegration) callAPI(req Request, action, ip string) error {
|
||||
cfg := req.Config.OPNsense
|
||||
apiURL := strings.TrimSuffix(cfg.BaseURL, "/") + fmt.Sprintf("/api/firewall/alias_util/%s/%s", action, cfg.Alias)
|
||||
|
||||
Reference in New Issue
Block a user