Dinnerbone / mcstatus

A Python class for checking the status of an enabled Minecraft server
http://dinnerbone.com/minecraft/tools/status/
1.11k stars 146 forks source link

Query protocol fixes #146

Closed MeRuslan closed 3 years ago

MeRuslan commented 3 years ago

This library seems to not conform to minecraft query protocol.

This PR fixes inconsistencies and cleans up query packet handling. Tests are provided.

It now queries PocketMine-MP servers, as well as regular java edition servers. Closes #145, properly.

Details on fixes (from https://wiki.vg/Query which seems to be the closest to the truth on minecraft protocol):

  1. There was an extra zero int written to the handshake packet, now it conforms to this: image

  2. Cleaned up request packet generation as well, it all is now handled in one place, rather than doing most of the work in a single method and then adding a padding. It conforms to this: image Functionally not a lot changes.

  3. Querier now generates proper session ids instead of always using 0, which helps readability and is more correct. GameSpot) Query Protocol image

kevinkjt2000 commented 3 years ago

Thanks for the pull request! And nice catch!

As stated the magic number seems to be missing at the start of the handshake packet. It seems the vanilla server has handled this without any issue for a long time, so I'll have to do some thorough testing/review to make sure the existing behavior continues to function.

MeRuslan commented 3 years ago

No, magic number was always there. The issue was an extra 0 in a handshake packet.

kevinkjt2000 commented 3 years ago

Released in v6.1.2 Thanks for the contribution ❤️

MeRuslan commented 3 years ago

Thanks for a prompt review.