{"_id":"@eggjs/ip","_rev":"4633146","name":"@eggjs/ip","description":"[![NPM version][npm-image]][npm-url] [![Node.js CI](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml) [![Test coverage][codecov-image]][codecov-url] [![Known Vulnerabil","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"akitasummer","email":""},{"name":"atian25","email":"atian25@qq.com"},{"name":"coolme200","email":""},{"name":"eggjs-admin","email":""},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"gxkl","email":""},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"niania","email":""}],"time":{"modified":"2026-04-10T19:01:58.000Z","created":"2024-06-12T08:13:18.075Z","2.1.0":"2025-01-13T12:57:54.522Z","2.0.2":"2024-06-12T08:13:18.075Z"},"users":{},"author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"repository":{"type":"git","url":"git://github.com/eggjs/node-ip.git"},"versions":{"2.1.0":{"name":"@eggjs/ip","version":"2.1.0","publishConfig":{"access":"public"},"engines":{"node":">= 14.0.0"},"author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"homepage":"https://github.com/eggjs/node-ip","repository":{"type":"git","url":"git://github.com/eggjs/node-ip.git"},"main":"lib/ip","types":"index.d.ts","devDependencies":{"@types/node":"^22.10.5","egg-bin":"^6.10.0","eslint":"^8.15.0","tsd":"^0.31.2"},"scripts":{"lint":"eslint lib test","pretest":"npm run lint -- --fix && tsd","test":"egg-bin test --ts false","preci":"npm run lint && tsd","ci":"egg-bin cov --ts false"},"license":"MIT","_id":"@eggjs/ip@2.1.0","gitHead":"6c37b45d1e3e2d4d56a357637c9f64545fa70fa6","description":"[![NPM version][npm-image]][npm-url] [![Node.js CI](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml) [![Test coverage][codecov-image]][codecov-url] [![Known Vulnerabil","bugs":{"url":"https://github.com/eggjs/node-ip/issues"},"_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"shasum":"979918a1351fab56ce043d5a83fe12de828d180a","size":6402,"noattachment":false,"key":"/@eggjs/ip/-/@eggjs/ip-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@eggjs/ip/download/@eggjs/ip-2.1.0.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"akitasummer","email":""},{"name":"atian25","email":"atian25@qq.com"},{"name":"coolme200","email":""},{"name":"eggjs-admin","email":""},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"gxkl","email":""},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"niania","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ip_2.1.0_1736773074359_0.342679885353095"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-01-13T12:57:54.522Z","publish_time":1736773074522,"_source_registry_name":"default","_cnpm_publish_time":1736773074522},"2.0.2":{"name":"@eggjs/ip","version":"2.0.2","publishConfig":{"access":"public"},"engines":{"node":">= 14.0.0"},"author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"homepage":"https://github.com/eggjs/node-ip","repository":{"type":"git","url":"git://github.com/eggjs/node-ip.git"},"main":"lib/ip","devDependencies":{"eslint":"^8.15.0","mocha":"^10.0.0"},"scripts":{"lint":"eslint lib/*.js test/*.js","test":"npm run lint && mocha --reporter spec test/*-test.js","fix":"npm run lint -- --fix"},"license":"MIT","_id":"@eggjs/ip@2.0.2","gitHead":"aa5672baeebff749eaf1d1e47280dc7acb27f248","description":"[![](https://badge.fury.io/js/@eggjs/ip.svg)](https://www.npmjs.com/package/@eggjs/ip)","bugs":{"url":"https://github.com/eggjs/node-ip/issues"},"_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"shasum":"3c362d8323b0aab3624e8396714ee2148a34e592","size":5330,"noattachment":false,"key":"/@eggjs/ip/-/@eggjs/ip-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@eggjs/ip/download/@eggjs/ip-2.0.2.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"akitasummer","email":""},{"name":"atian25","email":"atian25@qq.com"},{"name":"coolme200","email":""},{"name":"eggjs-admin","email":""},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"gxkl","email":""},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"niania","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ip_2.0.2_1718179997932_0.005583490672777636"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-06-12T08:13:18.075Z","publish_time":1718179998075,"_source_registry_name":"default","_cnpm_publish_time":1718179998075}},"readme":"# @eggjs/ip\n\n[![NPM version][npm-image]][npm-url]\n[![Node.js CI](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/node-ip/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/@eggjs/ip.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@eggjs/ip\n[codecov-image]: https://codecov.io/gh/eggjs/node-ip/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/eggjs/node-ip\n[snyk-image]: https://snyk.io/test/npm/@eggjs/ip/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/@eggjs/ip\n[download-image]: https://img.shields.io/npm/dm/@eggjs/ip.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@eggjs/ip\n\nIP address utilities for node.js\n\nSecurity fix fork, merge https://github.com/indutny/node-ip/pull/144\n\n## Installation\n\n### npm\n\n```shell\nnpm install @eggjs/ip\n```\n  \n## Usage\n\nGet your ip address, compare ip addresses, validate ip addresses, etc.\n\n```js\nvar ip = require('@eggjs/ip');\n\nip.address() // my ip address\nip.isEqual('::1', '::0:1'); // true\nip.toBuffer('127.0.0.1') // Buffer([127, 0, 0, 1])\nip.toString(new Buffer([127, 0, 0, 1])) // 127.0.0.1\nip.fromPrefixLen(24) // 255.255.255.0\nip.mask('192.168.1.134', '255.255.255.0') // 192.168.1.0\nip.cidr('192.168.1.134/26') // 192.168.1.128\nip.not('255.255.255.0') // 0.0.0.255\nip.or('192.168.1.134', '0.0.0.255') // 192.168.1.255\nip.isPrivate('127.0.0.1') // true\nip.isV4Format('127.0.0.1'); // true\nip.isV6Format('::ffff:127.0.0.1'); // true\nip.isValid('127.0.0.1'); // true\n\n// operate on buffers in-place\nvar buf = new Buffer(128);\nvar offset = 64;\nip.toBuffer('127.0.0.1', buf, offset);  // [127, 0, 0, 1] at offset 64\nip.toString(buf, offset, 4);            // '127.0.0.1'\n\n// subnet information\nip.subnet('192.168.1.134', '255.255.255.192')\n// { networkAddress: '192.168.1.128',\n//   firstAddress: '192.168.1.129',\n//   lastAddress: '192.168.1.190',\n//   broadcastAddress: '192.168.1.191',\n//   subnetMask: '255.255.255.192',\n//   subnetMaskLength: 26,\n//   numHosts: 62,\n//   length: 64,\n//   contains: function(addr){...} }\nip.cidrSubnet('192.168.1.134/26')\n// Same as previous.\n\n// range checking\nip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true\n\n// ipv4 long conversion\nip.toLong('127.0.0.1'); // 2130706433\nip.fromLong(2130706433); // '127.0.0.1'\n\n// malformed addresses and normalization\nip.normalizeStrict('0::01'); // '::1'\nip.isPrivate('0x7f.1'); // throw error\nip.isValidAndPrivate('0x7f.1'); // false\nip.normalizeStrict('0x7f.1'); // throw error\nvar normalized = ip.normalizeLax('0x7f.1'); // 127.0.0.1\nip.isPrivate(normalized); // true\n```\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=eggjs/node-ip)](https://github.com/eggjs/node-ip/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n\n### License\n\n```txt\nThis software is licensed under the MIT License.\n\nCopyright (c) 2024-present eggjs and other contributors.\nCopyright Fedor Indutny, 2012.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the\nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\nNO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n```\n","_attachments":{},"homepage":"https://github.com/eggjs/node-ip","bugs":{"url":"https://github.com/eggjs/node-ip/issues"},"license":"MIT"}