fix: 并发dns查询,由于ipv6阻塞导致某些情况下的网络不通

This commit is contained in:
Skyxim 2022-05-21 00:34:00 +08:00
parent 3ab82849d4
commit 948700eed6

View File

@ -82,12 +82,16 @@ func (r *Resolver) ResolveAllIP(host string) (ips []netip.Addr, err error) {
ips, err = r.resolveIP(host, D.TypeA) ips, err = r.resolveIP(host, D.TypeA)
ipv6s, open := <-ch select {
if !open && err != nil { case ipv6s, open := <-ch:
return nil, resolver.ErrIPNotFound 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 return ips, nil
} }