Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

addr

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addr

Get the remote address of a request, with reverse-proxy support

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

addr

Get the remote address of a request, with reverse-proxy support

build status

Usage

$ npm install addr

addr(req, [proxies])

  • req: an http.ServerRequest object.
  • proxes: an array of IP addresses of trusted proxies. If specified and the request doesn't come from one of these addresses, the X-Forwarded-For header will not be honored.
  • Returns: Remote IP address of the request, taken from the X-Forwarded-For header if it exists and the request is coming from a trusted proxy.

Example

var addr = require('addr')
  , http = require('http')
  , port = 3000
  , proxies = ['127.0.0.1']
  ;

http.createServer(function(req, res) {
  res.writeHead(200, {'Content-Type': 'application/json'});
  res.write(JSON.stringify({addr: addr(req, proxies)}));
  res.end();
}).listen(port, function() {
  console.log('test server running on port ' + port);
});

License

MIT

Keywords

FAQs

Package last updated on 25 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc