diff --git a/x/xnet/stack-async.go b/x/xnet/stack-async.go index c91d012..6b330ca 100644 --- a/x/xnet/stack-async.go +++ b/x/xnet/stack-async.go @@ -189,11 +189,13 @@ func (s *StackAsync) resetARP() error { // Prand32 generates a pseudo random 32-bit unsigned integer from the internal state and advances the seed. func (s *StackAsync) Prand32() uint32 { /* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */ + s.mu.Lock() seed := s.prng seed ^= seed << 13 seed ^= seed >> 17 seed ^= seed << 5 s.prng = seed + s.mu.Unlock() return seed } @@ -360,10 +362,13 @@ func (s *StackAsync) ResultLookupIP(host string) ([]netip.Addr, bool, error) { } else if len(data) == 16 { addrs = append(addrs, netip.AddrFrom16([16]byte(data))) } else { - return addrs, done, errors.New("bogus IP") + err = errors.New("bogus IP") } } - return addrs, done, nil + if err == nil && len(addrs) == 0 { + err = errors.New("no address in DNS answer") + } + return addrs, done, err } func (s *StackAsync) StartDHCPv4Request(request [4]byte) error { diff --git a/x/xnet/stack-retrying.go b/x/xnet/stack-retrying.go index e11764f..2e20e38 100644 --- a/x/xnet/stack-retrying.go +++ b/x/xnet/stack-retrying.go @@ -56,6 +56,9 @@ func (s StackRetrying) DoNTP(ntpHost netip.Addr, timeout time.Duration, retries return -1, errRetriesExceeded } func (s StackRetrying) DoLookupIP(host string, timeout time.Duration, retries int) (addrs []netip.Addr, err error) { + if !s.block.async.dnssv.IsValid() { + return nil, errNoDNSServer + } expectEnd := time.Now().Add(timeout * time.Duration(retries)) for i := 0; i < retries; i++ { addrs, err = s.block.DoLookupIP(host, timeout)