pbojinov / request-ip

A Node.js module for retrieving a request's IP address on the server.
https://npmjs.com/package/request-ip
MIT License
823 stars 102 forks source link

Cloudflare fallback headers and updates eslint and prettier configs #53

Closed pbojinov closed 2 years ago

pbojinov commented 2 years ago

Fixes https://github.com/pbojinov/request-ip/issues/46

Kikobeats commented 2 years ago

@pbojinov According to CloudFlare docs, there is another header worth it to be supported:

The three options available for configuring Pseudo IPv4 are:

  • Off: This is the default value.
  • Add Header: Cloudflare automatically adds the Cf-Pseudo-IPv4 header with a Class E IPv4 address hashed from the original IPv6 address.
  • Overwrite Headers - Cloudflare overwrites the existing Cf-Connecting-IP and X-Forwarded-For headers with a pseudo IPv4 address while preserving the real IPv6 address in a Cf-Connecting-IPv6 header.

so if you add support Cf-Connecting-IPv6 as well, that will cover all the possibilities 🙂

pbojinov commented 2 years ago

@Kikobeats thanks for pointing that out. I’ll add that as well.