Created
January 22, 2014 17:44
-
-
Save yannickcr/8563509 to your computer and use it in GitHub Desktop.
Outgoing port tester. Test outbound TCP port using portquiz.net. Useful to see which port is blocked by your network.
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
var | |
exec = require('child_process').exec, | |
current = 0, | |
max = 100 | |
; | |
function scan (i) { | |
if (current < max) { | |
current++; | |
exec('curl portquiz.net:' + i, callback.bind(this, i)); | |
} else { | |
setTimeout(scan.bind(this, i), 10); | |
} | |
} | |
function callback (port, err, stdout, stderr) { | |
current--; | |
if (stdout) { | |
console.log(port + ' is open'); | |
} | |
} | |
for (var i = 1, j = 65537; i < j; i++) { | |
scan(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires CURL