mirror of
https://github.com/soypat/lneto.git
synced 2026-08-13 19:33:42 +00:00
add dns empty response error
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user