Add sections to integrations

This commit is contained in:
2026-02-17 00:05:46 +01:00
parent 0d551ede53
commit 1cd2439cea
4 changed files with 58 additions and 38 deletions

View File

@@ -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)