Pugmatt / BedrockConnect

Join any Minecraft Bedrock Edition server IP on Xbox One, Nintendo Switch, and PS4/PS5
GNU General Public License v3.0
1.45k stars 164 forks source link

Resolve address to IP before transferring client to selected custom server #398

Closed MonsterDruide1 closed 1 year ago

MonsterDruide1 commented 1 year ago

What happened?

Short version: When using the hostname of a featured server in the custom_servers.json, the client gets redirected to the server selection screen again.

Long version: I want to only add a subset of featured servers to the custom server list, along with some new ones. However, using the hostname of the featured server in the server list means that the client will resolve the hostname to IP again, getting caught by the DNS setup, and being redirected to the server list - again.

Expected Behaviour?

The client should be sent to the expected server instead.

Steps to reproduce.

  1. Create (and configure) a custom_servers.json containing for example "Mineplex", with the address pointing towards mco.mineplex.com.
  2. Set up the normal DNS, meaning that Mineplex will also get caught when trying to join.
  3. Join the server selector, then select Mineplex from the list.
  4. After some loading, you'll be sent back to the server selection screen.

Screenshots/Videos

-

Minecraft Bedrock Version

(doesn't matter)

Console

(doesn't matter)

Additional Context

I'd see the issue in the following line: https://github.com/Pugmatt/BedrockConnect/blob/38a7a369963ed3430a5b13ffbd56c94fb7394203/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/listeners/PacketHandler.java#L140

Here, the client just gets sent a transfer packet pointing to the address listed in the json config file. It would be better if this could be resolved by the BedrockConnect server first, allowing to resolve domains blocked by the DNS, then only sending the IP to the client.

The issue can currently be worked around by hardcoding the IP to the servers instead, but ... that's cheating.

MonsterDruide1 commented 1 year ago

Update: Hardcoding the IP to servers manually is not really a solution, as those get rotated more quickly than I'm willing to update manually.

CrafterPika commented 1 year ago

Update: Hardcoding the IP to servers manually is not really a solution, as those get rotated more quickly than I'm willing to update manually.

indeed, it led me back in Dec 2021 to use Java's InetAdress to get the IP address (https://github.com/Pugmatt/BedrockConnect/pull/249/commits/fc4e2ecfb703ed04d4b07a025ddf99ba891633a5). The problem probably could be fixed by using an library that can configured to allways force it through a custom dns server.

CrafterPika commented 1 year ago

I just simply lacked the java knowledge. I didn’t know how to use maven and stuff at that time.

MonsterDruide1 commented 1 year ago

Yes, something like this would be the solution - as pointed out by the line I linked above, this should also be done for domains fetched from the config file. I just haven't gotten around to implement something like this myself, so if you have the time for it feel free to just wrap this in a check+domain resolution.

MonsterDruide1 commented 1 year ago

The main problem isn't even trying to get around the DNS, as the code linked above is being executed on the server hosting the DNS - so it doesn't get resolved by the spoofed DNS, but the right one the hosting server uses, meaning it gets resolved to the right server here. What's currently happening is that the domain name is being sent to the client (Minecraft), which tries to look up the domain to IP itself - and in turn gets caught by the DNS again, as "intended". Just checking for the "address", see if it is a domain or IP and resolving it in this program before sending it to the client will totally solve this issue.

Pugmatt commented 1 year ago

Latest release, 1.33, should now allow this to be possible. In your BedrockConnect launch command, add the argument fetch_ips=true.

MonsterDruide1 commented 1 year ago

Yes, this works just like expected. Thanks for taking the time to implement it!