Skip to content

Commit

Permalink
Adding support to point to an ipinfo cache (#18)
Browse files Browse the repository at this point in the history
Example postman to show things are hooked up correctly

https://xbj3ebrf2c.execute-api.us-east-2.amazonaws.com/ipinfo/8.8.8.8

{'ip': '8.8.8.8', 'hostname': 'dns.google', 'anycast': True, 'city':
'Mountain View', 'region': 'California', 'country': 'US', 'loc':
'37.4056,-122.0775', 'org': 'AS15169 Google LLC', 'postal': '94043',
'timezone': 'America/Los_Angeles', 'readme':
'https://ipinfo.io/missingauth'}
  • Loading branch information
stephen-pl committed Aug 18, 2023
1 parent f74a47a commit 1bf7e95
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/resolver/location_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"net"
"net/http"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -63,9 +64,12 @@ func (i *IPInfo) Resolve() {

func GetPublicIPInfo(ctx context.Context, ip string, token string) (IPInfo, error) {
logger := logging.Logger("location_resolver")
url := "https://ipinfo.io/json"
url, exists := os.LookupEnv("IPINFO_URL")
if !exists {
url = "https://ipinfo.io/"
}
if ip != "" {
url = "https://ipinfo.io/" + ip + "/json"
url = url + ip + "/json"
}

if token != "" {
Expand Down

0 comments on commit 1bf7e95

Please sign in to comment.