Merge pull request #1222 from safing/feature/country-center-api

Add API endpoint to retrieve a list of country center coordinates
This commit is contained in:
Daniel Hovie
2023-05-24 10:47:18 +02:00
committed by GitHub

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,