mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-27 21:24:25 -04:00
Legacy ping is only allowed when in HANDSHAKING state (otherwise, varint packet length 254)
This commit is contained in:
parent
4840ffe7b1
commit
9b824b5b88
@ -14,6 +14,7 @@ class Client extends EventEmitter
|
||||
super();
|
||||
this.version=version;
|
||||
this.isServer = !!isServer;
|
||||
this.splitter=framing.createSplitter();
|
||||
this.setSerializer(states.HANDSHAKING);
|
||||
this.packetsToParse={};
|
||||
this.serializer;
|
||||
@ -21,7 +22,6 @@ class Client extends EventEmitter
|
||||
this.framer=framing.createFramer();
|
||||
this.cipher=null;
|
||||
this.decipher=null;
|
||||
this.splitter=framing.createSplitter();
|
||||
this.decompressor=null;
|
||||
this.deserializer;
|
||||
this.isServer;
|
||||
@ -51,6 +51,7 @@ class Client extends EventEmitter
|
||||
this.deserializer = createDeserializer({ isServer:this.isServer, version:this.version, state: state, packetsToParse:
|
||||
this.packetsToParse});
|
||||
|
||||
this.splitter.recognizeLegacyPing = state === states.HANDSHAKING;
|
||||
|
||||
this.serializer.on('error', (e) => {
|
||||
var parts=e.field.split(".");
|
||||
|
@ -29,12 +29,12 @@ class Splitter extends Transform {
|
||||
constructor() {
|
||||
super();
|
||||
this.buffer = new Buffer(0);
|
||||
this.recognizeLegacyPing = false;
|
||||
}
|
||||
_transform(chunk, enc, cb) {
|
||||
this.buffer = Buffer.concat([this.buffer, chunk]);
|
||||
|
||||
// TODO: only decode if in handshake state! important since 254 is a valid varint (encodes as 0xfe 0x01), packet length
|
||||
if (this.buffer[0] === LEGACY_PING_PACKET_ID) {
|
||||
if (this.recognizeLegacyPing && this.buffer[0] === LEGACY_PING_PACKET_ID) {
|
||||
// legacy_server_list_ping packet follows a different protocol format
|
||||
// prefix the encoded varint packet id for the deserializer
|
||||
var header = new Buffer(sizeOfVarInt(LEGACY_PING_PACKET_ID));
|
||||
|
Loading…
x
Reference in New Issue
Block a user