PrismarineJS / node-minecraft-protocol

Parse and serialize minecraft packets, plus authentication and encryption.
https://prismarinejs.github.io/node-minecraft-protocol/
BSD 3-Clause "New" or "Revised" License
1.22k stars 239 forks source link

Cannot join server if handshake packet contains 0xfe #685

Open Hadron67 opened 4 years ago

Hadron67 commented 4 years ago

This problem is related to the processing of legacy server list ping packet. As written in framing.js

if (this.recognizeLegacyPing && this.buffer[0] === LEGACY_PING_PACKET_ID) {

and client.js

this.splitter.recognizeLegacyPing = state === states.HANDSHAKING

A packet starting with 0xfe would be regarded as legacy ping packet. However, my situation is that this 0xfe is not legacy ping packet id, but part of the varint indicating the packet length, so the handshake packet is ignored and player just get timed out. Because i was running this server behind a BungeeCord proxy with ip forwarding turned on, the handshake packet could be lengthy, thus may cause the above problem. My temporary workaround is just changing the corresponding line in framing.js to

if (false && this.buffer[0] === LEGACY_PING_PACKET_ID) {

and it worked. Is there any less hacky way to fix this?

rom1504 commented 4 years ago

I guess we could do a better check for legacy ping packet by trying to read what comes after. Feel free to try some things