{"name":"@fastify/proxy-addr","version":"3.0.0","keywords":["ip","proxy","x-forwarded-for"],"author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","_id":"@fastify/proxy-addr@3.0.0","maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"airhorns","email":"harry@harry.me"},{"name":"davidmarkclements","email":"david.mark.clements@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":"maksim@sinik.it"},{"name":"salmanm","email":"salmanmitha@gmail.com"}],"homepage":"https://github.com/fastify/proxy-addr#readme","bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"dist":{"shasum":"7d3bb6474a01b206010329291f4edf6af8af582d","tarball":"http://registry-npm.ywwl.com/@fastify/proxy-addr/download/@fastify/proxy-addr-3.0.0.tgz","fileCount":4,"integrity":"sha512-ty7wnUd/GeSqKTC2Jozsl5xGbnxUnEFC0On2/zPv/8ixywipQmVZwuWvNGnBoitJ2wixwVqofwXNua8j6Y62lQ==","signatures":[{"sig":"MEUCIHBmcAxKkxfUwSoGeMsM9gWa+9K1rwU7rOeCtSc8pVcBAiEA6xw/KM2inFtDo7TL2p/q+hDNamdu3KdnQZBesIWSMLI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11561,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJsXjCRA9TVsSAnZWagAAUgcP/Azk++nIER4qsD1rC6M1\nCpUnIWBDASJePzC+gsecznlJoBCgb2TACVaBWadGP5uMl+rqXGy8RGg8kXBV\n/7Qm1z2dr7EozwoFSIAY0mlM76SdfzL+D9srHQEXcJPDYygcch0J7249vBlI\n+EyRWuwzGp3KErOvsgV5R7LfDHx2nGC7zb8ExG52eyzrRhhwwaBNAX2WIiu1\nmq0T+zweC59BiYA4FyBisIsZ3kVvC/dd722Hk2ZVuYFRUOZ+dzqsDrASyFBC\n5u679fvD+5uzeZqj8/WEYFdKvJnBwUEf39W7cKsz9cehXZOCNa5+brsIJS2X\nhdcnLWDMmiTARcl7v9b7IvdXEXu/GeW4dQ0Vpf9G69dr49rLk29aGC1J6nga\n9kwcO6cKiuDImA/5K6sCT2gwJype1bDhjn/gJSACKgUuO7s7jUqjYwD5iT+0\nhFb58SVlLz0NS54rqlpwo99grq2Kfd8+B+W8S7zy1jx4uZUzjIyxyWpRbVXU\nflabDEozZjSOc2sU9FQ8t0a+pOgcP8LeuZMTMtQEelqxHqPSw0xsFld+8w3l\n72Q438RIUD3TYOMNEu9GUZCzQCf0ghWnVd7SuSEq5VJaKr+T8dYk6AYUqPSN\n73RDIrT8XTIJHISKQEC8SQoUCS5+6JAGIxwKG01pDXRzHiXejdn09OkhfP6E\nAyl1\r\n=txzf\r\n-----END PGP SIGNATURE-----\r\n","size":4172,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-3.0.0.tgz"},"gitHead":"1ca1ae3cd8cb6f18b4b6fec8194ec5600e7ad7e8","scripts":{"test":"standard && tap","bench":"node benchmark/index.js"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"repository":{"url":"git+https://github.com/fastify/proxy-addr.git","type":"git"},"_npmVersion":"6.14.11","description":"Determine address of proxied request","directories":{},"_nodeVersion":"14.15.4","dependencies":{"ipaddr.js":"^2.0.0","@fastify/forwarded":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^14.11.0","standard":"^16.0.3","benchmark":"2.1.4","beautify-benchmark":"0.2.4"},"_npmOperationalInternal":{"tmp":"tmp/proxy-addr_3.0.0_1613153762784_0.6577085370964424","host":"s3://npm-registry-packages"},"readme":"# proxy-addr\n\n[![CI](https://github.com/fastify/proxy-addr/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/proxy-addr/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/proxy-addr.svg?style=flat)](https://www.npmjs.com/package/@fastify/proxy-addr)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nDetermine the address of a proxied request.\n\nForked from https://github.com/jshttp/proxy-addr to address https://github.com/jshttp/forwarded/pull/9.\n\n## Install\n\n```sh\n$ npm i @fastify/proxy-addr\n```\n\n## API\n\n<!-- eslint-disable no-unused-vars -->\n\n```js\nconst proxyaddr = require('@fastify/proxy-addr')\n```\n\n### proxyaddr(req, trust)\n\nReturn the address of the request, using the given `trust` parameter.\n\nThe `trust` argument is a function that returns `true` if you trust\nthe address, `false` if you don't. The closest untrusted address is\nreturned.\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, function (addr) { return addr === '127.0.0.1' })\nproxyaddr(req, function (addr, i) { return i < 1 })\n```\n\nThe `trust` argument may also be a single IP address string or an\narray of trusted addresses, as plain IP addresses, CIDR-formatted\nstrings, or IP/netmask strings.\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, '127.0.0.1')\nproxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8'])\nproxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0'])\n```\n\nThis module also supports IPv6. Your IPv6 addresses will be normalized\nautomatically (i.e. `fe80::00ed:1` equals `fe80:0:0:0:0:0:ed:1`).\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, '::1')\nproxyaddr(req, ['::1/128', 'fe80::/10'])\n```\n\nThis module will automatically work with IPv4-mapped IPv6 addresses\nas well to support node.js in IPv6-only mode. This means that you do\nnot have to specify both `::ffff:a00:1` and `10.0.0.1`.\n\nAs a convenience, this module also takes certain pre-defined names\nin addition to IP addresses, which expand into IP addresses:\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, 'loopback')\nproxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64'])\n```\n\n  * `loopback`: IPv4 and IPv6 loopback addresses (like `::1` and\n    `127.0.0.1`).\n  * `linklocal`: IPv4 and IPv6 link-local addresses (like\n    `fe80::1:1:1:1` and `169.254.0.1`).\n  * `uniquelocal`: IPv4 private addresses and IPv6 unique-local\n    addresses (like `fc00:ac:1ab5:fff::1` and `192.168.0.1`).\n\nWhen `trust` is specified as a function, it will be called for each\naddress to determine if it is a trusted address. The function is\ngiven two arguments: `addr` and `i`, where `addr` is a string of\nthe address to check and `i` is a number that represents the distance\nfrom the socket address.\n\n### proxyaddr.all(req, [trust])\n\nReturn all the request addresses, optionally stopping at the\nfirst untrusted. This array is ordered from closest to furthest\n(i.e. `arr[0] === req.connection.remoteAddress`).\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr.all(req)\n```\n\nThe optional `trust` argument takes the same arguments as `trust`\ndoes in `proxyaddr(req, trust)`.\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr.all(req, 'loopback')\n```\n\n### proxyaddr.compile(val)\n\nCompiles argument `val` into a `trust` function. This function takes\nthe same arguments as `trust` does in `proxyaddr(req, trust)` and\nreturns a function suitable for `proxyaddr(req, trust)`.\n\n<!-- eslint-disable no-undef, no-unused-vars -->\n\n```js\nconst trust = proxyaddr.compile('loopback')\nconst addr = proxyaddr(req, trust)\n```\n\nThis function is meant to be optimized for use against every request.\nIt is recommended that a trust function be compiled up-front for the\ntrusted configuration and passed to proxyaddr(req, trust) for each request.\n\n## Testing\n\n```sh\n$ npm test\n```\n\n## Benchmarks\n\n```sh\n$ npm run bench\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","publish_time":1613153762939,"_cnpm_publish_time":1613153762939,"dist-tags":{"latest":"5.1.2","next":"5.0.0"}}