Fix ipv6 stuffs 2

This commit is contained in:
Ben Sarmiento
2024-01-11 02:41:50 +01:00
parent b526da1b4f
commit 8378422b3a
2 changed files with 4 additions and 2 deletions

View File

@@ -127,14 +127,16 @@ func NewHTTPClient(token string, maxRetries int, timeoutSecs int, restrictToHost
}
}
if !found {
log.Warnf("Host %s is not an IPv6 host, replacing with a random host (ensure you have preferred_hosts properly set in your config.yml)", host)
log.Warnf("Host %s is not an IPv6 host (ensure you have preferred_hosts properly set in your config.yml, if unset, run `zurg network-test -t ipv6`)", host)
// replace with a random ipv6 host
restrictToHostsLen := len(restrictToHosts)
randomHost := restrictToHosts[rand.Intn(restrictToHostsLen)]
host = randomHost
log.Warnf("Replacing with a random IPv6 host: %s", host)
address = net.JoinHostPort(host, port)
}
}
// todo: replace .com with .cloud if needed
ips, err := net.DefaultResolver.LookupIPAddr(ctx, host)
if err != nil {
return nil, err