fix: 并发dns查询,由于ipv6阻塞导致某些情况下的网络不通
This commit is contained in:
parent
ba7e0887bd
commit
98ca305a54
1 changed files with 8 additions and 4 deletions
|
@ -82,12 +82,16 @@ func (r *Resolver) ResolveAllIP(host string) (ips []netip.Addr, err error) {
|
|||
|
||||
ips, err = r.resolveIP(host, D.TypeA)
|
||||
|
||||
ipv6s, open := <-ch
|
||||
if !open && err != nil {
|
||||
return nil, resolver.ErrIPNotFound
|
||||
select {
|
||||
case ipv6s, open := <-ch:
|
||||
if !open && err != nil {
|
||||
return nil, resolver.ErrIPNotFound
|
||||
}
|
||||
ips = append(ips, ipv6s...)
|
||||
case <-time.After(3 * time.Millisecond):
|
||||
// wait ipv6 3ms
|
||||
}
|
||||
|
||||
ips = append(ips, ipv6s...)
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue