UNPKG

motion

Version:

motion - moving development forward

79 lines (78 loc) 6.38 kB
{ "_args": [ [ "proxy-addr@https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.10.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "proxy-addr@>=1.0.7 <1.1.0", "_id": "proxy-addr@1.0.10", "_inCache": true, "_location": "/proxy-addr", "_phantomChildren": {}, "_requested": { "name": "proxy-addr", "raw": "proxy-addr@https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.10.tgz", "rawSpec": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.10.tgz", "scope": null, "spec": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.10.tgz", "type": "remote" }, "_requiredBy": [ "/express" ], "_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.10.tgz", "_shasum": "0d40a82f801fc355567d2ecb65efe3f077f121c5", "_shrinkwrap": null, "_spec": "proxy-addr@https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.10.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "email": "doug@somethingdoug.com", "name": "Douglas Christopher Wilson" }, "bugs": { "url": "https://github.com/jshttp/proxy-addr/issues" }, "dependencies": { "forwarded": "~0.1.0", "ipaddr.js": "1.0.5" }, "description": "Determine address of proxied request", "devDependencies": { "beautify-benchmark": "0.2.4", "benchmark": "1.0.0", "istanbul": "0.4.1", "mocha": "~1.21.5" }, "engines": { "node": ">= 0.6" }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], "homepage": "https://github.com/jshttp/proxy-addr#readme", "keywords": [ "ip", "proxy", "x-forwarded-for" ], "license": "MIT", "name": "proxy-addr", "optionalDependencies": {}, "readme": "# proxy-addr\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Node.js Version][node-version-image]][node-version-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nDetermine address of proxied request\n\n## Install\n\n```sh\n$ npm install proxy-addr\n```\n\n## API\n\n```js\nvar proxyaddr = require('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```js\nproxyaddr(req, function(addr){ return addr === '127.0.0.1' })\nproxyaddr(req, function(addr, i){ return i < 1 })\n```\n\nThe `trust` arugment 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```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```js\nproxyaddr(req, '::1')\nproxyaddr(req, ['::1/128', 'fe80::/10'])\nproxyaddr(req, ['fe80::/ffc0::'])\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```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 addresses of the request, optionally stopping at the\nfirst untrusted. This array is ordered from closest to furthest\n(i.e. `arr[0] === req.connection.remoteAddress`).\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```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```js\nvar trust = proxyaddr.compile('localhost')\nvar addr = proxyaddr(req, trust)\n```\n\nThis function is meant to be optimized for use against every request.\nIt is recommend to compile a trust function up-front for the trusted\nconfiguration and pass that 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-script bench\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/proxy-addr.svg\n[npm-url]: https://npmjs.org/package/proxy-addr\n[node-version-image]: https://img.shields.io/node/v/proxy-addr.svg\n[node-version-url]: http://nodejs.org/download/\n[travis-image]: https://img.shields.io/travis/jshttp/proxy-addr/master.svg\n[travis-url]: https://travis-ci.org/jshttp/proxy-addr\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/proxy-addr/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/proxy-addr?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/proxy-addr.svg\n[downloads-url]: https://npmjs.org/package/proxy-addr\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/jshttp/proxy-addr.git" }, "scripts": { "bench": "node benchmark/index.js", "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, "version": "1.0.10" }