From c5d64dedcbf81f6219ae973d876fbf0f41acefff Mon Sep 17 00:00:00 2001 From: cetteup <17167062+cetteup@users.noreply.github.com> Date: Sun, 1 Jun 2025 17:23:04 +0200 Subject: [PATCH] fix(protocol/battlefield): skip non-response packets (#704) --- protocols/battlefield.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/protocols/battlefield.js b/protocols/battlefield.js index d6b6568..389c700 100644 --- a/protocols/battlefield.js +++ b/protocols/battlefield.js @@ -146,8 +146,21 @@ export default class battlefield extends Core { decodePacket (buffer) { if (buffer.length < 8) return false const reader = this.reader(buffer) - reader.uint(4) // header + const header = reader.uint(4) const totalLength = reader.uint(4) + // Venice Unleashed servers "broadcast" in-game events to any connected rcon client + // If we get such a non-response packet, skip it and decode any remaining data + // Note: We will receive the broadcast ticket again next time the socket receives data, as data is concatenated + if (!(header & 0x40000000)) { + // Skip total length minus already read bytes (4 header + 4 length) + reader.skip(totalLength - 8) + if (reader.done()) { + this.logger.debug('Skipping packet, type mismatch') + return + } else { + return this.decodePacket(reader.rest()) + } + } if (buffer.length < totalLength) return false this.logger.debug('Expected ' + totalLength + ' bytes, have ' + buffer.length)