mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 07:07:33 +00:00
fix(protocol/battlefield): skip non-response packets (#704)
This commit is contained in:
parent
d3461ffb61
commit
c5d64dedcb
1 changed files with 14 additions and 1 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue