File: 0000-bundle_forwarded.patch

package info (click to toggle)
node-proxy-addr 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 172 kB
  • ctags: 37
  • sloc: makefile: 7; sh: 2
file content (225 lines) | stat: -rw-r--r-- 6,408 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
Description: Bundle forwarded module as patch since it only
 reverse depends on proxy-addr module.
Author: Leo Iannacone <l3on@ubutnu.com>
Forwarded: not-needed

--- /dev/null
+++ node-proxy-addr-1.0.3/node_modules/forwarded/.travis.yml
@@ -0,0 +1,15 @@
+language: node_js
+node_js:
+  - "0.6"
+  - "0.8"
+  - "0.10"
+  - "0.11"
+matrix:
+  allow_failures:
+    - node_js: "0.11"
+  fast_finish: true
+script:
+  - "test $TRAVIS_NODE_VERSION != '0.6' || npm test"
+  - "test $TRAVIS_NODE_VERSION  = '0.6' || npm run-script test-travis"
+after_script:
+  - "test $TRAVIS_NODE_VERSION = '0.10' && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
--- /dev/null
+++ node-proxy-addr-1.0.3/node_modules/forwarded/HISTORY.md
@@ -0,0 +1,4 @@
+0.1.0 / 2014-09-21
+==================
+
+  * Initial release
--- /dev/null
+++ node-proxy-addr-1.0.3/node_modules/forwarded/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2014 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.
--- /dev/null
+++ node-proxy-addr-1.0.3/node_modules/forwarded/README.md
@@ -0,0 +1,53 @@
+# 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
+
+```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?style=flat
+[npm-url]: https://npmjs.org/package/forwarded
+[node-version-image]: https://img.shields.io/node/v/forwarded.svg?style=flat
+[node-version-url]: http://nodejs.org/download/
+[travis-image]: https://img.shields.io/travis/jshttp/forwarded.svg?style=flat
+[travis-url]: https://travis-ci.org/jshttp/forwarded
+[coveralls-image]: https://img.shields.io/coveralls/jshttp/forwarded.svg?style=flat
+[coveralls-url]: https://coveralls.io/r/jshttp/forwarded?branch=master
+[downloads-image]: https://img.shields.io/npm/dm/forwarded.svg?style=flat
+[downloads-url]: https://npmjs.org/package/forwarded
--- /dev/null
+++ node-proxy-addr-1.0.3/node_modules/forwarded/index.js
@@ -0,0 +1,35 @@
+/*!
+ * forwarded
+ * Copyright(c) 2014 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+/**
+ * Module exports.
+ */
+
+module.exports = forwarded
+
+/**
+ * Get all addresses in the request, using the `X-Forwarded-For` header.
+ *
+ * @param {Object} req
+ * @api public
+ */
+
+function forwarded(req) {
+  if (!req) {
+    throw new TypeError('argument req is required')
+  }
+
+  // simple header parsing
+  var proxyAddrs = (req.headers['x-forwarded-for'] || '')
+    .split(/ *, */)
+    .filter(Boolean)
+    .reverse()
+  var socketAddr = req.connection.remoteAddress
+  var addrs = [socketAddr].concat(proxyAddrs)
+
+  // return all addresses
+  return addrs
+}
--- /dev/null
+++ node-proxy-addr-1.0.3/node_modules/forwarded/package.json
@@ -0,0 +1,33 @@
+{
+  "name": "forwarded",
+  "description": "Parse HTTP X-Forwarded-For header",
+  "version": "0.1.0",
+  "contributors": [
+    "Douglas Christopher Wilson <doug@somethingdoug.com>"
+  ],
+  "license": "MIT",
+  "keywords": [
+    "x-forwarded-for",
+    "http",
+    "req"
+  ],
+  "repository": "jshttp/forwarded",
+  "devDependencies": {
+    "istanbul": "0.3.2",
+    "mocha": "~1.21.4"
+  },
+  "files": [
+    "LICENSE",
+    "HISTORY.md",
+    "README.md",
+    "index.js"
+  ],
+  "engines": {
+    "node": ">= 0.6"
+  },
+  "scripts": {
+    "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/"
+  }
+}
--- /dev/null
+++ node-proxy-addr-1.0.3/node_modules/forwarded/test/test.js
@@ -0,0 +1,37 @@
+
+var assert = require('assert')
+var forwarded = require('..')
+
+describe('forwarded(req)', function () {
+  it('should require req', function () {
+    assert.throws(forwarded.bind(null), /argument req.*required/)
+  })
+
+  it('should work with X-Forwarded-For header', function () {
+    var req = createReq('127.0.0.1')
+    assert.deepEqual(forwarded(req), ['127.0.0.1'])
+  })
+
+  it('should include entries from X-Forwarded-For', function () {
+    var req = createReq('127.0.0.1', {
+      'x-forwarded-for': '10.0.0.2, 10.0.0.1'
+    })
+    assert.deepEqual(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2'])
+  })
+
+  it('should skip blank entries', function () {
+    var req = createReq('127.0.0.1', {
+      'x-forwarded-for': '10.0.0.2,, 10.0.0.1'
+    })
+    assert.deepEqual(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2'])
+  })
+})
+
+function createReq(socketAddr, headers) {
+  return {
+    connection: {
+      remoteAddress: socketAddr
+    },
+    headers: headers || {}
+  };
+}