Api ednpoint to custom filter list added

This commit is contained in:
Vladimir Stoilov 2022-08-01 08:02:45 +02:00 committed by Daniel
parent fa1480d4c1
commit a3c39b183e

View file

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