Skip to content

the-pesar/port-scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

port-scanner

Installation

npm install pscanner

example:

const portScan = require("pscanner");

const main = async () => {
  const isOpen = await portScan({ host: "8.8.8.8", port: 443 });
  console.log(isOpen); // true
};

main();

support CallBack function:

const portScan = require("pscanner");

portScan({
  host: "8.8.8.8",
  port: 100,
  callback: (isOpen, port) => {
    console.log(isOpen, port);
    // false 100
  },
});

set timeout connection (default 200ms):

const portScan = require("pscanner");

const main = async () => {
  const isOpen = await portScan({
    host: "8.8.8.8",
    port: 443,
    timeout: 100,
  });
  console.log(isOpen); // true
};

main();