1.1.2 • Published 6 years ago

address_util v1.1.2

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

address_util npm npm npm

NodeJS Core Module Extended

Installation

npm install address_util --save

Usage

In your node program:

let addressUtil = require('address_util')

// get current machine local address
const currentIp = addressUtil.getCurrentIp()    // example: 192.168.1.2
// get new port to listen
addressUtil.findPortToListen(8080, port => {
    // if 8080 is not occupied , port > 8080
    // else other port which is not occupied
})
// have not default port, find from 8080
addressUtil.findPortToListen(port => {})

// promise
addressUtil.findPortToListen(8080).then(port => {})
addressUtil.findPortToListen().then(port => {})

// get client real request ip
const http = require('http')
const server = http.createServer((req, res) => {
    // real ip
    const realClientIp = addressUtil.getClientIp(req)

    res.end(realClientIp)
})

License

MIT. Copyright (c) SoberZ.

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago