Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch scan a set of ports #3

Open
baalexander opened this issue Nov 30, 2011 · 2 comments
Open

Batch scan a set of ports #3

baalexander opened this issue Nov 30, 2011 · 2 comments

Comments

@baalexander
Copy link
Owner

Originally, portscanner would scan as many ports as it could and the first to return with a status was returned. Unfortunately, this can throw an error on systems when scanning more than 50 ports or so at a time (see Issue #2). The fix for Issue #2 waits for the status of a port before scanning the next one.

But c'mon, waiting is node is a waste. I propose scanning a batch of 50 ports asynchronously, then if none of those return a matching port status, try the next batch of 50.

@yoshuawuyts
Copy link

You could consider using [supertest](github. om/visionmedia/supertest) to test http asynchronously. Give it a try, maybe you'll like it.

@laggingreflex
Copy link
Collaborator

bluebird promise library has a concurrency feature out of the box which is perfect for this scenario. I almost implemented it and it seemed to work great, showing a massive improvement when scanning all 65k ports, but I ran into an issue - processing in batch doesn't guarantee the first port found will be the first one that was provided in the range or list. For eg. findPortNotInUse(3000, 65000) is normally expected to return 3000 with the old code, but with this concurrent batching it returns anything like 3049 as the first result (asynchronously speaking).

There could be a couple of solutions, like just accepting whatever port it finds first (like 3049 instead of 3000). Or waiting for it to go through the entire range or list and then pick the first one from the resultant list.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants