v1.3.1
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.1Performance
- 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 hardcodednetinfo.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 thecore.HostResolverport and wired by the composition root. - Less boilerplate in
cmd/netwp.scan,monitoranddashboardeach repeated the same network-resolution + alias-store setup; a singlediscoveryContext()helper now owns it. --jsonparsed once. The dispatch special-cased the flag and thenrunScanwalkedos.Argsagain to find the same flag. One helper owns flag detection now.
Testing
tcpprobecoverage 0% → 90%. It was pure stdlibnetbut 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.