RealIP icon indicating copy to clipboard operation
RealIP copied to clipboard

Protocol Documentation

Open gudenau opened this issue 2 years ago • 9 comments

I would like to create a Fabric mod to support TCPShield so I could host a Fabric server protected by TCP Shield. I am not familiar very with the Bukkit stack or the plugins that you depend on, it would be easier to create a mod for this from a protocol specification than figuring out how the plugin works.

gudenau avatar Mar 05 '22 22:03 gudenau

Why would you need a mod? The server handles validating the connections, not the client.

DylanKeir avatar Mar 05 '22 22:03 DylanKeir

The server would need a mod to get the correct IP addresses.

gudenau avatar Mar 05 '22 23:03 gudenau

Ah you mean a plugin on the server side, gotcha. You can view how we verify connections here: https://github.com/TCPShield/RealIP/blob/master/src/main/java/net/tcpshield/tcpshield/TCPShieldPacketHandler.java#L89

Essentially, we send a custom hostname from our proxies in the form of "hostname//ip:port//timestamp//signature", the timestamp and signature are used to validate the connection is coming from our proxies to stop IP forging & replay attacks. The IP is then used to replace the TCPShield proxy IP for the player, same with the hostname.

DylanKeir avatar Mar 05 '22 23:03 DylanKeir

To be clear because some names are inconsistent between different MC namespaces: You mean the packet that is sent to the server in the first stage of a client connecting?

gudenau avatar Mar 05 '22 23:03 gudenau

https://github.com/TCPShield/RealIP/blob/master/src/main/java/net/tcpshield/tcpshield/TCPShieldPacketHandler.java#L94

Also this shows that you use /// instead of //.

gudenau avatar Mar 05 '22 23:03 gudenau

Yes, the hostname packet is how we send the data to the server. Yes, I mean triple slash, not double.

Hostname packet: https://wiki.vg/Protocol#Handshake

DylanKeir avatar Mar 05 '22 23:03 DylanKeir

This should be a super quick mod to make then. That is super simple.

gudenau avatar Mar 05 '22 23:03 gudenau

My mod is available here if you would like to verify that it does what it is supposed to do.

Since the protocol is so simple I would recommend documenting it in the README somewhere.

gudenau avatar Mar 06 '22 01:03 gudenau

Bumping this issue up, hoping this mod gets added into the README for other users to find since it was a tad difficult for me personally.

Thanks for this excellent mod as well, gudenau <3

JosTheDude avatar Mar 12 '23 01:03 JosTheDude