Skip to content

Commit

Permalink
Update definition for ChatMessage and CommandExecution (#30)
Browse files Browse the repository at this point in the history
* Update ChatMessage definition, prevent typing in chat from kicking players

fixes #24

* Update definition for CommandExecution
  • Loading branch information
dyc3 authored Sep 7, 2022
1 parent ce02b50 commit 2b3794d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/protocol/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ impl<R: AsyncRead + Unpin> Decoder<R> {
.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 {
Expand Down
24 changes: 21 additions & 3 deletions src/protocol/packets/c2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,16 @@ pub mod play {
}
}

def_struct! {
MessageAcknowledgmentList {
entries: Vec<MessageAcknowledgmentEntry>,
}
}

def_struct! {
MessageAcknowledgment {
entry: Option<MessageAcknowledgmentEntry>,
last_seen: MessageAcknowledgmentList,
last_received: Option<MessageAcknowledgmentEntry>,
}
}

Expand All @@ -135,11 +142,21 @@ pub mod play {
}
}

def_struct! {
ArgumentSignatureEntry {
name: BoundedString<0, 16>,
signature: Vec<u8>,
}
}

def_struct! {
CommandExecution {
command: String, // TODO: bounded?
// TODO: timestamp, arg signatures
command: BoundedString<0, 256>,
timestamp: u64,
salt: u64,
arg_sig: Vec<ArgumentSignatureEntry>,
signed_preview: bool,
acknowledgement: MessageAcknowledgment,
}
}

Expand All @@ -150,6 +167,7 @@ pub mod play {
salt: u64,
signature: Vec<u8>,
signed_preview: bool,
acknowledgement: MessageAcknowledgment,
}
}

Expand Down

0 comments on commit 2b3794d

Please sign in to comment.