🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

address_util

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

address_util

ip util package

latest
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

node

FAQs

Package last updated on 18 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts