Skip to content

Commit

Permalink
fix(publicip): IPv6 endpoint for ipinfo (#1853)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Sep 13, 2023
1 parent c0062fb commit 3449e7a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/publicip/ipinfo/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ var (
// of the machine is used as the IP.
func (f *Fetch) FetchInfo(ctx context.Context, ip netip.Addr) (
result Response, err error) {
const baseURL = "https://ipinfo.io/"
url := baseURL
if ip.IsValid() {
url += ip.String()
url := "https://ipinfo.io/"
switch {
case ip.Is6():
url = "https://v6.ipinfo.io/" + ip.String()
case ip.Is4():
url = "https://ipinfo.io/" + ip.String()
}

request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
Expand Down

0 comments on commit 3449e7a

Please sign in to comment.