diff --git a/rcon/battleye/proto.py b/rcon/battleye/proto.py index d09d82e..46e42e2 100644 --- a/rcon/battleye/proto.py +++ b/rcon/battleye/proto.py @@ -50,15 +50,18 @@ class Header(NamedTuple): @classmethod def from_bytes(cls, payload: bytes): """Creates a header from the given bytes.""" + if (size := len(payload)) != 8: + raise ValueError('Invalid payload size', size) + if (prefix := payload[:2].decode('ascii')) != PREFIX: raise ValueError('Invalid prefix', prefix) - if (infix := int.from_bytes(payload[5:6], 'little')) != INFIX: + if (infix := int.from_bytes(payload[6:7], 'little')) != INFIX: raise ValueError('Invalid infix', infix) return cls( - int.from_bytes(payload[2:5], 'little'), - int.from_bytes(payload[6:7], 'little') + int.from_bytes(payload[2:6], 'little'), + int.from_bytes(payload[7:8], 'little') )