fix(publicip): IPv6 endpoint for ipinfo (#1853)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user