CloudburstMC / ProxyPass

MITM proxy tool for Minecraft: Bedrock Edition
GNU Affero General Public License v3.0
132 stars 47 forks source link

Don't use PONG ports #19

Open bundabrg opened 4 years ago

bundabrg commented 4 years ago

This fixes a bedrock server being port forwarded with a different port than configured. For example BDS:19130 and a router with port 19133 forwarding.

If trying to connect using a bedrock client in this config, proxypass will make a single ping to the downstream server, then update its port to that returned in the pong packet (if not -1) and then continue trying to connect.

We simply skip this step and honour the port specified in the config file.

bundabrg commented 4 years ago

I now understand why ProxyPass defaults to this. A device will advertise a different port to represent a "LAN" connection versus an invited connection.

However by enforcing a port lookup we can't ever proxypass to a bedrock device that has port forwards. Perhaps this needs to be an option to differentiate between the two options OR a connection is attempted using both ports in turn till one works.

SupremeMortal commented 4 years ago

This is vanilla behaviour so I think it should be kept. The random port range that vanilla servers generate is the bug here because you don't have any control over what value is set so you can never have the correct ports forwarded. Checkout BDS-1094 for more information.

bundabrg commented 4 years ago

The issue is:

  1. With the existing behaviour its impossible to connect to a Bedrock server behind a port forward using proxypass. It will be required for #13 for example.

  2. With the changed behaviour here, you end up connecting to the correct port but it will not allow it due to ProxyPass not being invited properly.

The random ports are LAN ports (offline) and the set ports are Online ports as far as I can gather.

SupremeMortal commented 4 years ago

The random ports are the ones in which the Minecraft connection takes place. They need to be port forwarded in order for you to be able to to connect to the server.

bundabrg commented 4 years ago

This does not seem to be the case. If I run 'bedrock_server' under linux with the following line in server.properties:

server-port=19131

and port forward ONLY port 19133 from outside to port 19131 it works perfectly fine. I can connect without issue.

EDIT: Perhaps the dedicated server and the games themselves have different logic to how they work. I've been talking about the dedicated server here whereas the game operates how you describe with a facade port simply there to redirect to the proper port.