Add API endpoint to retrieve a list of country center coordinates

This commit is contained in:
Patrick Pacher
2023-05-23 09:41:34 +02:00
committed by Daniel Hovie
parent c75804bc16
commit f001ed6d06

View File

@@ -3,6 +3,7 @@ package geoip
import (
"context"
"github.com/safing/portbase/api"
"github.com/safing/portbase/modules"
"github.com/safing/portmaster/updates"
)
@@ -14,6 +15,19 @@ func init() {
}
func prep() error {
if err := api.RegisterEndpoint(api.Endpoint{
Path: "intel/geoip/country-centers",
Read: api.PermitUser,
// Do not attach to module, as the data is always available anyway.
StructFunc: func(ar *api.Request) (i interface{}, err error) {
return countryCoordinates, nil
},
Name: "Get Geographic Country Centers",
Description: "Returns a map of country centers indexed by ISO-A2 country code",
}); err != nil {
return err
}
return module.RegisterEventHook(
updates.ModuleName,
updates.ResourceUpdateEvent,