From a3c39b183ed446359ee627528b10f2a80eade152 Mon Sep 17 00:00:00 2001 From: Vladimir Stoilov Date: Mon, 1 Aug 2022 08:02:45 +0200 Subject: [PATCH] Api ednpoint to custom filter list added --- intel/customlists/module.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/intel/customlists/module.go b/intel/customlists/module.go index f4e319b1..f0cdc721 100644 --- a/intel/customlists/module.go +++ b/intel/customlists/module.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "github.com/safing/portbase/api" "github.com/safing/portbase/modules" "golang.org/x/net/publicsuffix" ) @@ -70,6 +71,24 @@ func start() error { return nil }).Schedule(time.Now().Add(20 * time.Second)) + // register api endpoint for updating the filter list + if err := api.RegisterEndpoint(api.Endpoint{ + Path: "customlists/update", + Read: api.PermitUser, + BelongsTo: module, + ActionFunc: func(ar *api.Request) (msg string, err error) { + err = checkAndUpdateFilterList() + if err != nil { + return "failed to load custom filter list.", err + } + return "custom filter list loaded successfully.", nil + }, + Name: "Update custom filter list", + Description: "Load a filter list form a file defined by the user.", + }); err != nil { + return err + } + return nil }