Skip to content

Conversation

@alfonsojon
Copy link

backport of beta 1.8 server ping to beta 1.7.3

@alfonsojon
Copy link
Author

resolves #12

@alfonsojon alfonsojon changed the title Introduce server ping Introduce beta 1.8 Packet254GetInfo for server ping Nov 21, 2024
Copy link
Contributor

@moderatorman moderatorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's a good idea to be remapping NMS code, as there are plenty of plugins that need to use reflection to access internal Minecraft classes, and changing the names would break those entirely. I can't say for sure if this would break any plugins, but all the same I reckon it would be better left alone.

I would like for other contributors to comment on these changes before I approve and merge them, and I'm also probably going to DM Johny to review this as well.

@alfonsojon
Copy link
Author

alfonsojon commented Nov 23, 2024

it seems this would not resolve adding servers to lists as from what I can tell, Planet Minecraft is not using the server ping feature but rather the query port 25565, which is a whole different animal

After speaking with a Planet Minecraft employee, I found that this was inaccurate & rather caused by their specific implementation of the server ping.

@RhysB RhysB self-requested a review November 23, 2024 02:29
@RhysB
Copy link
Member

RhysB commented Nov 23, 2024

Carried out some testing with this pull request and it appears to work as expected with B1.8 clients, however, I have noted that large errors are printed in consolse when a modern client (1.21) attempts to query data. Likely this needs to be less verbose as this could spam consoles of servers.
image

@alfonsojon
Copy link
Author

alfonsojon commented Nov 24, 2024

I checked with a CraftBukkit b1.8.1 server and can validate that the bad packet ID 5 error is there, but it doesn't throw a NullPointerException due to string length. Similar issue though slightly less verbose.

00:30:24 [SEVERE] java.io.IOException: Bad packet id 5

00:30:24 [SEVERE]       at net.minecraft.server.Packet.a(Packet.java:73)

00:30:24 [SEVERE]       at net.minecraft.server.NetworkManager.h(NetworkManager.java:149)

00:30:24 [SEVERE]       at net.minecraft.server.NetworkManager.c(NetworkManager.java:263)

00:30:24 [SEVERE]       at net.minecraft.server.NetworkReaderThread.run(SourceFile:77)

00:30:25 [INFO] Disconnecting /127.0.0.1:50630: Protocol error
00:30:25 [INFO] /127.0.0.1:50630 lost connection
00:30:38 [SEVERE] java.io.IOException: Bad packet id 5

00:30:38 [SEVERE]       at net.minecraft.server.Packet.a(Packet.java:73)

00:30:38 [SEVERE]       at net.minecraft.server.NetworkManager.h(NetworkManager.java:149)

00:30:38 [SEVERE]       at net.minecraft.server.NetworkManager.c(NetworkManager.java:263)

00:30:38 [SEVERE]       at net.minecraft.server.NetworkReaderThread.run(SourceFile:77)

00:30:38 [INFO] Disconnecting /127.0.0.1:58168: Protocol error

@alfonsojon
Copy link
Author

Pre-Netty Rewrite

Protocol 17 - 23 (b1.8 - 1.1)

  • Ping works, attempting to join results in Outdated server! I'm still on Beta 1.7.3 on client & server.

Protocol 28 - 29 (1.2 - 1.2.5)

  • Ping works, attempting to join results in the following error on the client Internal exception: java.net.SocketException: Connection reset and the following error in the server console:
[SEVERE] java.io.IOException: Received string length longer than maximum allowed (34 > 32)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:165)
[SEVERE]       at net.minecraft.server.Packet2Handshake.a(Packet2Handshake.java:18)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:110)
[SEVERE]       at net.minecraft.server.NetworkManager.g(NetworkManager.java:180)
[SEVERE]       at net.minecraft.server.NetworkManager.c(NetworkManager.java:332)
[SEVERE]       at net.minecraft.server.NetworkReaderThread.run(NetworkReaderThread.java:37)

