Skip to content

Move haproxy handling to cloudburst network#6390

Merged
valaphee merged 4 commits into
GeyserMC:masterfrom
valaphee:feat/proxy-protocol
May 18, 2026
Merged

Move haproxy handling to cloudburst network#6390
valaphee merged 4 commits into
GeyserMC:masterfrom
valaphee:feat/proxy-protocol

Conversation

@valaphee
Copy link
Copy Markdown
Member

@valaphee valaphee commented May 11, 2026

Copilot AI review requested due to automatic review settings May 11, 2026 07:55
@valaphee valaphee marked this pull request as draft May 11, 2026 07:55
@valaphee valaphee force-pushed the feat/proxy-protocol branch from 904d0c6 to 9bebd25 Compare May 11, 2026 08:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to move HAProxy/forwarded-address handling out of Geyser’s Netty pipeline and into the Cloudburst networking layer by removing Geyser’s custom proxy-protocol decoder/peer/address-mapping code and related rate-limit adjustments.

Changes:

  • Removes Geyser’s HAProxy proxy-protocol decoding pipeline and proxied-address tracking.
  • Refactors upstream address access away from GeyserBedrockPeer and removes Waterdog/HAProxy address propagation paths (currently with TODO stubs).
  • Updates build configuration to use a local Cloudburst RakNet transport JAR and enables mavenLocal() for build-logic resolution.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
core/src/main/java/org/geysermc/geyser/util/LoginEncryptionUtils.java Changes WaterdogPE forwarding to call a now-stubbed upstream address setter (port currently hardcoded to 0).
core/src/main/java/org/geysermc/geyser/session/UpstreamSession.java Switches address source to session.getSocketAddress() and leaves setInetAddress unimplemented (TODO).
core/src/main/java/org/geysermc/geyser/session/SessionManager.java Removes per-IP connection limiting helpers but still maintains per-address counters.
core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java Removes the max-connections-per-address login gate.
core/src/main/java/org/geysermc/geyser/network/netty/proxy/ProxyServerHandler.java Deleted (previous HAProxy PROXY header handler).
core/src/main/java/org/geysermc/geyser/network/netty/proxy/ProxyProtocolDecoder.java Deleted (previous HAProxy PROXY header decoder).
core/src/main/java/org/geysermc/geyser/network/netty/handler/RakGeyserRateLimiter.java Deleted (previous per-IP scaling rate limiter).
core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Removes proxied-address map usage, disables proxy handler insertion (TODO), and changes rate limiter behavior/event fields.
core/src/main/java/org/geysermc/geyser/network/GeyserServerInitializer.java Removes custom peer creation and proxied-address injection.
core/src/main/java/org/geysermc/geyser/network/GeyserBedrockPeer.java Deleted (previous peer wrapper to override “real” vs proxied address).
core/build.gradle.kts Replaces RakNet dependency with an absolute local JAR path.
build-logic/build.gradle.kts Adds mavenLocal() to build-logic repositories.
Comments suppressed due to low confidence (1)

