fix: switch tcp_check mode to TCP-only instead of ICMP+TCP

Previously tcp_check required both ICMP and TCP to pass. This caused
two failure modes: hosts with ICMP rate-limiting under scan load were
missed (ICMP fails → TCP never tried), and the AND logic was confusing.

In TCP-only mode, proxy-ARP gateways are still filtered out because
they never spoof TCP replies. Hosts with rate-limited ICMP (e.g. some
WiFi APs during a full /24 sweep) are now correctly detected via TCP.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 15:12:04 +02:00
parent 4b0aa1edf2
commit 93ab343db7
2 changed files with 15 additions and 10 deletions
+9 -4
View File
@@ -115,10 +115,15 @@ def _tcp_check(ip: str) -> bool:
def _scan_one(ip: str, dns_server: str, vlan_id: int, cidr: str, tcp_check: bool = False) -> Optional[DiscoveredHost]:
if not _ping(ip):
return None
if tcp_check and not _tcp_check(ip):
return None
if tcp_check:
# TCP-only mode: bypasses ICMP entirely.
# Proxy-ARP gateways never spoof TCP replies, so ghost IPs are filtered
# without ICMP. Also catches hosts whose ICMP is rate-limited under load.
if not _tcp_check(ip):
return None
else:
if not _ping(ip):
return None
hostname = _ptr_lookup(ip, dns_server) if dns_server else None
return DiscoveredHost(ip=ip, hostname=hostname, vlan_id=vlan_id, cidr=cidr)