Protocol 39 (1.3-1.3.2)

  • Ping works, attempting to join results in the following error on the client Internal exception: java.net.SocketException: Connection reset and the following error in the server console:
[SEVERE] java.io.IOException: Received string length longer than maximum allowed (9984 > 32)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:165)
[SEVERE]       at net.minecraft.server.Packet2Handshake.a(Packet2Handshake.java:18)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:110)
[SEVERE]       at net.minecraft.server.NetworkManager.g(NetworkManager.java:180)
[SEVERE]       at net.minecraft.server.NetworkManager.c(NetworkManager.java:332)
[SEVERE]       at net.minecraft.server.NetworkReaderThread.run(NetworkReaderThread.java:37)

Protocol 47 - 61 (1.4 - 1.5.2)

  • Ping works, client incorrectly detects the server is running Minecraft 1.3. Joining is not possible.

Protocol 72 - 78 (1.6 - 1.6.2)

  • Ping does not work, following error appears in the server console:
[SEVERE] java.io.IOException: Received string length longer than maximum allowed (9984 > 32)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:165)
[SEVERE]       at net.minecraft.server.Packet2Handshake.a(Packet2Handshake.java:18)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:110)
[SEVERE]       at net.minecraft.server.NetworkManager.g(NetworkManager.java:180)
[SEVERE]       at net.minecraft.server.NetworkManager.c(NetworkManager.java:332)
[SEVERE]       at net.minecraft.server.NetworkReaderThread.run(NetworkReaderThread.java:37)

Post-Netty Rewrite

Protocol 0+ (1.7 - modern)

  • Ping does not work, the following info appears in the server console: `[INFO] Bad packet id: 23

@alfonsojon
Copy link
Author

After testing with a local instance of CraftBukkit 1185, I can confirm this behavior is identical in both Project Poseidon and CraftBukkit, so a custom solution will need to be ported.

This is the output I get from trying to ping a b1.8.1 server running CraftBukkit 1185 using a Minecraft 1.6.4 client:

[SEVERE] java.io.IOException: Received string length longer than maximum allowed (19712 > 16)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:134)
[SEVERE]       at net.minecraft.server.Packet1Login.a(SourceFile:38)
[SEVERE]       at net.minecraft.server.Packet.a(Packet.java:81)
[SEVERE]       at net.minecraft.server.NetworkManager.h(NetworkManager.java:149)
[SEVERE]       at net.minecraft.server.NetworkManager.c(NetworkManager.java:263)
[SEVERE]       at net.minecraft.server.NetworkReaderThread.run(SourceFile:77)

@alfonsojon
Copy link
Author

alfonsojon commented Dec 16, 2024

This behavior is also experienced when pinging a vanilla Minecraft b1.8.1 server using a Minecraft 1.6.4 client. This behavior does match vanilla Minecraft beta 1.8's ping behavior. I have not been able to reproduce the NPE caused by pinging with a modern client version

java.io.IOException: Received string length longer than maximum allowed (19712 > 16)
        at in.a(SourceFile:191)
        at la.a(SourceFile:38)
        at in.a(SourceFile:145)
        at ma.h(SourceFile:190)
        at ma.c(SourceFile:10)
        at ta.run(SourceFile:77)
java.lang.NullPointerException: Cannot invoke "java.net.Socket.getInetAddress()" because "<parameter1>" is null
        at dr.a(SourceFile:63)
        at fi.a(SourceFile:156)
        at db.a(SourceFile:16)
        at ma.b(SourceFile:272)
        at fi.a(SourceFile:46)
        at dr.a(SourceFile:94)
        at net.minecraft.server.MinecraftServer.h(SourceFile:373)
        at net.minecraft.server.MinecraftServer.run(SourceFile:302)
        at ce.run(SourceFile:417)

@RhysB RhysB marked this pull request as draft December 22, 2024 08:42
@RhysB RhysB added enhancement New feature or request help wanted Extra attention is needed labels Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants