Skip to content

Commit

Permalink
Add API endpoint to retrieve a list of country center coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
ppacher authored and dhaavi committed May 24, 2023
1 parent c75804b commit f001ed6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions intel/geoip/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package geoip
import (
"context"

"github.com/safing/portbase/api"
"github.com/safing/portbase/modules"
"github.com/safing/portmaster/updates"
)
Expand All @@ -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,
Expand Down

0 comments on commit f001ed6

Please sign in to comment.