{"name":"@fastify/proxy-addr","version":"5.1.0","keywords":["ip","proxy","x-forwarded-for"],"author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","_id":"@fastify/proxy-addr@5.1.0","maintainers":[{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"}],"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},{"url":"https://james.sumners.info","name":"James Sumners"},{"url":"https://github.com/fdawgs","name":"Frazer Smith","email":"frazer.dev@icloud.com"}],"homepage":"https://github.com/fastify/proxy-addr#readme","bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"dist":{"shasum":"f5360b5dd83c7de3d41b415be4aab84ae44aa106","tarball":"http://registry-npm.ywwl.com/@fastify/proxy-addr/download/@fastify/proxy-addr-5.1.0.tgz","fileCount":18,"integrity":"sha512-INS+6gh91cLUjB+PVHfu1UqcB76Sqtpyp7bnL+FYojhjygvOPA9ctiD/JDKsyD9Xgu4hUhCSJBPig/w7duNajw==","signatures":[{"sig":"MEQCIH1fZ2394Z4n+H63WD+AovLcz2hlKY5mQpl4Gh3oPbdLAiAxe3BgNk1U9u86fW/B0AU5P/WNbmzZlLW24E+uNuEAfA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37777,"size":8534,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-5.1.0.tgz"},"main":"index.js","type":"commonjs","types":"types/index.d.ts","funding":[{"url":"https://github.com/sponsors/fastify","type":"github"},{"url":"https://opencollective.com/fastify","type":"opencollective"}],"gitHead":"918e32cf3a7502c32d5a8426e42616c74fa34d67","scripts":{"lint":"eslint","test":"npm run test:unit && npm run test:typescript","bench":"node benchmark/index.js","lint:fix":"eslint --fix","test:unit":"c8 --100 node --test","test:typescript":"tsd"},"_npmUser":{"name":"eomm","email":"behemoth89@gmail.com"},"repository":{"url":"git+https://github.com/fastify/proxy-addr.git","type":"git"},"_npmVersion":"10.9.3","description":"Determine the address of a proxied request","directories":{},"_nodeVersion":"22.19.0","dependencies":{"ipaddr.js":"^2.1.0","@fastify/forwarded":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","tsd":"^0.32.0","eslint":"^9.17.0","benchmark":"2.1.4","@types/node":"^24.0.8","neostandard":"^0.12.0","beautify-benchmark":"0.2.4"},"_npmOperationalInternal":{"tmp":"tmp/proxy-addr_5.1.0_1759072635900_0.06533958968416509","host":"s3://npm-registry-packages-npm-production"},"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":1759072724994,"_cnpm_publish_time":1759072724994,"dist-tags":{"latest":"5.1.2","next":"5.0.0"}}