fix: handle ping output with hostname when DNS resolves scan target

When the Docker container's DNS can resolve a target IP to a hostname,
ping formats the reply line as "from hostname (ip):" instead of the
plain "from ip:" format. The proxy-ARP source-IP guard only checked
for the plain format, causing those hosts to be incorrectly reported
as unreachable despite a valid ICMP response.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 14:40:19 +02:00
parent 4c61ae9456
commit 4b0aa1edf2
+2 -1
View File
@@ -71,7 +71,8 @@ def _ping(ip: str) -> bool:
# Guard against proxy-ARP / gateway false positives: verify the ICMP # Guard against proxy-ARP / gateway false positives: verify the ICMP
# reply actually came from the target IP and not an intermediate node. # reply actually came from the target IP and not an intermediate node.
stdout = r.stdout.decode(errors="ignore") stdout = r.stdout.decode(errors="ignore")
return f"from {ip}:" in stdout or f"from {ip} " in stdout # Also handles "from hostname (ip):" format when DNS resolves the target
return f"from {ip}:" in stdout or f"from {ip} " in stdout or f"({ip}):" in stdout
except Exception: except Exception:
return False return False