Sha256: 72bbb8047c48c217040bfa42a9e76e43a1fb9d6b6edeced5c772a85a11cbd866

Contents?: true

Size: 641 Bytes

Versions: 15

Compression:

Stored size: 641 Bytes

Contents

/*!
 * forwarded
 * Copyright(c) 2014 Douglas Christopher Wilson
 * MIT Licensed
 */

/**
 * Module exports.
 */

module.exports = forwarded

/**
 * Get all addresses in the request, using the `X-Forwarded-For` header.
 *
 * @param {Object} req
 * @api public
 */

function forwarded(req) {
  if (!req) {
    throw new TypeError('argument req is required')
  }

  // simple header parsing
  var proxyAddrs = (req.headers['x-forwarded-for'] || '')
    .split(/ *, */)
    .filter(Boolean)
    .reverse()
  var socketAddr = req.connection.remoteAddress
  var addrs = [socketAddr].concat(proxyAddrs)

  // return all addresses
  return addrs
}

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
lanes-0.8.0 node_modules/forwarded/index.js
webpack_rails-2.0.1 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-2.0.0 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.3.1 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.3.0 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.2.2 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.2.1 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.2.0 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.1.1 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.1.0 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.0.1 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
webpack_rails-1.0.0 lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js