Added req.ip

Esse commit está contido em:
TJ Holowaychuk
2012-05-29 18:46:07 -07:00
commit d84d0b69ef
2 arquivos alterados com 15 adições e 2 exclusões
+13
Ver Arquivo
@@ -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
Ver Arquivo
@@ -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();