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

Add port-sniffer by OperKH #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

OperKH
Copy link

@OperKH OperKH commented Nov 10, 2019

I've read ./README.md and ./CODE_QUALITY.md carefully.

The code is checked by npm run lint:js --fix` and linter reported no errors.

The code is submitted in its own sub-directory and in a dedicated feature branch.

Please, review.

Copy link
Member

@AMashoshyna AMashoshyna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of recursion. Please below my comments.

process.exit(0);
}

function getParamsFromArguments () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has too much responsibility. Although it is called "getParamsFromArguments", it actually not only gets the parameters, but also processes them. I suggest to split it into several functions.

This might not be a case for this small program, but usually argument parsing is reused and thus should not contain any specific logic.

});
socket.on('timeout', function () {
socket.destroy();
reject(new Error('timeout'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that in terms of this program timeout is not an error, but expected behavior for closed port. Your solution is ok, but to me it looks cleaner to resolve the Promise with boolean value (true for open ports and false for closed ports). This way you don't need to have empty catch block.

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

Successfully merging this pull request may close these issues.

2 participants