mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 05:35:56 -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();
|
super();
|
||||||
this.version=version;
|
this.version=version;
|
||||||
this.isServer = !!isServer;
|
this.isServer = !!isServer;
|
||||||
|
this.splitter=framing.createSplitter();
|
||||||
this.setSerializer(states.HANDSHAKING);
|
this.setSerializer(states.HANDSHAKING);
|
||||||
this.packetsToParse={};
|
this.packetsToParse={};
|
||||||
this.serializer;
|
this.serializer;
|
||||||
@ -21,7 +22,6 @@ class Client extends EventEmitter
|
|||||||
this.framer=framing.createFramer();
|
this.framer=framing.createFramer();
|
||||||
this.cipher=null;
|
this.cipher=null;
|
||||||
this.decipher=null;
|
this.decipher=null;
|
||||||
this.splitter=framing.createSplitter();
|
|
||||||
this.decompressor=null;
|
this.decompressor=null;
|
||||||
this.deserializer;
|
this.deserializer;
|
||||||
this.isServer;
|
this.isServer;
|
||||||
@ -51,6 +51,7 @@ class Client extends EventEmitter
|
|||||||
this.deserializer = createDeserializer({ isServer:this.isServer, version:this.version, state: state, packetsToParse:
|
this.deserializer = createDeserializer({ isServer:this.isServer, version:this.version, state: state, packetsToParse:
|
||||||
this.packetsToParse});
|
this.packetsToParse});
|
||||||
|
|
||||||
|
this.splitter.recognizeLegacyPing = state === states.HANDSHAKING;
|
||||||
|
|
||||||
this.serializer.on('error', (e) => {
|
this.serializer.on('error', (e) => {
|
||||||
var parts=e.field.split(".");
|
var parts=e.field.split(".");
|
||||||
|
@ -29,12 +29,12 @@ class Splitter extends Transform {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.buffer = new Buffer(0);
|
this.buffer = new Buffer(0);
|
||||||
|
this.recognizeLegacyPing = false;
|
||||||
}
|
}
|
||||||
_transform(chunk, enc, cb) {
|
_transform(chunk, enc, cb) {
|
||||||
this.buffer = Buffer.concat([this.buffer, chunk]);
|
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.recognizeLegacyPing && this.buffer[0] === LEGACY_PING_PACKET_ID) {
|
||||||
if (this.buffer[0] === LEGACY_PING_PACKET_ID) {
|
|
||||||
// legacy_server_list_ping packet follows a different protocol format
|
// legacy_server_list_ping packet follows a different protocol format
|
||||||
// prefix the encoded varint packet id for the deserializer
|
// prefix the encoded varint packet id for the deserializer
|
||||||
var header = new Buffer(sizeOfVarInt(LEGACY_PING_PACKET_ID));
|
var header = new Buffer(sizeOfVarInt(LEGACY_PING_PACKET_ID));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user