Added req.ip
Esse commit está contido em:
@@ -325,6 +325,19 @@ req.__defineGetter__('secure', function(){
|
||||
return 'https' == this.protocol;
|
||||
});
|
||||
|
||||
/**
|
||||
* Return the remote address, or when
|
||||
* "trust proxy" is `true` return
|
||||
* the upstream addr.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
req.__defineGetter__('ip', function(){
|
||||
return this.ips[0] || this.connection.remoteAddress;
|
||||
});
|
||||
|
||||
/**
|
||||
* When "trust proxy" is `true`, parse
|
||||
* the "X-Forwarded-For" ip address list.
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ var express = require('../')
|
||||
describe('req', function(){
|
||||
describe('.ips', function(){
|
||||
describe('when X-Forwarded-For is present', function(){
|
||||
describe('when "trust proxies" is enabled', function(){
|
||||
describe('when "trust proxy" is enabled', function(){
|
||||
it('should return an array of the specified addresses', function(done){
|
||||
var app = express();
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('req', function(){
|
||||
})
|
||||
})
|
||||
|
||||
describe('when "trust proxies" is disabled', function(){
|
||||
describe('when "trust proxy" is disabled', function(){
|
||||
it('should return an empty array', function(done){
|
||||
var app = express();
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário