Skip to content

Instantly share code, notes, and snippets.

@yannickcr
Created January 22, 2014 17:44
Show Gist options
  • Save yannickcr/8563509 to your computer and use it in GitHub Desktop.
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.
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);
}
@JamesCullum
Copy link

Requires CURL

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