2.2.0 • Published 4 months ago

is-local-address v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

is-local-address

Check if an URL hostname is a local address, including support for Bogon IP address ranges.

Most solutions typically determine local IP addresses by checking DNS.

However, this implementation uses the Bogon IP address specification, delivering performance five times faster than alternative approaches.

Check benchmark for detailed performance metrics.

Install

$ npm install is-local-address --save

Usage

The method exported by default supports detection of both IPv4 and IPv6 addresses:

const isLocalAddress = require('is-local-address')

isLocalAddress(new URL('https://127.0.0.1').hostname) // true
isLocalAddress(new URL('http://[::]:3000').hostname) // true

You can also specify to just resolve IPv4:

const isLocalAddress = require('is-local-address/ipv4')
isLocalAddress(new URL('https://127.0.0.1').hostname) // true

or just IPv6:

const isLocalAddress = require('is-local-address/ipv6')
isLocalAddress(new URL('http://[::]:3000').hostname) // true

License

is-local-address © Kiko Beats, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · X @Kikobeats

2.2.0

4 months ago

2.1.3

4 months ago

2.1.2

4 months ago

2.1.1

4 months ago

2.1.0

4 months ago

2.0.0

4 months ago