fix(publicip): IPv6 endpoint for ipinfo (#1853)

This commit is contained in:
Aleksa Siriški
2023-09-13 16:37:39 +02:00
committed by GitHub
parent c0062fb807
commit 3449e7a0e1

View File

@@ -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)