lib/request-extractors/express.js
function extractRemoteAddressFromRequest(req) {

  if (typeof req.header('x-forwarded-for') !== 'undefined') {

    return req.header('x-forwarded-for');
  } else if (isObject(req.connection)) {

    return req.connection.remoteAddress;
  }

  return '';
}
function extractRemoteAddressFromRequest(req) {

  if (typeof req.header('x-forwarded-for') !== 'undefined') {

    return req.header('x-forwarded-for');
  } else if (isObject(req.connection)) {

    return req.connection.remoteAddress;
  }

  return '';
}
function extractRemoteAddressFromRequest ( req ) { if ( typeof req . header ( 'x-forwarded-for' ) !== 'undefined' ) { return req . header ( 'x-forwarded-for' ) ; } else if ( isObject ( req . connection ) ) { return req . connection . remoteAddress ; } return '' ; }
This function checks for the presence of an `x-forwarded-for` header on the
request to check for remote address forwards, if that is header is not
present in the request then the function will attempt to extract the remote
address from the express request object.
@function extractRemoteAddressFromRequest
@param {Object} req - the express request object
@returns {String} - the remote address or, if one cannot be found, an empty
string
This function checks for the presence of an x - forwarded - for header on the request to check for remote address forwards if that is header is not present in the request then the function will attempt to extract the remote address from the express request object .