From 3449e7a0e17699fb7066c9de173b40cade50faec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Wed, 13 Sep 2023 16:37:39 +0200 Subject: [PATCH] fix(publicip): IPv6 endpoint for ipinfo (#1853) --- internal/publicip/ipinfo/fetch.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/publicip/ipinfo/fetch.go b/internal/publicip/ipinfo/fetch.go index 306c7125..4190a325 100644 --- a/internal/publicip/ipinfo/fetch.go +++ b/internal/publicip/ipinfo/fetch.go @@ -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)