From c9cd856c8c70c66ae82724df2be0daf944f48fff Mon Sep 17 00:00:00 2001 From: Lz Date: Sun, 11 Jan 2026 21:42:19 +0800 Subject: [PATCH] fix: distinguish NXDOMAIN from network errors in RDNS lookup - Use *net.DNSError.IsNotFound to detect NXDOMAIN (no PTR record) - NXDOMAIN now returns StatusFailed instead of StatusPending - Network errors (timeout, connection issues) still return StatusPending for retry --- bot.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index 81d6a34..0e1f708 100644 --- a/bot.go +++ b/bot.go @@ -216,7 +216,13 @@ func (b *Bot) VerifyRDNS(ipStr string) ResultStatus { // Perform RDNS lookup names, err := net.LookupAddr(ipStr) if err != nil { - // Network error - allow retry, do not add to fail cache + // Distinguish network errors from NXDOMAIN (no PTR record) + if dnsErr, ok := err.(*net.DNSError); ok && dnsErr.IsNotFound { + // NXDOMAIN: PTR record does not exist - verification failed + b.fail.Add(ipStr) + return StatusFailed + } + // Network error (timeout, connection issue, etc.) - allow retry return StatusPending } if len(names) == 0 {