项目作者: beaudurrant

项目描述 :
Lean JavaScript port scanner
高级语言: JavaScript
项目地址: git://github.com/beaudurrant/node-port-scanner.git
创建时间: 2020-10-17T16:17:07Z
项目社区:https://github.com/beaudurrant/node-port-scanner

开源协议:MIT License

下载


node-port-scanner

npm

node-port-scanner

Scans ports to see if they are open or closed.

After calling nodePortScanner, ports are checked in order one after the previous is completed.

Multiple calls can be made and will run in parallel.

Install

  1. npm i node-port-scanner

Usage

  1. npm run usage
  1. const nodePortScanner = require('node-port-scanner');
  2. // scan local common ports
  3. nodePortScanner('127.0.0.1', [21, 22, 23, 25, 80, 110, 123, 443])
  4. .then(results => {
  5. console.log(results);
  6. })
  7. .catch(error => {
  8. console.log(error);
  9. });
  10. // scan remote common ports
  11. nodePortScanner('github.com', [21, 22, 23, 25, 80, 110, 123, 443])
  12. .then(results => {
  13. console.log(results);
  14. })
  15. .catch(error => {
  16. console.log(error);
  17. });
  18. // scan all local ports - not recommended on remote hosts
  19. async function checkLocalPorts () {
  20. const allPorts = nodePortScanner('127.0.0.1', []);
  21. console.log(await allPorts);
  22. }
  23. checkLocalPorts();

Sample Response

  1. {
  2. host: 'github.com',
  3. ports: {
  4. open: [ 22, 80, 443 ],
  5. closed: [ 21, 23, 25, 110, 123 ]
  6. }
  7. }

Test (Jest)

  1. npm test

License (MIT)

MIT