Last active
December 31, 2019 08:17
-
-
Save paulgalow/d33599630f139e600fd5a39a2dfec1bc to your computer and use it in GitHub Desktop.
Revisions
-
paulgalow revised this gist
Dec 31, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ const { createConnection } = require("net"); function checkTCP(host = "1.1.1.1", port = 53) { return new Promise((resolve, reject) => { const client = createConnection({ host, port }, () => { console.log(`TCP connection established on port ${port}`); -
paulgalow created this gist
Dec 31, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ const { createConnection } = require("net"); function checkTCP(host = "1.1.1.1", port = 443) { return new Promise((resolve, reject) => { const client = createConnection({ host, port }, () => { console.log(`TCP connection established on port ${port}`); client.end(); resolve(); }); client.setTimeout(3000); client.on("timeout", err => { console.error(`TCP connection on port ${port} timed out`); client.destroy(); reject(err); }); client.on("error", err => { console.error(`Error trying to connect via TCP on port ${port}`); reject(err); }); }); }