diff --git a/lib/portscanner.js b/lib/portscanner.js index 1eb8345..4047230 100644 --- a/lib/portscanner.js +++ b/lib/portscanner.js @@ -115,13 +115,13 @@ function findAPortWithStatus(status, startPort, endPort, host, callback) { var checkNextPort = function(callback) { portscanner.checkPortStatus(port, host, function(error, statusOfPort) { numberOfPortsChecked++ - if (error) { - callback(error) - } - else if (statusOfPort === status) { + if (statusOfPort === status) { foundPort = true callback(null, port) } + else if (error) { + callback(error) + } else { port++ callback(null, false)