| 1 | [](https://dl.circleci.com/status-badge/redirect/circleci/9fJmTZfn8d8p7GtVt688PY/JjriGjhcxBD6zYKygMZaet/tree/master)
|
|---|
| 2 | [![codecov]](https://codecov.io/github/beaugunderson/ip-address?branch=master)
|
|---|
| 3 | [![downloads]](https://www.npmjs.com/package/ip-address)
|
|---|
| 4 | [![npm]](https://www.npmjs.com/package/ip-address)
|
|---|
| 5 | [![snyk]](https://snyk.io/test/github/beaugunderson/ip-address)
|
|---|
| 6 |
|
|---|
| 7 | [codecov]: https://codecov.io/github/beaugunderson/ip-address/coverage.svg?branch=master
|
|---|
| 8 | [downloads]: https://img.shields.io/npm/dm/ip-address.svg
|
|---|
| 9 | [npm]: https://img.shields.io/npm/v/ip-address.svg
|
|---|
| 10 | [snyk]: https://snyk.io/test/github/beaugunderson/ip-address/badge.svg
|
|---|
| 11 |
|
|---|
| 12 | ## ip-address
|
|---|
| 13 |
|
|---|
| 14 | `ip-address` is a library for validating and manipulating IPv4 and IPv6
|
|---|
| 15 | addresses in JavaScript.
|
|---|
| 16 |
|
|---|
| 17 | ### Upgrading from 9.x to 10.x
|
|---|
| 18 |
|
|---|
| 19 | The dependency on `jsbn` was removed thanks to
|
|---|
| 20 | [michal-kocarek](https://github.com/michal-kocarek). Thanks Michal! For
|
|---|
| 21 | clarity, all methods with BigInteger in the name were renamed to BigInt.
|
|---|
| 22 |
|
|---|
| 23 | #### Breaking changes
|
|---|
| 24 |
|
|---|
| 25 | - `#fromBigInteger()` → `#fromBigInt()`; now returns a native BigInt
|
|---|
| 26 | - `#bigInteger()` → `#bigInt()`; now returns a native BigInt
|
|---|
| 27 |
|
|---|
| 28 | ### Documentation
|
|---|
| 29 |
|
|---|
| 30 | Documentation is available at [ip-address.js.org](http://ip-address.js.org/).
|
|---|
| 31 |
|
|---|
| 32 | ### Examples
|
|---|
| 33 |
|
|---|
| 34 | ```js
|
|---|
| 35 | var Address6 = require('ip-address').Address6;
|
|---|
| 36 |
|
|---|
| 37 | var address = new Address6('2001:0:ce49:7601:e866:efff:62c3:fffe');
|
|---|
| 38 |
|
|---|
| 39 | var teredo = address.inspectTeredo();
|
|---|
| 40 |
|
|---|
| 41 | teredo.client4; // '157.60.0.1'
|
|---|
| 42 | ```
|
|---|
| 43 |
|
|---|
| 44 | ### Features
|
|---|
| 45 |
|
|---|
| 46 | - Usable via CommonJS or ESM
|
|---|
| 47 | - Parsing of all IPv6 notations
|
|---|
| 48 | - Parsing of IPv6 addresses and ports from URLs with `Address6.fromURL(url)`
|
|---|
| 49 | - Validity checking
|
|---|
| 50 | - Decoding of the [Teredo
|
|---|
| 51 | information](http://en.wikipedia.org/wiki/Teredo_tunneling#IPv6_addressing)
|
|---|
| 52 | in an address
|
|---|
| 53 | - Whether one address is a valid subnet of another
|
|---|
| 54 | - What special properties a given address has (multicast prefix, unique
|
|---|
| 55 | local address prefix, etc.)
|
|---|
| 56 | - Number of subnets of a certain size in a given address
|
|---|
| 57 | - Display methods
|
|---|
| 58 | - Hex, binary, and decimal
|
|---|
| 59 | - Canonical form
|
|---|
| 60 | - Correct form
|
|---|
| 61 | - IPv4-compatible (i.e. `::ffff:192.168.0.1`)
|
|---|
| 62 | - Works in [node](http://nodejs.org/) and the browser (with browserify)
|
|---|
| 63 | - ~1,600 test cases
|
|---|
| 64 |
|
|---|
| 65 | ### Used by
|
|---|
| 66 |
|
|---|
| 67 | - [anon](https://github.com/edsu/anon) which powers
|
|---|
| 68 | [@congressedits](https://twitter.com/congressedits), among
|
|---|
| 69 | [many others](https://github.com/edsu/anon#community)
|
|---|
| 70 | - [base85](https://github.com/noseglid/base85): base85 encoding/decoding
|
|---|
| 71 | - [contrail-web-core](https://github.com/Juniper/contrail-web-core): part of
|
|---|
| 72 | Contrail, a network virtualization solution made by Juniper Networks
|
|---|
| 73 | - [dhcpjs](https://github.com/apaprocki/node-dhcpjs): a DHCP client and server
|
|---|
| 74 | - [epochtalk](https://github.com/epochtalk/epochtalk): next generation forum
|
|---|
| 75 | software
|
|---|
| 76 | - [geoip-web](https://github.com/tfrce/node-geoip-web): a server for
|
|---|
| 77 | quickly geolocating IP addresses
|
|---|
| 78 | - [hexabus](https://github.com/mysmartgrid/hexabus): an IPv6-based home
|
|---|
| 79 | automation bus
|
|---|
| 80 | - [hubot-deploy](https://github.com/atmos/hubot-deploy): GitHub Flow via hubot
|
|---|
| 81 | - [heroku-portscanner](https://github.com/robison/heroku-portscanner): nmap
|
|---|
| 82 | hosted on Heroku
|
|---|
| 83 | - [ipfs-swarm](https://github.com/diasdavid/node-ipfs-swarm): a swarm
|
|---|
| 84 | implementation based on IPFS
|
|---|
| 85 | - [javascript-x-server](https://github.com/GothAck/javascript-x-server): an X
|
|---|
| 86 | server written in JavaScript
|
|---|
| 87 | - [libnmap](https://github.com/jas-/node-libnmap): a node API for nmap
|
|---|
| 88 | - [mail-io](https://github.com/mofux/mail-io): a lightweight SMTP server
|
|---|
| 89 | - [maxmind-db-reader](https://github.com/PaddeK/node-maxmind-db): a library for
|
|---|
| 90 | reading MaxMind database files
|
|---|
| 91 | - [proxy-protocol-v2](https://github.com/ably/proxy-protocol-v2): a proxy
|
|---|
| 92 | protocol encoder/decoder built by [Ably](https://www.ably.io/)
|
|---|
| 93 | - [Samsara](https://github.com/mariusGundersen/Samsara): a Docker web interface
|
|---|
| 94 | - [sis-api](https://github.com/sis-cmdb/sis-api): a configuration management
|
|---|
| 95 | database API
|
|---|
| 96 | - [socks5-client](https://github.com/mattcg/socks5-client): a SOCKS v5 client
|
|---|
| 97 | - [socksified](https://github.com/vially/node-socksified): a SOCKS v5 client
|
|---|
| 98 | - [socksv5](https://github.com/mscdex/socksv5): a SOCKS v5 server/client
|
|---|
| 99 | - [ssdapi](https://github.com/rsolomou/ssdapi): an API created by the
|
|---|
| 100 | University of Portsmouth
|
|---|
| 101 | - [SwitchyOmega](https://github.com/FelisCatus/SwitchyOmega): a [Chrome
|
|---|
| 102 | extension](https://chrome.google.com/webstore/detail/padekgcemlokbadohgkifijomclgjgif)
|
|---|
| 103 | for switching between multiple proxies with ~311k users!
|
|---|
| 104 | - [swiz](https://github.com/racker/node-swiz): a serialization framework built
|
|---|
| 105 | and used by [Rackspace](http://www.rackspace.com/)
|
|---|