updated ipbl api endpoints

This commit is contained in:
Paul 2022-04-10 12:43:28 +02:00
parent 9803adfbb9
commit 60943adc66
3 changed files with 13 additions and 1 deletions

View File

@ -64,6 +64,14 @@ func GetSets(cfg config.Config) (res []CfgSet, err error) {
return
}
func GetGlobalConfig(cfg config.Config) (res []Cfg, err error) {
var w = []Cfg{}
if err := cfg.Db.Find(&w); err == nil {
return w, err
}
return
}
func InsertOrUpdateSets(cfg config.Config, folders []CfgSet) (res string, err error) {
var w = Cfg{Key: "folders"}
if exists, _ := cfg.Db.Get(&w); exists {

View File

@ -73,6 +73,10 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) {
log.Println(msg)
return Result(c, err, msg)
})
e.GET("/config", func(c echo.Context) (err error) {
trustlists, err := models.GetGlobalConfig(*cfg)
return Result(c, err, trustlists)
})
e.GET("/config/trustlist", func(c echo.Context) (err error) {
trustlists, err := models.GetTrustlists(*cfg)
return Result(c, err, trustlists)

View File

@ -48,7 +48,7 @@ func Handle(cfg *config.Config, reqsock *goczmq.Sock, pubsock *goczmq.Sock, chan
if err != nil {
log.Println(err)
}
log.Println(fmt.Sprintf("zmq: Inserted %d IP, Updated %d IP", numinsert, numupdate))
log.Printf("zmq: Inserted %d IP, Updated %d IP\n", numinsert, numupdate)
tmpval := fmt.Sprintf("%s %s", channel, string(val))
val = []byte(tmpval)
topub = append(topub, val)