forwarded-for
Advanced tools
Comparing version 0.0.1 to 0.0.2
27
index.js
@@ -28,2 +28,7 @@ 'use strict'; | ||
{ | ||
ip: 'fastly-client-ip', | ||
port: 'fastly-client-port', // Estimated guess, no standard header available. | ||
proto: 'fastly-ssl' | ||
}, | ||
{ | ||
ip: 'x-forwarded-for', | ||
@@ -56,3 +61,3 @@ port: 'x-forwarded-port', | ||
function forwarded(headers, whitelist) { | ||
var ports, port, ips, ip, length = proxies.length, i = 0; | ||
var ports, port, proto, ips, ip, length = proxies.length, i = 0; | ||
@@ -64,2 +69,3 @@ for (; i < length; i++) { | ||
ips = (headers[proxies[i].ip] || '').split(','); | ||
proto = (headers[proxies[i].proto] || 'http'); | ||
@@ -91,5 +97,8 @@ // | ||
// | ||
// So extracting the first IP should be sufficient. | ||
// So extracting the first IP should be sufficient. There are SSL | ||
// terminators like the once's that is used by `fastly.com` which set their | ||
// HTTPS header to `1` as an indication that the connection was secure. | ||
// (This reduces bandwidth) | ||
// | ||
return new Forwarded(ip, port); | ||
return new Forwarded(ip, port, proto === '1' || proto === 'https'); | ||
} | ||
@@ -127,3 +136,4 @@ } | ||
obj.remoteAddress, | ||
obj.remotePort | ||
obj.remotePort, | ||
obj.encrypted | ||
); | ||
@@ -136,3 +146,4 @@ } | ||
obj.address, | ||
obj.port | ||
obj.port, | ||
obj.encrypted | ||
); | ||
@@ -145,3 +156,4 @@ } | ||
connection.remoteAddress, | ||
connection.remotePort | ||
connection.remotePort, | ||
connection.encrypted | ||
); | ||
@@ -153,3 +165,4 @@ } | ||
socket.remoteAddress, | ||
socket.remoteAddress | ||
socket.remoteAddress, | ||
socket.encrypted | ||
); | ||
@@ -156,0 +169,0 @@ } |
{ | ||
"name": "forwarded-for", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Abstraction for retrieving ip address information from a Node.js connection. Searches for proxy headers before degrading req.address", | ||
@@ -14,10 +14,14 @@ "main": "index.js", | ||
"keywords": [ | ||
"x-forwarded-for", | ||
"address", | ||
"client ip", | ||
"fastly", | ||
"forwarded-for", | ||
"ip", | ||
"address", | ||
"original ip", | ||
"parser", | ||
"ssl-terminator", | ||
"x-forwarded-for", | ||
"x-forwarded-proto", | ||
"z-forwarded-for", | ||
"x-real-ip" | ||
"x-real-ip", | ||
"z-forwarded-for" | ||
], | ||
@@ -24,0 +28,0 @@ "author": "Arnout Kazemier", |
@@ -53,3 +53,3 @@ # forwarded-for | ||
```js | ||
'use stict'; | ||
'use strict'; | ||
@@ -56,0 +56,0 @@ var forwarded = require('forwarded-for'); |
7705
147