{"name":"@fastify/proxy-addr","version":"4.1.0","keywords":["ip","proxy","x-forwarded-for"],"author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","_id":"@fastify/proxy-addr@4.1.0","maintainers":[{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"jsumners","email":"james.sumners@gmail.com"}],"homepage":"https://github.com/fastify/proxy-addr#readme","bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"dist":{"shasum":"511b412693301d50f189e9985b0f01af81ad6730","tarball":"http://registry-npm.ywwl.com/@fastify/proxy-addr/download/@fastify/proxy-addr-4.1.0.tgz","fileCount":18,"integrity":"sha512-qM7GsdQLojsqv7Ldhn6Ygu9p/9m/uzeAtVReZI7kJ8UzsXXTeHjFe6BzQI4FRCaW2VaZEuZI5W7OF2u0SZn4Lw==","signatures":[{"sig":"MEUCIBvI3dmaMCyCzfgiP2kZt8R7IoyaPADc+jy3ZAzhTa2+AiEA704N+HGFrTvsTVs1UbY6PK1VvbGmapwQfmVwKkUqN1k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36176,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjmxIIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqY8Q//S9UCDFijyuWrkngoKwYG8p10W8sxmZmdOFwtEAaCOPBEgZoq\r\np6/QPWiAKYNhVBOh6HxCTRrzAaOZAc4pt3W4zHjb9xly5S+3pIlao/sfLh5o\r\nn9XFIR47txSo0KFKaHNhy31lo6dSzPBhT8ZRGy/P4OFmZgWavMCI6eIZh2IR\r\nVnS/qYrp7dG5OeevBNzGy7utrht7dH78h2fHB3w5kAppcvyIfk5DyD7sHShR\r\n320HonW1g+rHAWt3VyZq4lA0n4mJawYwao4o9sjcMdjln54LHxL16feCyQ1h\r\nleYVOzlapZ+4/xfQJqXnRZH1YzRG300R1ug6q09U0ncfSQrFQU1T51Xr0P3h\r\n6WIqDbzNdtrAWmbYZXI1phWv5bUiYgnU8/lvbIyQaVXoufaCfqEfatzR6S3t\r\n7rabHVK5k1EG5OGIUvckbvdsmO6+WexgSaiLNp8ZjPoL8MtF8hKri0EcQqSU\r\n7NLt68P4z5Gx6vLX7diwz2xGsw7UveOUTWjRU3rUxW5pD4gIoehMjGViDhZH\r\nqFipti07BNAZps6qf3KvL2V8NH1aypU76iPWsWZZhAgWQSHnOepoBJJeORDf\r\n0HhNq8N1sSPr6r0/HlgDjpzgzDPvFMnRg7L5iT0plsek7u1C56Yf+5oVqSIN\r\nKIuSdgRJKwFirKF0pT7MR2qKEZlmuB5VPHM=\r\n=xWnh\r\n-----END PGP SIGNATURE-----\r\n","size":8115,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-4.1.0.tgz"},"main":"index.js","types":"types/index.d.ts","gitHead":"db635d606fb368a9d6e4736508fd5cf509c7a332","scripts":{"lint":"standard","test":"npm run test:unit && npm run test:typescript","bench":"node benchmark/index.js","test:unit":"tap","test:typescript":"tsd"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"repository":{"url":"git+https://github.com/fastify/proxy-addr.git","type":"git"},"_npmVersion":"9.1.2","description":"Determine address of proxied request","directories":{},"_nodeVersion":"16.17.0","dependencies":{"ipaddr.js":"^2.0.0","@fastify/forwarded":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.0.0","tsd":"^0.25.0","standard":"^17.0.0","benchmark":"2.1.4","@types/node":"^18.11.11","beautify-benchmark":"0.2.4"},"_npmOperationalInternal":{"tmp":"tmp/proxy-addr_4.1.0_1671107080372_0.9244830690855266","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":1671107080640,"_cnpm_publish_time":1671107080640,"dist-tags":{"latest":"5.1.2","next":"5.0.0"}}