diff options
Diffstat (limited to 'azalea-protocol')
| -rw-r--r-- | azalea-protocol/src/connect.rs | 5 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/game/s_client_information.rs | 2 | ||||
| -rw-r--r-- | azalea-protocol/src/packets/login/s_custom_query.rs | 9 | ||||
| -rw-r--r-- | azalea-protocol/src/read.rs | 2 | ||||
| -rw-r--r-- | azalea-protocol/src/write.rs | 11 |
5 files changed, 16 insertions, 13 deletions
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs index 13a86ed8..77968eed 100644 --- a/azalea-protocol/src/connect.rs +++ b/azalea-protocol/src/connect.rs @@ -344,8 +344,9 @@ impl Connection<ClientboundHandshakePacket, ServerboundHandshakePacket> { impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> { /// Set our compression threshold, i.e. the maximum size that a packet is - /// allowed to be without getting compressed. If you set it to less than 0 - /// then compression gets disabled. + /// allowed to be without getting compressed. Setting it to 0 means every + /// packet will be compressed. If you set it to less than 0, + /// then compression is disabled. pub fn set_compression_threshold(&mut self, threshold: i32) { // if you pass a threshold of less than 0, compression is disabled if threshold >= 0 { diff --git a/azalea-protocol/src/packets/game/s_client_information.rs b/azalea-protocol/src/packets/game/s_client_information.rs index 5861212c..c8e76f63 100644 --- a/azalea-protocol/src/packets/game/s_client_information.rs +++ b/azalea-protocol/src/packets/game/s_client_information.rs @@ -5,5 +5,5 @@ use crate::common::client_information::ClientInformation; #[derive(Clone, Debug, AzBuf, ServerboundGamePacket)] pub struct ServerboundClientInformation { - pub information: ClientInformation, + pub client_information: ClientInformation, } diff --git a/azalea-protocol/src/packets/login/s_custom_query.rs b/azalea-protocol/src/packets/login/s_custom_query.rs deleted file mode 100644 index 39ecdcef..00000000 --- a/azalea-protocol/src/packets/login/s_custom_query.rs +++ /dev/null @@ -1,9 +0,0 @@ -use azalea_buf::{AzBuf, UnsizedByteArray}; -use azalea_protocol_macros::ServerboundLoginPacket; - -#[derive(Clone, Debug, AzBuf, ServerboundLoginPacket)] -pub struct ServerboundCustomQuery { - #[var] - pub transaction_id: u32, - pub data: Option<UnsizedByteArray>, -} diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 64d35a08..038af319 100644 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -285,6 +285,8 @@ where buffer.get_mut().extend_from_slice(&bytes); } } +/// Read a packet from the stream, then if necessary decrypt it, decompress +/// it, and split it. pub fn try_read_raw_packet<R>( stream: &mut R, buffer: &mut Cursor<Vec<u8>>, diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs index adefc340..dd863f9e 100644 --- a/azalea-protocol/src/write.rs +++ b/azalea-protocol/src/write.rs @@ -54,6 +54,15 @@ pub async fn write_raw_packet<W>( where W: AsyncWrite + Unpin + Send, { + let network_packet = encode_to_network_packet(raw_packet, compression_threshold, cipher); + stream.write_all(&network_packet).await +} + +pub fn encode_to_network_packet( + raw_packet: &[u8], + compression_threshold: Option<u32>, + cipher: &mut Option<Aes128CfbEnc>, +) -> Vec<u8> { trace!("Writing raw packet: {raw_packet:?}"); let mut raw_packet = raw_packet.to_vec(); if let Some(threshold) = compression_threshold { @@ -64,7 +73,7 @@ where if let Some(cipher) = cipher { azalea_crypto::encrypt_packet(cipher, &mut raw_packet); } - stream.write_all(&raw_packet).await + raw_packet } pub fn compression_encoder( |
