First commit
This commit is contained in:
16
node_modules/forwarded/HISTORY.md
generated
vendored
Executable file
16
node_modules/forwarded/HISTORY.md
generated
vendored
Executable file
@ -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
|
22
node_modules/forwarded/LICENSE
generated
vendored
Executable file
22
node_modules/forwarded/LICENSE
generated
vendored
Executable file
@ -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.
|
57
node_modules/forwarded/README.md
generated
vendored
Executable file
57
node_modules/forwarded/README.md
generated
vendored
Executable file
@ -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
|
76
node_modules/forwarded/index.js
generated
vendored
Executable file
76
node_modules/forwarded/index.js
generated
vendored
Executable file
@ -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
|
||||
}
|
78
node_modules/forwarded/package.json
generated
vendored
Executable file
78
node_modules/forwarded/package.json
generated
vendored
Executable file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"_from": "forwarded@~0.1.2",
|
||||
"_id": "forwarded@0.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=",
|
||||
"_location": "/forwarded",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "forwarded@~0.1.2",
|
||||
"name": "forwarded",
|
||||
"escapedName": "forwarded",
|
||||
"rawSpec": "~0.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~0.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/proxy-addr"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
|
||||
"_shasum": "98c23dab1175657b8c0573e8ceccd91b0ff18c84",
|
||||
"_spec": "forwarded@~0.1.2",
|
||||
"_where": "/Users/josh.burman/Projects/braid/node_modules/proxy-addr",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/forwarded/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"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"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/jshttp/forwarded#readme",
|
||||
"keywords": [
|
||||
"x-forwarded-for",
|
||||
"http",
|
||||
"req"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "forwarded",
|
||||
"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"
|
||||
}
|
Reference in New Issue
Block a user