
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
proxy-addr
Advanced tools
Determine address of proxied request
$ npm install proxy-addr
var proxyaddr = require('proxy-addr')
Return the address of the request, using the given trust parameter.
The trust argument is a function that returns true if you trust
the address, false if you don't. The closest untrusted address is
returned.
proxyaddr(req, function(addr){ return addr === '127.0.0.1' })
proxyaddr(req, function(addr, i){ return i < 1 })
The trust arugment may also be a single IP address string or an
array of trusted addresses, as plain IP addresses, CIDR-formatted
strings, or IP/netmask strings.
proxyaddr(req, '127.0.0.1')
proxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8'])
proxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0'])
This module also supports IPv6. Your IPv6 addresses will be normalized
automatically (i.e. fe80::00ed:1 equals fe80:0:0:0:0:0:ed:1).
proxyaddr(req, '::1')
proxyaddr(req, ['::1/128', 'fe80::/10'])
proxyaddr(req, ['fe80::/ffc0::'])
This module will automatically work with IPv4-mapped IPv6 addresses
as well to support node.js in IPv6-only mode. This means that you do
not have to specify both ::ffff:a00:1 and 10.0.0.1.
As a convenience, this module also takes certain pre-defined names in addition to IP addresses, which expand into IP addresses:
proxyaddr(req, 'loopback')
proxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64'])
loopback: IPv4 and IPv6 loopback addresses (like ::1 and
127.0.0.1).linklocal: IPv4 and IPv6 link-local addresses (like
fe80::1:1:1:1 and 169.254.0.1).uniquelocal: IPv4 private addresses and IPv6 unique-local
addresses (like fc00:ac:1ab5:fff::1 and 192.168.0.1).When trust is specified as a function, it will be called for each
address to determine if it is a trusted address. The function is
given two arguments: addr and i, where addr is a string of
the address to check and i is a number that represents the distance
from the socket address.
Return all the addresses of the request, optionally stopping at the
first untrusted. This array is ordered from closest to furthest
(i.e. arr[0] === req.connection.remoteAddress).
proxyaddr.all(req)
The optional trust argument takes the same arguments as trust
does in proxyaddr(req, trust).
proxyaddr.all(req, 'loopback')
Compiles argument val into a trust function. This function takes
the same arguments as trust does in proxyaddr(req, trust) and
returns a function suitable for proxyaddr(req, trust).
var trust = proxyaddr.compile('localhost')
var addr  = proxyaddr(req, trust)
This function is meant to be optimized for use against every request.
It is recommend to compile a trust function up-front for the trusted
configuration and pass that to proxyaddr(req, trust) for each request.
$ npm test
$ npm run-script bench
The 'forwarded' npm package parses the X-Forwarded-For header and returns an array of the addresses. It is similar to proxy-addr but does not provide the same level of control over which addresses are considered trustworthy.
The 'ipware' npm package is designed to retrieve the user's IP address from the incoming request, supporting both IPv4 and IPv6. It offers functionality similar to proxy-addr but with a different API and additional features for IP address detection.
FAQs
Determine address of proxied request
The npm package proxy-addr receives a total of 35,997,364 weekly downloads. As such, proxy-addr popularity was classified as popular.
We found that proxy-addr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.