From 2b3794da7e5dd2a70b0a0f35e533c765fcc38d69 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Wed, 7 Sep 2022 14:21:20 -0400 Subject: [PATCH] Update definition for ChatMessage and CommandExecution (#30) * Update ChatMessage definition, prevent typing in chat from kicking players fixes #24 * Update definition for CommandExecution --- src/protocol/codec.rs | 5 ++++- src/protocol/packets/c2s.rs | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/protocol/codec.rs b/src/protocol/codec.rs index 0054372..062896f 100644 --- a/src/protocol/codec.rs +++ b/src/protocol/codec.rs @@ -200,7 +200,10 @@ impl Decoder { .context("decoding packet after decompressing")?; ensure!( decompressed.is_empty(), - "packet contents were not read completely" + format!( + "packet contents were not read completely, {} remaining bytes", + decompressed.len() + ) ); packet } else { diff --git a/src/protocol/packets/c2s.rs b/src/protocol/packets/c2s.rs index 735183f..5237e10 100644 --- a/src/protocol/packets/c2s.rs +++ b/src/protocol/packets/c2s.rs @@ -122,9 +122,16 @@ pub mod play { } } + def_struct! { + MessageAcknowledgmentList { + entries: Vec, + } + } + def_struct! { MessageAcknowledgment { - entry: Option, + last_seen: MessageAcknowledgmentList, + last_received: Option, } } @@ -135,11 +142,21 @@ pub mod play { } } + def_struct! { + ArgumentSignatureEntry { + name: BoundedString<0, 16>, + signature: Vec, + } + } + def_struct! { CommandExecution { - command: String, // TODO: bounded? - // TODO: timestamp, arg signatures + command: BoundedString<0, 256>, + timestamp: u64, + salt: u64, + arg_sig: Vec, signed_preview: bool, + acknowledgement: MessageAcknowledgment, } } @@ -150,6 +167,7 @@ pub mod play { salt: u64, signature: Vec, signed_preview: bool, + acknowledgement: MessageAcknowledgment, } }