Giter VIP home page Giter VIP logo

node-portscanner's Introduction

portscanner

npm JavaScript Style Guide

The portscanner module is an asynchronous JavaScript port scanner for Node.js.

Portscanner can check a port, or range of ports, for 'open' or 'closed' statuses.

Looking for maintainer!

Install

npm install portscanner

Usage

A brief example:

var portscanner = require('portscanner')

// Checks the status of a single port
portscanner.checkPortStatus(3000, '127.0.0.1', function(error, status) {
  // Status is 'open' if currently in use or 'closed' if available
  console.log(status)
})

// Find the first available port. Asynchronously checks, so first port
// determined as available is returned.
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', function(error, port) {
  console.log('AVAILABLE PORT AT: ' + port)
})

// Find the first port in use or blocked. Asynchronously checks, so first port
// to respond is returned.
portscanner.findAPortInUse(3000, 3010, '127.0.0.1', function(error, port) {
  console.log('PORT IN USE AT: ' + port)
})

// You can also pass array of ports to check
portscanner.findAPortInUse([3000, 3005, 3006], '127.0.0.1', function(error, port) {
  console.log('PORT IN USE AT: ' + port)
})

// And skip host param. Default is '127.0.0.1'
portscanner.findAPortNotInUse(3000, 4000, function(error, port) {
  console.log('PORT IN USE AT: ' + port)
})

// And use promises
portscanner.findAPortNotInUse(3000, 4000).then(function(port) {
  console.log('PORT IN USE AT: ' + port)
})

The example directory contains a more detailed example.

Test

npm test

Future

Please create issues or pull requests for port scanning related features you'd like to see included.

License (MIT)

MIT

node-portscanner's People

Contributors

baalexander avatar darthneko avatar denniskehrig avatar elmccd avatar endangeredmassa avatar jdwilliams15 avatar laggingreflex avatar lughino avatar pdehaan avatar shinnn avatar skilesare avatar thomseddon avatar yogu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.