Repository navigation
Add Simple Proxy Protocol support for trusted UDP proxies - #4508
Open
jakemmarsh wants to merge 1 commit into
Open
jakemmarsh wants to merge 1 commit into
jakemmarsh wants to merge 1 commit into
Conversation
A UDP proxy in front of ACE (Cloudflare Spectrum, a DDoS shield, a relay) makes every proxied player arrive from the proxy's address, so the per IP session limit, the unlimited sessions allowlist, account IP addresses and admin displays all see the proxy. The new Network.TrustedProxyAddresses setting lists proxies that prepend a Simple Proxy Protocol header to every datagram (https://developers.cloudflare.com/spectrum/reference/simple-proxy-protocol-header/). - Datagrams from a trusted proxy must start with a valid header or they are dropped. An ACE packet can legitimately start with the magic bytes, so the header is never stripped from other addresses: their datagrams are processed exactly as before. - Sessions stay keyed by the proxy endpoint. Session.ClientAddress is the client address from the header (or the endpoint address when not proxied) and is used for MaximumAllowedSessionsPerIPAddress, AllowUnlimitedSessionsFromIPAddresses, the unique connection count, account create/last login IP, /showsession and /forcelogoff. - Packets for a proxied session whose header names a different client address are dropped. - Packets sent to a proxied session, including login rejections, carry the header received on the connection they are sent on. Empty by default, which leaves behaviour unchanged.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When players connect through a UDP proxy, ACE sees every one of them at the proxy's address. That covers Cloudflare Spectrum, DDoS protection services, and relays such as a WebSocket-to-UDP bridge for a browser client. As a result,
MaximumAllowedSessionsPerIPAddress,AllowUnlimitedSessionsFromIPAddresses, account create/last-login IPs and the admin session displays all see the proxy. A per-IP limit then either caps all proxied players together or can be bypassed by mixing direct and proxied connections.This adds support for Simple Proxy Protocol (SPP), the format Cloudflare Spectrum uses for UDP. A proxy prepends a 38-byte header with the client's address to every datagram, and the server echoes the header on its replies.
Config
Empty by default, which leaves behaviour unchanged.
Behaviour when an address is listed
0x56ECas the low half of a sequence number), and a direct client must not be able to claim another address. Datagrams from any other address are processed exactly as before.Session.ClientAddressis the address from the header, or the endpoint's address when not proxied.GetUniqueSessionEndpointCount, account create/last-login IP, and/showsessionand/forcelogoff, which also show "via proxy".ClientPacket.UnpackandServerPacket.CreateReadyToSendPackettake an optional offset, so the header is handled without copying.Testing
SimpleProxyProtocolTests, 10 tests):VerifyCRCMaximumAllowedSessionsPerIPAddress: 1and full clients through an SPP relay.TrustedProxyAddresses:Login Request from 203.0.113.2:0 via proxy … rejected, and the client got the normal server-full message.account.last_Login_I_P/create_I_Pheld the real addresses.CanParseStarterGearJsonfails in my environment (arm64 output path) on master as well; everything else that doesn't need a database passes.