Skip to content

Commit be76ea0

Browse files
authored
dep update (#39)
Signed-off-by: Matteo Collina <[email protected]>
1 parent aa06694 commit be76ea0

File tree

5 files changed

+53
-54
lines changed

5 files changed

+53
-54
lines changed

.taprc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
esm: false
21
ts: false
32
jsx: false
43
flow: false

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
},
1919
"homepage": "https://github.com/fastify/proxy-addr#readme",
2020
"dependencies": {
21-
"@fastify/forwarded": "^1.0.0",
21+
"@fastify/forwarded": "^2.0.0",
2222
"ipaddr.js": "^2.0.0"
2323
},
2424
"devDependencies": {
2525
"beautify-benchmark": "0.2.4",
2626
"benchmark": "2.1.4",
2727
"standard": "^17.0.0",
28-
"tap": "^14.11.0"
28+
"tap": "^16.0.0"
2929
},
3030
"files": [
3131
"LICENSE",

test/all.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,39 @@ test('argument trustshould be optional', function (t) {
1616

1717
test('with no headers should return socket address', function (t) {
1818
const req = createReq('127.0.0.1')
19-
t.deepEqual(proxyaddr.all(req), ['127.0.0.1'])
19+
t.same(proxyaddr.all(req), ['127.0.0.1'])
2020
t.end()
2121
})
2222

2323
test('with x-forwarded-for header should include x-forwarded-for', function (t) {
2424
const req = createReq('127.0.0.1', {
2525
'x-forwarded-for': '10.0.0.1'
2626
})
27-
t.deepEqual(proxyaddr.all(req), ['127.0.0.1', '10.0.0.1'])
27+
t.same(proxyaddr.all(req), ['127.0.0.1', '10.0.0.1'])
2828
t.end()
2929
})
3030

3131
test('with x-forwarded-for header should include x-forwarded-for in correct order', function (t) {
3232
const req = createReq('127.0.0.1', {
3333
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
3434
})
35-
t.deepEqual(proxyaddr.all(req), ['127.0.0.1', '10.0.0.2', '10.0.0.1'])
35+
t.same(proxyaddr.all(req), ['127.0.0.1', '10.0.0.2', '10.0.0.1'])
3636
t.end()
3737
})
3838

3939
test('with trust argument should stop at first untrusted', function (t) {
4040
const req = createReq('127.0.0.1', {
4141
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
4242
})
43-
t.deepEqual(proxyaddr.all(req, '127.0.0.1'), ['127.0.0.1', '10.0.0.2'])
43+
t.same(proxyaddr.all(req, '127.0.0.1'), ['127.0.0.1', '10.0.0.2'])
4444
t.end()
4545
})
4646

4747
test('with trust argument should be only socket address for no trust', function (t) {
4848
const req = createReq('127.0.0.1', {
4949
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
5050
})
51-
t.deepEqual(proxyaddr.all(req, []), ['127.0.0.1'])
51+
t.same(proxyaddr.all(req, []), ['127.0.0.1'])
5252
t.end()
5353
})
5454

test/base.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test('trust should not alter input array', function (t) {
7272
const arr = ['loopback', '10.0.0.1']
7373
const req = createReq('127.0.0.1')
7474
t.doesNotThrow(proxyaddr.bind(null, req, arr))
75-
t.deepEqual(arr, ['loopback', '10.0.0.1'])
75+
t.same(arr, ['loopback', '10.0.0.1'])
7676
t.end()
7777
})
7878

@@ -115,7 +115,7 @@ test('trust should be invoked as trust(addr, i)', function (t) {
115115
return log.push(Array.prototype.slice.call(arguments))
116116
})
117117

118-
t.deepEqual(log, [
118+
t.same(log, [
119119
['127.0.0.1', 0],
120120
['10.0.0.1', 1]
121121
])
@@ -125,249 +125,249 @@ test('trust should be invoked as trust(addr, i)', function (t) {
125125

126126
test('with all trusted should return socket address wtesth no headers', function (t) {
127127
const req = createReq('127.0.0.1')
128-
t.strictEqual(proxyaddr(req, all), '127.0.0.1')
128+
t.equal(proxyaddr(req, all), '127.0.0.1')
129129
t.end()
130130
})
131131

132132
test('with all trusted should return header value', function (t) {
133133
const req = createReq('127.0.0.1', {
134134
'x-forwarded-for': '10.0.0.1'
135135
})
136-
t.strictEqual(proxyaddr(req, all), '10.0.0.1')
136+
t.equal(proxyaddr(req, all), '10.0.0.1')
137137
t.end()
138138
})
139139

140140
test('with all trusted should return furthest header value', function (t) {
141141
const req = createReq('127.0.0.1', {
142142
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
143143
})
144-
t.strictEqual(proxyaddr(req, all), '10.0.0.1')
144+
t.equal(proxyaddr(req, all), '10.0.0.1')
145145
t.end()
146146
})
147147

148148
test('with none trusted should return socket address wtesth no headers', function (t) {
149149
const req = createReq('127.0.0.1')
150-
t.strictEqual(proxyaddr(req, none), '127.0.0.1')
150+
t.equal(proxyaddr(req, none), '127.0.0.1')
151151
t.end()
152152
})
153153

154154
test('with none trusted should return socket address wtesth headers', function (t) {
155155
const req = createReq('127.0.0.1', {
156156
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
157157
})
158-
t.strictEqual(proxyaddr(req, none), '127.0.0.1')
158+
t.equal(proxyaddr(req, none), '127.0.0.1')
159159
t.end()
160160
})
161161

162162
test('with some trusted should return socket address wtesth no headers', function (t) {
163163
const req = createReq('127.0.0.1')
164-
t.strictEqual(proxyaddr(req, trust10x), '127.0.0.1')
164+
t.equal(proxyaddr(req, trust10x), '127.0.0.1')
165165
t.end()
166166
})
167167

168168
test('with some trusted should return socket address when not trusted', function (t) {
169169
const req = createReq('127.0.0.1', {
170170
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
171171
})
172-
t.strictEqual(proxyaddr(req, trust10x), '127.0.0.1')
172+
t.equal(proxyaddr(req, trust10x), '127.0.0.1')
173173
t.end()
174174
})
175175

176176
test('with some trusted should return header when socket trusted', function (t) {
177177
const req = createReq('10.0.0.1', {
178178
'x-forwarded-for': '192.168.0.1'
179179
})
180-
t.strictEqual(proxyaddr(req, trust10x), '192.168.0.1')
180+
t.equal(proxyaddr(req, trust10x), '192.168.0.1')
181181
t.end()
182182
})
183183

184184
test('with some trusted should return first untrusted after trusted', function (t) {
185185
const req = createReq('10.0.0.1', {
186186
'x-forwarded-for': '192.168.0.1, 10.0.0.2'
187187
})
188-
t.strictEqual(proxyaddr(req, trust10x), '192.168.0.1')
188+
t.equal(proxyaddr(req, trust10x), '192.168.0.1')
189189
t.end()
190190
})
191191

192192
test('with some trusted should not skip untrusted', function (t) {
193193
const req = createReq('10.0.0.1', {
194194
'x-forwarded-for': '10.0.0.3, 192.168.0.1, 10.0.0.2'
195195
})
196-
t.strictEqual(proxyaddr(req, trust10x), '192.168.0.1')
196+
t.equal(proxyaddr(req, trust10x), '192.168.0.1')
197197
t.end()
198198
})
199199

200200
test('when given array should accept ltesteral IP addresses', function (t) {
201201
const req = createReq('10.0.0.1', {
202202
'x-forwarded-for': '192.168.0.1, 10.0.0.2'
203203
})
204-
t.strictEqual(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), '192.168.0.1')
204+
t.equal(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), '192.168.0.1')
205205
t.end()
206206
})
207207

208208
test('when given array should not trust non-IP addresses', function (t) {
209209
const req = createReq('10.0.0.1', {
210210
'x-forwarded-for': '192.168.0.1, 10.0.0.2, localhost'
211211
})
212-
t.strictEqual(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), 'localhost')
212+
t.equal(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), 'localhost')
213213
t.end()
214214
})
215215

216216
test('when given array should return socket address if none match', function (t) {
217217
const req = createReq('10.0.0.1', {
218218
'x-forwarded-for': '192.168.0.1, 10.0.0.2'
219219
})
220-
t.strictEqual(proxyaddr(req, ['127.0.0.1', '192.168.0.100']), '10.0.0.1')
220+
t.equal(proxyaddr(req, ['127.0.0.1', '192.168.0.100']), '10.0.0.1')
221221
t.end()
222222
})
223223

224224
test('when array empty should return socket address ', function (t) {
225225
const req = createReq('127.0.0.1')
226-
t.strictEqual(proxyaddr(req, []), '127.0.0.1')
226+
t.equal(proxyaddr(req, []), '127.0.0.1')
227227
t.end()
228228
})
229229

230230
test('when array empty should return socket address wtesth headers', function (t) {
231231
const req = createReq('127.0.0.1', {
232232
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
233233
})
234-
t.strictEqual(proxyaddr(req, []), '127.0.0.1')
234+
t.equal(proxyaddr(req, []), '127.0.0.1')
235235
t.end()
236236
})
237237

238238
test('when given IPv4 addresses should accept ltesteral IP addresses', function (t) {
239239
const req = createReq('10.0.0.1', {
240240
'x-forwarded-for': '192.168.0.1, 10.0.0.2'
241241
})
242-
t.strictEqual(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), '192.168.0.1')
242+
t.equal(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), '192.168.0.1')
243243
t.end()
244244
})
245245

246246
test('when given IPv4 addresses should accept CIDR notation', function (t) {
247247
const req = createReq('10.0.0.1', {
248248
'x-forwarded-for': '192.168.0.1, 10.0.0.200'
249249
})
250-
t.strictEqual(proxyaddr(req, '10.0.0.2/26'), '10.0.0.200')
250+
t.equal(proxyaddr(req, '10.0.0.2/26'), '10.0.0.200')
251251
t.end()
252252
})
253253

254254
test('when given IPv4 addresses should accept netmask notation', function (t) {
255255
const req = createReq('10.0.0.1', {
256256
'x-forwarded-for': '192.168.0.1, 10.0.0.200'
257257
})
258-
t.strictEqual(proxyaddr(req, '10.0.0.2/255.255.255.192'), '10.0.0.200')
258+
t.equal(proxyaddr(req, '10.0.0.2/255.255.255.192'), '10.0.0.200')
259259
t.end()
260260
})
261261

262262
test('when given IPv6 addresses should accept ltesteral IP addresses', function (t) {
263263
const req = createReq('fe80::1', {
264264
'x-forwarded-for': '2002:c000:203::1, fe80::2'
265265
})
266-
t.strictEqual(proxyaddr(req, ['fe80::1', 'fe80::2']), '2002:c000:203::1')
266+
t.equal(proxyaddr(req, ['fe80::1', 'fe80::2']), '2002:c000:203::1')
267267
t.end()
268268
})
269269

270270
test('when given IPv6 addresses should accept CIDR notation', function (t) {
271271
const req = createReq('fe80::1', {
272272
'x-forwarded-for': '2002:c000:203::1, fe80::ff00'
273273
})
274-
t.strictEqual(proxyaddr(req, 'fe80::/125'), 'fe80::ff00')
274+
t.equal(proxyaddr(req, 'fe80::/125'), 'fe80::ff00')
275275
t.end()
276276
})
277277

278278
test('with IP version mixed should match respective versions', function (t) {
279279
const req = createReq('::1', {
280280
'x-forwarded-for': '2002:c000:203::1'
281281
})
282-
t.strictEqual(proxyaddr(req, ['127.0.0.1', '::1']), '2002:c000:203::1')
282+
t.equal(proxyaddr(req, ['127.0.0.1', '::1']), '2002:c000:203::1')
283283
t.end()
284284
})
285285

286286
test('with IP version mixed should not match IPv4 to IPv6', function (t) {
287287
const req = createReq('::1', {
288288
'x-forwarded-for': '2002:c000:203::1'
289289
})
290-
t.strictEqual(proxyaddr(req, '127.0.0.1'), '::1')
290+
t.equal(proxyaddr(req, '127.0.0.1'), '::1')
291291
t.end()
292292
})
293293

294294
test('when IPv4-mapped IPv6 addresses should match IPv4 trust to IPv6 request', function (t) {
295295
const req = createReq('::ffff:a00:1', {
296296
'x-forwarded-for': '192.168.0.1, 10.0.0.2'
297297
})
298-
t.strictEqual(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), '192.168.0.1')
298+
t.equal(proxyaddr(req, ['10.0.0.1', '10.0.0.2']), '192.168.0.1')
299299
t.end()
300300
})
301301

302302
test('when IPv4-mapped IPv6 addresses should match IPv4 netmask trust to IPv6 request', function (t) {
303303
const req = createReq('::ffff:a00:1', {
304304
'x-forwarded-for': '192.168.0.1, 10.0.0.2'
305305
})
306-
t.strictEqual(proxyaddr(req, ['10.0.0.1/16']), '192.168.0.1')
306+
t.equal(proxyaddr(req, ['10.0.0.1/16']), '192.168.0.1')
307307
t.end()
308308
})
309309

310310
test('when IPv4-mapped IPv6 addresses should match IPv6 trust to IPv4 request', function (t) {
311311
const req = createReq('10.0.0.1', {
312312
'x-forwarded-for': '192.168.0.1, 10.0.0.2'
313313
})
314-
t.strictEqual(proxyaddr(req, ['::ffff:a00:1', '::ffff:a00:2']), '192.168.0.1')
314+
t.equal(proxyaddr(req, ['::ffff:a00:1', '::ffff:a00:2']), '192.168.0.1')
315315
t.end()
316316
})
317317

318318
test('when IPv4-mapped IPv6 addresses should match CIDR notation for IPv4-mapped address', function (t) {
319319
const req = createReq('10.0.0.1', {
320320
'x-forwarded-for': '192.168.0.1, 10.0.0.200'
321321
})
322-
t.strictEqual(proxyaddr(req, '::ffff:a00:2/122'), '10.0.0.200')
322+
t.equal(proxyaddr(req, '::ffff:a00:2/122'), '10.0.0.200')
323323
t.end()
324324
})
325325

326326
test('when IPv4-mapped IPv6 addresses should match CIDR notation for IPv4-mapped address mixed wtesth IPv6 CIDR', function (t) {
327327
const req = createReq('10.0.0.1', {
328328
'x-forwarded-for': '192.168.0.1, 10.0.0.200'
329329
})
330-
t.strictEqual(proxyaddr(req, ['::ffff:a00:2/122', 'fe80::/125']), '10.0.0.200')
330+
t.equal(proxyaddr(req, ['::ffff:a00:2/122', 'fe80::/125']), '10.0.0.200')
331331
t.end()
332332
})
333333

334334
test('when IPv4-mapped IPv6 addresses should match CIDR notation for IPv4-mapped address mixed wtesth IPv4 addresses', function (t) {
335335
const req = createReq('10.0.0.1', {
336336
'x-forwarded-for': '192.168.0.1, 10.0.0.200'
337337
})
338-
t.strictEqual(proxyaddr(req, ['::ffff:a00:2/122', '127.0.0.1']), '10.0.0.200')
338+
t.equal(proxyaddr(req, ['::ffff:a00:2/122', '127.0.0.1']), '10.0.0.200')
339339
t.end()
340340
})
341341

342342
test('when given predefined names should accept single pre-defined name', function (t) {
343343
const req = createReq('fe80::1', {
344344
'x-forwarded-for': '2002:c000:203::1, fe80::2'
345345
})
346-
t.strictEqual(proxyaddr(req, 'linklocal'), '2002:c000:203::1')
346+
t.equal(proxyaddr(req, 'linklocal'), '2002:c000:203::1')
347347
t.end()
348348
})
349349

350350
test('when given predefined names should accept multiple pre-defined names', function (t) {
351351
const req = createReq('::1', {
352352
'x-forwarded-for': '2002:c000:203::1, fe80::2'
353353
})
354-
t.strictEqual(proxyaddr(req, ['loopback', 'linklocal']), '2002:c000:203::1')
354+
t.equal(proxyaddr(req, ['loopback', 'linklocal']), '2002:c000:203::1')
355355
t.end()
356356
})
357357

358358
test('when header contains non-ip addresses should stop at first non-ip after trusted', function (t) {
359359
const req = createReq('127.0.0.1', {
360360
'x-forwarded-for': 'myrouter, 127.0.0.1, proxy'
361361
})
362-
t.strictEqual(proxyaddr(req, '127.0.0.1'), 'proxy')
362+
t.equal(proxyaddr(req, '127.0.0.1'), 'proxy')
363363
t.end()
364364
})
365365

366366
test('when header contains non-ip addresses should stop at first malformed ip after trusted', function (t) {
367367
const req = createReq('127.0.0.1', {
368368
'x-forwarded-for': 'myrouter, 127.0.0.1, ::8:8:8:8:8:8:8:8:8'
369369
})
370-
t.strictEqual(proxyaddr(req, '127.0.0.1'), '::8:8:8:8:8:8:8:8:8')
370+
t.equal(proxyaddr(req, '127.0.0.1'), '::8:8:8:8:8:8:8:8:8')
371371
t.end()
372372
})
373373

@@ -381,7 +381,7 @@ test('when header contains non-ip addresses should provide all values to functio
381381
return log.push(Array.prototype.slice.call(arguments))
382382
})
383383

384-
t.deepEqual(log, [
384+
t.same(log, [
385385
['127.0.0.1', 0],
386386
['proxy', 1],
387387
['127.0.0.1', 2]
@@ -391,15 +391,15 @@ test('when header contains non-ip addresses should provide all values to functio
391391

392392
test('when socket address undefined should return undefined as address', function (t) {
393393
const req = createReq(undefined)
394-
t.strictEqual(proxyaddr(req, '127.0.0.1'), undefined)
394+
t.equal(proxyaddr(req, '127.0.0.1'), undefined)
395395
t.end()
396396
})
397397

398398
test('when socket address undefined should return undefined even wtesth trusted headers', function (t) {
399399
const req = createReq(undefined, {
400400
'x-forwarded-for': '127.0.0.1, 10.0.0.1'
401401
})
402-
t.strictEqual(proxyaddr(req, '127.0.0.1'), undefined)
402+
t.equal(proxyaddr(req, '127.0.0.1'), undefined)
403403
t.end()
404404
})
405405

0 commit comments

Comments
 (0)