fix(scan): bound the subnet and stop waiting on devices one at a time - #4
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two problems with the same root:
discovertreated the network as a list to walk rather than a set of waits to overlap.A scan cost the sum of every timeout on the network.
nudgehas used a 128-worker pool since the beginning, but the step after it - reverse DNS and the port scan, per device, both pure waiting - ran one device at a time, and the ports inside each ran one at a time too. The audit's banner grab was worse: a 2s timeout per open port, sequentially, and a TLS port never greets so it always costs the full 2s. Per-device work now goes through a pool, andgrab_bannersgathers the whole set at once. Wall clock is the slowest single device instead of the total.Nothing bounded the subnet.
netdiff scan 10.0.0.0/8materialised 16.7M address strings and handed them all to the nudge pool before a packet moved. ARP does not cross routers, so a subnet that large is a typo rather than a request - refused up front with the reason.While in there: a bad CIDR reached the user as a traceback, since the subnet is parsed deep inside
discoverrather than at the argparse layer.mainnow turns aValueErrorinto a message and exit 2, which covers both cases.Tests are timed rather than only checked for their return value - a pool that quietly stops being used still returns the right answer.