Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added HAProxy support #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LightningReflex
Copy link

Cool I added support for HAProxy, so if the server has HAProxy enabled, it can still be pinged using this program by setting "HAProxy: true"

@woodendoors7
Copy link
Owner

I will have to fix some things about that PR, we stopped using buffers (and I am on a holiday), though interestingly I haven't heard of HAproxy yet, I assume you need to register in the proxy first by sending those headers? Have you tested it already? Also it seems like it only handles ipv4 rn, and does Minecraft send a HAproxy header as well, is it custom in its code? + what is the purpose of the header? Can't find much about it when I google, it looks like haproxy can be used as a normal tcp proxy?

@LightningReflex
Copy link
Author

LightningReflex commented Dec 26, 2024

Hey, thanks for the response, by default Minecraft doesn't support the HAProxy header, but paper's added support for it since 2022.

HAProxy is essentially a load-balancing system, but it causes the user's IP-address to get lost, and replaced with the load-balancer's IP. That's where an HAProxyMessage comes in, this packet contains the original IP address of the user, and allows you to preserve the IP address when HAProxy is used.

Now, when you enable the HAProxy option on paper (config/paper-global.yml ->proxies.proxy-protocol: true), this causes any normal connection (including status pings) directly to the server without the HAProxyMessage to stop functioning (unhandled, no response).

What I added in the PR made it so the status ping also sends a HAProxyMessage which allows the status ping to be handled correctly by paper.

I also think (I'm not too sure) that ipv6 should also work, the code is just set to ipv4 due to the fact that I'm passing through 127.0.0.1 twice (which should instead actually be the server's ip for destIP and the pinger's ip for sourceIP, but those are more difficult to get, and seems unnecessary as Minecraft doesn't seem even do anything with the IP anyways when it's just a status ping).

I have tested this on paper/purpur, but not on vanilla (as HAProxyMessages aren't supported on it), so I'm unsure what it would produce if you attempted to send an HAProxyMessage to it.

If you need a better explanation, feel free to dm me on discord, I've already friended you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants