[SPIGOT-6913] Floodgate Players can't connect over IPv6 behind BungeeCord with ip_forward Created: 26/Jan/22 Updated: 27/Jan/22 |
|
| Status: | Open |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Bennet Becker | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | spigot | ||
| Environment: |
Dual mode Java/Bedrock server behind BungeeCord with GeyserMC (Bedrock translation layer) and Floodgate (Plugin to allow Geyser connections, player account linking and provide some interoperability with Plugins like AntiCheat) installed. |
||
| Version: | CraftBukkit version 3413-Spigot-862678e-13670b4 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) |
| Plugin: | Floodgate |
| Guidelines Read: | Yes |
| Description |
|
I found a problem/bug when connecting over IPv6 to a server with floodgate running behind a BungeeCord/Geyser proxy. When the client tries to connect, he immediately gets kicked with the message: Kicked whilst connecting to server: If you wish to use IP forwarding, please enable it in your BungeeCord config as well! On the Proxy "ip_forward" is true and on the server "bungeecord" is true as well. This only happens with IPv6 for bedrock players. It doesn't with IPv4 in any case and also not with java players on IPv6. Digging down in the source code I found "HOST_PATTERN" in "net/minecraft/network/protocol/handshake/PacketHandshakingInSetProtocol.java" to be the problem. Because if an IPv6 java player logs in the log locks like this [Server thread/INFO]: Bennet96[/[2003:d4:df0d:b801:6e7e:a7a4:44e:3280]:56047] logged in with entity id 15446 at ([world]-220.7278616902495, 122.78937476759972, 74.67083019292772) And with a bedrock IPv6 player like thisĀ [Server thread/INFO]: /[2003:d4:df12:c901:d001:2408:564e:fd99%0]:41753 lost connection: If you wish to use IP forwarding, please enable it in your BungeeCord config as well! When the bedrock player connects, the forwarded IP address has the zone identifier included, which is legal by RFC6874 but not covered by the HOST_PATTERN regex. The zone identifier seams to present by default when parsing IP addresses with java because it also appears for java player in the Bungee logs, but Bungee normally seams to truncate it before sending it of in the Handshake packet. It reemerges for Bedrock players because Floodgate intercepts the packet and replaces it with the appropriate value for the Bedrock player (see here). It didn't found out where exactly they get the IP from but I assume it is in some way parsed as java.net.InetAddress so it includes the zone identifier again. I know, strictly speaking this might not be a Spigot Bug, but one of another plugin, but they abide by the rules of how an IPv6 address should look like, so I think that it might needs fixing here. But I would also understand if a fix in the plugin is preferred. In this case I would open an issue there tomorrow. Looking at RFC6874 section 2 explicitly states, that there is specific character set for that identifier.
So a regex for the whole IP is probably not very useful. Which means that if a validity check is desirable then it could be an option trying to parse it as java.net.InetSocketAddress or java.net.InetAddress or to truncate the address at the "%" and apply the regex to the first part. But all 3 options seam kind of bad because an InetSocketAddress apperently always makes a DNS lookup, an InetAddress takes the IP as bytes and the regex (in its current from) still allows malformed addresses with too few or too many block or too long blocks etc. And if half a check is good enough that might not check it at all and assume that the data Bungee sends is probably correct. A 4th and 5th option would be to use the Google Guava library to parse it with com.google.common.net.InetAddresses#forString but I'm not sure how hard it would be to use an external library it a patched Mojang file or implementing a full on IP parser there, but catching each edge case for every possible IP notation is notoriously a pain in the neck. |
| Comments |
| Comment by Bennet Becker [ 27/Jan/22 ] |
|
Ok I get that. And I agree that the identifier would usually be useless for Spigot. But I think it would be better to keep other protocol definitions in mind when using the protocol's identifiers. But I also see why this might be difficult or a problem here, with a protocol as complex as IP. I filled the Issue over at their Github Repo, referencing this Issue here. Maybe to prevent this Issue from reemerging with other plugins again, it might be an option to explicitly truncate the identifier again before matching it to HOST_PATTERN in Spigot? |
| Comment by md_5 [ 26/Jan/22 ] |
|
Floodgate issue imo, because a zone identifier is not useful information to the Spigot server — unless it is on the same machine as bungee it would not have the same ethernet interface as bungee. |