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.
|
// of the machine is used as the IP.
|
||||||
func (f *Fetch) FetchInfo(ctx context.Context, ip netip.Addr) (
|
func (f *Fetch) FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||||
result Response, err error) {
|
result Response, err error) {
|
||||||
const baseURL = "https://ipinfo.io/"
|
url := "https://ipinfo.io/"
|
||||||
url := baseURL
|
switch {
|
||||||
if ip.IsValid() {
|
case ip.Is6():
|
||||||
url += ip.String()
|
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)
|
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user