aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/forwarded
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/forwarded')
-rw-r--r--node_modules/forwarded/HISTORY.md16
-rw-r--r--node_modules/forwarded/LICENSE22
-rw-r--r--node_modules/forwarded/README.md57
-rw-r--r--node_modules/forwarded/index.js76
-rw-r--r--node_modules/forwarded/package.json114
5 files changed, 285 insertions, 0 deletions
diff --git a/node_modules/forwarded/HISTORY.md b/node_modules/forwarded/HISTORY.md
new file mode 100644
index 0000000..2599a55
--- /dev/null
+++ b/node_modules/forwarded/HISTORY.md
@@ -0,0 +1,16 @@
+0.1.2 / 2017-09-14
+==================
+
+ * perf: improve header parsing
+ * perf: reduce overhead when no `X-Forwarded-For` header
+
+0.1.1 / 2017-09-10
+==================
+
+ * Fix trimming leading / trailing OWS
+ * perf: hoist regular expression
+
+0.1.0 / 2014-09-21
+==================
+
+ * Initial release
diff --git a/node_modules/forwarded/LICENSE b/node_modules/forwarded/LICENSE
new file mode 100644
index 0000000..84441fb
--- /dev/null
+++ b/node_modules/forwarded/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2014-2017 Douglas Christopher Wilson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/forwarded/README.md b/node_modules/forwarded/README.md
new file mode 100644
index 0000000..c776ee5
--- /dev/null
+++ b/node_modules/forwarded/README.md
@@ -0,0 +1,57 @@
+# forwarded
+
+[![NPM Version][npm-image]][npm-url]
+[![NPM Downloads][downloads-image]][downloads-url]
+[![Node.js Version][node-version-image]][node-version-url]
+[![Build Status][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+Parse HTTP X-Forwarded-For header
+
+## Installation
+
+This is a [Node.js](https://nodejs.org/en/) module available through the
+[npm registry](https://www.npmjs.com/). Installation is done using the
+[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
+
+```sh
+$ npm install forwarded
+```
+
+## API
+
+```js
+var forwarded = require('forwarded')
+```
+
+### forwarded(req)
+
+```js
+var addresses = forwarded(req)
+```
+
+Parse the `X-Forwarded-For` header from the request. Returns an array
+of the addresses, including the socket address for the `req`, in reverse
+order (i.e. index `0` is the socket address and the last index is the
+furthest address, typically the end-user).
+
+## Testing
+
+```sh
+$ npm test
+```
+
+## License
+
+[MIT](LICENSE)
+
+[npm-image]: https://img.shields.io/npm/v/forwarded.svg
+[npm-url]: https://npmjs.org/package/forwarded
+[node-version-image]: https://img.shields.io/node/v/forwarded.svg
+[node-version-url]: https://nodejs.org/en/download/
+[travis-image]: https://img.shields.io/travis/jshttp/forwarded/master.svg
+[travis-url]: https://travis-ci.org/jshttp/forwarded
+[coveralls-image]: https://img.shields.io/coveralls/jshttp/forwarded/master.svg
+[coveralls-url]: https://coveralls.io/r/jshttp/forwarded?branch=master
+[downloads-image]: https://img.shields.io/npm/dm/forwarded.svg
+[downloads-url]: https://npmjs.org/package/forwarded
diff --git a/node_modules/forwarded/index.js b/node_modules/forwarded/index.js
new file mode 100644
index 0000000..7833b3d
--- /dev/null
+++ b/node_modules/forwarded/index.js
@@ -0,0 +1,76 @@
+/*!
+ * forwarded
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module exports.
+ * @public
+ */
+
+module.exports = forwarded
+
+/**
+ * Get all addresses in the request, using the `X-Forwarded-For` header.
+ *
+ * @param {object} req
+ * @return {array}
+ * @public
+ */
+
+function forwarded (req) {
+ if (!req) {
+ throw new TypeError('argument req is required')
+ }
+
+ // simple header parsing
+ var proxyAddrs = parse(req.headers['x-forwarded-for'] || '')
+ var socketAddr = req.connection.remoteAddress
+ var addrs = [socketAddr].concat(proxyAddrs)
+
+ // return all addresses
+ return addrs
+}
+
+/**
+ * Parse the X-Forwarded-For header.
+ *
+ * @param {string} header
+ * @private
+ */
+
+function parse (header) {
+ var end = header.length
+ var list = []
+ var start = header.length
+
+ // gather addresses, backwards
+ for (var i = header.length - 1; i >= 0; i--) {
+ switch (header.charCodeAt(i)) {
+ case 0x20: /* */
+ if (start === end) {
+ start = end = i
+ }
+ break
+ case 0x2c: /* , */
+ if (start !== end) {
+ list.push(header.substring(start, end))
+ }
+ start = end = i
+ break
+ default:
+ start = i
+ break
+ }
+ }
+
+ // final address
+ if (start !== end) {
+ list.push(header.substring(start, end))
+ }
+
+ return list
+}
diff --git a/node_modules/forwarded/package.json b/node_modules/forwarded/package.json
new file mode 100644
index 0000000..fbbbe59
--- /dev/null
+++ b/node_modules/forwarded/package.json
@@ -0,0 +1,114 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "forwarded@~0.1.2",
+ "scope": null,
+ "escapedName": "forwarded",
+ "name": "forwarded",
+ "rawSpec": "~0.1.2",
+ "spec": ">=0.1.2 <0.2.0",
+ "type": "range"
+ },
+ "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/proxy-addr"
+ ]
+ ],
+ "_from": "forwarded@>=0.1.2 <0.2.0",
+ "_id": "forwarded@0.1.2",
+ "_inCache": true,
+ "_location": "/forwarded",
+ "_nodeVersion": "6.11.1",
+ "_npmOperationalInternal": {
+ "host": "s3://npm-registry-packages",
+ "tmp": "tmp/forwarded-0.1.2.tgz_1505441873168_0.0936233215034008"
+ },
+ "_npmUser": {
+ "name": "dougwilson",
+ "email": "doug@somethingdoug.com"
+ },
+ "_npmVersion": "3.10.10",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "forwarded@~0.1.2",
+ "scope": null,
+ "escapedName": "forwarded",
+ "name": "forwarded",
+ "rawSpec": "~0.1.2",
+ "spec": ">=0.1.2 <0.2.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/proxy-addr"
+ ],
+ "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
+ "_shasum": "98c23dab1175657b8c0573e8ceccd91b0ff18c84",
+ "_shrinkwrap": null,
+ "_spec": "forwarded@~0.1.2",
+ "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/proxy-addr",
+ "bugs": {
+ "url": "https://github.com/jshttp/forwarded/issues"
+ },
+ "contributors": [
+ {
+ "name": "Douglas Christopher Wilson",
+ "email": "doug@somethingdoug.com"
+ }
+ ],
+ "dependencies": {},
+ "description": "Parse HTTP X-Forwarded-For header",
+ "devDependencies": {
+ "beautify-benchmark": "0.2.4",
+ "benchmark": "2.1.4",
+ "eslint": "3.19.0",
+ "eslint-config-standard": "10.2.1",
+ "eslint-plugin-import": "2.7.0",
+ "eslint-plugin-node": "5.1.1",
+ "eslint-plugin-promise": "3.5.0",
+ "eslint-plugin-standard": "3.0.1",
+ "istanbul": "0.4.5",
+ "mocha": "1.21.5"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "98c23dab1175657b8c0573e8ceccd91b0ff18c84",
+ "tarball": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ },
+ "files": [
+ "LICENSE",
+ "HISTORY.md",
+ "README.md",
+ "index.js"
+ ],
+ "gitHead": "2fc094b49781b62acb0e2b00f83abd641d604a7c",
+ "homepage": "https://github.com/jshttp/forwarded#readme",
+ "keywords": [
+ "x-forwarded-for",
+ "http",
+ "req"
+ ],
+ "license": "MIT",
+ "maintainers": [
+ {
+ "name": "dougwilson",
+ "email": "doug@somethingdoug.com"
+ }
+ ],
+ "name": "forwarded",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/jshttp/forwarded.git"
+ },
+ "scripts": {
+ "bench": "node benchmark/index.js",
+ "lint": "eslint .",
+ "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": "0.1.2"
+}