-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ip)!: Rework priority of IP detection (#799)
Closes #798 This is a breaking change to how we detect IP from headers. I've changed it to prefer IP values on a "request-like" object, such as `ip` or `socket.remoteAddress`. I also prioritized `CF-Connecting-IP` and `Fly-Client-IP` over `X-Forwarded-For` headers but they are only used when actually deployed to Cloudflare or Fly respectively. We'll want to guard other platforms where an environment variable is detectable but I couldn't others in some cursory research. Additionally, we now iterate the `X-Forwarded-For` IPs in reverse since the first items are the easiest to spoof. For example, a user can just submit whatever IP address as the first entry in `X-Forwarded-For` along with their request. All of the above should be documented via code comments too. Oh, and I removed the `CF-Pseudo-IPv4` header because it will always be wrong since Cloudflare generates a non-public IP address as the translation of the IPv6 so we're preferring `CF-Connecting-IPv6` correctly now.
- Loading branch information
1 parent
a85d18c
commit 1df6291
Showing
4 changed files
with
112 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters