Skip to content

v1.3.1

Choose a tag to compare

@gsjonio gsjonio released this 10 Jul 13:36

Internal quality pass driven by a full architecture and code review. No new commands, no flag changes, and no behavior changes visible to users — hence a patch bump over v1.3.0.

Install

go install github.com/gsjonio/netwp/cmd/netwp@v1.3.1

Performance

  • Bounded enrichment fan-out. Discovery spawned one goroutine per live device, and each device opened ~12 concurrent sockets (a TCP probe per well-known port, an ICMP ping, and mDNS/NetBIOS lookups). On a busy LAN that unbounded fan-out could approach the process file-descriptor limit. A 32-slot semaphore now caps devices in flight, keeping total concurrent sockets in the low hundreds.
  • Reverse-DNS timeout halved (2s → 1s). Reverse DNS runs before the 400ms mDNS/NetBIOS fallback, so its old 2s cap meant a device ultimately resolvable by mDNS still waited up to 2s for DNS to fail first. Legit PTR answers and NXDOMAIN both return in milliseconds; only a resolver refusing RFC1918 reverse zones hit the cap, and it now hands off to the fallback faster.

Internal quality

  • Dependency inversion in namelookup. It hardcoded netinfo.DNSResolver{} as its primary lookup — an adapter-to-adapter dependency that also forced every test of the fallback path to hit real DNS. The primary is now injected through the core.HostResolver port and wired by the composition root.
  • Less boilerplate in cmd/netwp. scan, monitor and dashboard each repeated the same network-resolution + alias-store setup; a single discoveryContext() helper now owns it.
  • --json parsed once. The dispatch special-cased the flag and then runScan walked os.Args again to find the same flag. One helper owns flag detection now.

Testing

  • tcpprobe coverage 0% → 90%. It was pure stdlib net but untestable, because it scanned a fixed package-level list of privileged ports no test can bind to. The port list is now injectable, so a test points it at a live loopback listener and a closed port.
  • New test asserting the discovery fan-out actually stays within its concurrency cap.

Verified

CI green on Windows and Ubuntu (build, vet, test, golangci-lint). scan, scan --json, bare --json, iface, and ports exercised against a real home network.