From 88d5f111da74515e567a3ede2aa1f4f1d59a6859 Mon Sep 17 00:00:00 2001 From: Patricio Whittingslow Date: Mon, 5 Jan 2026 11:42:01 -0300 Subject: [PATCH] add dns empty response error --- x/xnet/stack-async.go | 9 +++++++-- x/xnet/stack-retrying.go | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) 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)