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

clientHandshakeAddress is unused when constructing ClientIntention packet #338

Closed
mat-1 opened this issue Dec 23, 2024 · 2 comments
Closed

Comments

@mat-1
Copy link

mat-1 commented Dec 23, 2024

Setting the wildcard-domain-handling to INTERNAL and connecting to asdf\x07localhost:25566\x071.20.4 results in the client connecting to 127.0.0.1:25566 and sending the hostname in the intention packet as localhost. The expected behavior is that it would send asdf as the hostname instead.

This seems to be because the clientHandshakeAddress variable that's set to the first argument you passed, is never used when constructing the ClientIntention packet to send:

if (serverAddress instanceof InetSocketAddress inetSocketAddress) {
address = inetSocketAddress.getHostString();
port = inetSocketAddress.getPort();
} else {
address = AddressUtil.toString(serverAddress);
port = 25565;
}

The correct code here would be something like

final String address = clientHandshakeAddress.getHost();
final int port = clientHandshakeAddress.getPort();

(I tested it, it does work as expected).

Though, clientHandshakeAddress can be null if it's invalid, so I guess it should show an error or use the old code as a fallback or something in that case.

@RaphiMC
Copy link
Member

RaphiMC commented Dec 23, 2024

ViaProxy never sends the original handshake address to the server, as that would be the wrong behaviour and easily blockable by servers (And some, especially Anti-DDoS provider even do that already). Instead it replaces it with the configured target address which results in it sending the same data to the server as a vanilla client connecting directly to the server.

The point of passing the original handshake address (asdf in your example) is purely for ViaProxy internal handling. An example of its usage is the transfer packet handler. The transfer packet handler rewrites the target address of incoming transfer packets to the client handshake address, so the client reconnects to ViaProxy instead of connecting to the target server directly.

@RaphiMC RaphiMC closed this as completed Dec 23, 2024
@mat-1
Copy link
Author

mat-1 commented Dec 23, 2024

Oh, I see...

I will note that it would be a little useful to be able to modify the connection IP address independently from the hostname sent in the intention packet, as it's possible for servers to have special behavior for hostnames that aren't resolvable. But to be fair, I can't think of any real servers that do this that wouldn't already be covered by the existing splitting by \0. It's not a massive deal, I appreciate your response. <3

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

No branches or pull requests

2 participants