Comparing version 0.0.3 to 0.0.4
@@ -0,1 +1,7 @@ | ||
## 0.0.4 | ||
Enhancement: | ||
- Support for Left2Right or Right2Left Proxy IP Lookup | ||
## 0.0.3 | ||
@@ -2,0 +8,0 @@ |
@@ -113,3 +113,3 @@ | ||
_me.get_ip = function (req) { | ||
_me.get_ip = function (req, right_most_proxy) { | ||
@@ -120,2 +120,3 @@ initialize(); | ||
var value = null; | ||
var right_most_proxy = right_most_proxy || false; | ||
@@ -126,2 +127,5 @@ for (var i = 0; i < ipware_precedence_list.length; i++) { | ||
var ips = value.split(','); | ||
if (right_most_proxy) { | ||
ips = ips.reverse(); | ||
} | ||
for (var j = 0; j < ips.length; j++) { | ||
@@ -128,0 +132,0 @@ var ip = ips[j].trim(); |
{ | ||
"name": "ipware", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Returns the real IP address of users in Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,2 +6,4 @@ Node IPware | ||
[![build-status-image-travis]][travis] | ||
Overview | ||
@@ -42,2 +44,9 @@ ==================== | ||
// **Advanced option:** By default the left most address in the `HTTP_X_FORWARDED_FOR` is returned. | ||
// However, depending on your preference and needs, you can change this behavior by passing | ||
// the `right_most_proxy=True` to the API. | ||
// **Note:** Not all proxies are equal. So left to right or right to left preference is not a | ||
// rule that all proxy servers follow. | ||
var ip_info = get_ip(req, right_most_proxy=True) | ||
``` | ||
@@ -164,1 +173,3 @@ | ||
[build-status-image-travis]: https://secure.travis-ci.org/un33k/node-ipware.png?branch=master | ||
[travis]: http://travis-ci.org/un33k/node-ipware?branch=master |
@@ -18,2 +18,14 @@ var get_ip = require('..')().get_ip, | ||
describe('get_ip(): IPV4: HTTP_X_FORWARDED_FOR', function() { | ||
it('test_x_forwarded_for_multiple_right_most_proxy', function() { | ||
var request = {headers: {}}; | ||
request.headers.HTTP_X_FORWARDED_FOR = '192.168.255.182, 198.84.193.157, 10.0.0.0, 127.0.0.1, 177.139.233.139'; | ||
request.headers.HTTP_X_REAL_IP = '177.139.233.132'; | ||
request.headers.REMOTE_ADDR = '177.139.233.133'; | ||
get_ip(request, right_most_proxy=true); | ||
assert.equal(request.clientIp, '177.139.233.139'); | ||
assert.equal(request.clientIpRoutable, true); | ||
}); | ||
}); | ||
describe('get_ip(): IPV4: HTTP_X_FORWARDED_FOR', function() { | ||
it('test_x_forwarded_for_multiple_bad_address', function() { | ||
@@ -20,0 +32,0 @@ var request = {headers: {}}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29687
589
173