npm.io
0.1.0 • Published 4 years agoCLI

whichip

Licence
ISC
Version
0.1.0
Deps
2
Size
7 kB
Vulns
0
Weekly
0

NodeJS Client

Install

npm install -g whichip

Usage

In Terminal
$ whichip discover --timeout 0.2 --all --debug
#10.86.8.222
# or
#not found
In Code
npm install whichip

Then,

const { discover } = require('whichip')

opts = {
  debug: false,  // print debug message
  port: 53535,   // remote server port
  all: true,    // true => wait until timeout; false => return on first ip
  timeout: 0.2,  // discover timeout, seconds
}
discover(opts)
  .then((ips) => {console.log(ips)})
  .catch(console.error)
// [ '10.86.8.222' ]
// -- or --
// not found