core/build.gradle.kts:56

  • core/build.gradle.kts now depends on a local absolute-path JAR under /home/valaphee/... which will not exist in CI or for other contributors, breaking the build and releases. Replace this with a published Maven coordinate (snapshot repo if needed) or a composite build/includedBuild, and keep the dependency in the version catalog instead of a developer-local file path.
        exclude("net.raphimc", "MinecraftAuth")
    }

    implementation(files("/home/valaphee/Documents/CloudburstMC-Network/transport-raknet/build/libs/transport-raknet-1.0.0.CR3-SNAPSHOT.jar"))

    // Network dependencies we are updating ourselves
    api(libs.netty.handler)
    implementation(libs.netty.codec.haproxy)

    api(libs.netty.transport.native.epoll) { artifact { classifier = "linux-x86_64" } }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/main/java/org/geysermc/geyser/session/UpstreamSession.java Outdated
Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
Comment thread core/src/main/java/org/geysermc/geyser/session/SessionManager.java Outdated
Comment thread build-logic/build.gradle.kts
Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
@valaphee valaphee force-pushed the feat/proxy-protocol branch 5 times, most recently from f963ccf to 94fc29a Compare May 11, 2026 21:59
Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
@onebeastchris onebeastchris added Work in Progress The issue is currently being worked on. PR: Under Review When a PR (particularly a large one) is currently being reviewed to see if it can be merged Upstream Something that needs to be resolved or addressed upstream. PR: Optimization When a PR doesn't necessarily add anything new or fix anything, but improves upon the code labels May 12, 2026
@valaphee valaphee force-pushed the feat/proxy-protocol branch from 94fc29a to 3abfe29 Compare May 16, 2026 07:14
@valaphee valaphee marked this pull request as ready for review May 17, 2026 17:30
Copilot AI review requested due to automatic review settings May 17, 2026 17:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
Copilot AI review requested due to automatic review settings May 18, 2026 12:47
@valaphee valaphee force-pushed the feat/proxy-protocol branch 2 times, most recently from 4704039 to 4268c53 Compare May 18, 2026 12:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
@valaphee valaphee force-pushed the feat/proxy-protocol branch from 4268c53 to e013151 Compare May 18, 2026 12:54
Copilot AI review requested due to automatic review settings May 18, 2026 13:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java:231

  • rakRateLimitingDisabled ? null : new DefaultRakServerThrottle(...) passes null into ServerBootstrap.option(...). Netty ChannelOption values are generally validated as non-null, so this can throw at bootstrap/bind time. Prefer conditionally omitting the RAK_THROTTLE option when rate limiting is disabled (or supplying an explicit no-op throttle implementation if the RakNet API provides one).
            .option(RakChannelOption.RAK_PACKET_LIMIT, rakRateLimitingDisabled ? 0 : rakPacketLimit)
            .option(RakChannelOption.RAK_GLOBAL_PACKET_LIMIT, rakGlobalPacketLimit)
            .option(RakChannelOption.RAK_SERVER_COOKIE_MODE, rakSendCookie ? RakServerCookieMode.ACTIVE : RakServerCookieMode.INVALID)
            .option(RakChannelOption.RAK_PROXY_PROTOCOL, this.geyser.config().advanced().bedrock().useHaproxyProtocol())
            .option(RakChannelOption.RAK_THROTTLE, rakRateLimitingDisabled ? null : new DefaultRakServerThrottle(maxConnectionsPerAddress, 4_000, 3))
            .childHandler(serverInitializer);

Comment thread core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java Outdated
@valaphee valaphee requested a review from onebeastchris May 18, 2026 13:37
Copy link
Copy Markdown
Member

@onebeastchris onebeastchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@valaphee
Copy link
Copy Markdown
Member Author

tested again with TCPShield and ProxyPass with PROXY Protocol Header, worked as expected

@valaphee valaphee merged commit 6b979fa into GeyserMC:master May 18, 2026
2 checks passed
@valaphee valaphee deleted the feat/proxy-protocol branch May 18, 2026 16:24
onebeastchris pushed a commit to onebeastchris/Geyser that referenced this pull request May 20, 2026
lucas-santoro added a commit to lucas-santoro/Geyser that referenced this pull request May 24, 2026
After GeyserMC#6390 moved HAProxy handling into cloudburst-netty,
RakServerChannel#getClientAddress can return null when no PROXY header
has been cached for a sender. This happens on the first packet from a
new sender, an expired session-cache entry, a malformed header, or a
PROXY v2 LOCAL frame (which the upstream RakProxyServerHandler currently
mishandles by passing null source addresses into InetSocketAddress).

Geyser passed that null straight through to onConnectionRequest, where
clientAddress.toString() threw NullPointerException and the connection
was dropped with a noisy stack trace, leaving operators without a useful
diagnostic.

This change:
- Adds an early null check in onConnectionRequest that rejects the
  connection cleanly and logs a WARN per occurrence when
  use-haproxy-protocol is enabled, pointing operators at the most
  likely upstream-proxy misconfiguration. RakNet's existing per-IP and
  global packet rate limiting (RAK_PACKET_LIMIT,
  DefaultRakServerThrottle) caps the realistic log rate.
- Drops pings silently in RakPingHandler when no client address is
  resolved, so the server visibly appears offline instead of leaking
  the proxy's address to ping passthrough.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Optimization When a PR doesn't necessarily add anything new or fix anything, but improves upon the code PR: Under Review When a PR (particularly a large one) is currently being reviewed to see if it can be merged Upstream Something that needs to be resolved or addressed upstream. Work in Progress The issue is currently being worked on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants