aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-24 19:28:29 -0500
committermat <github@matdoes.dev>2022-04-24 19:28:29 -0500
commit4c00bd886578c70f6aeb35400d9d03b355df3155 (patch)
treef4903dd0b8f9690a6c52a180babd56d12c3926c0 /azalea-protocol
parent3e507f0db4020eaf406ba69aae3d4dc1301d29ac (diff)
downloadazalea-drasl-4c00bd886578c70f6aeb35400d9d03b355df3155.tar.xz
Add ServerboundKeyPacket
Diffstat (limited to 'azalea-protocol')
-rwxr-xr-xazalea-protocol/src/packets/login/mod.rs6
-rwxr-xr-xazalea-protocol/src/packets/login/serverbound_hello_packet.rs24
-rw-r--r--azalea-protocol/src/packets/login/serverbound_key_packet.rs10
3 files changed, 17 insertions, 23 deletions
diff --git a/azalea-protocol/src/packets/login/mod.rs b/azalea-protocol/src/packets/login/mod.rs
index ab68518c..93c1200f 100755
--- a/azalea-protocol/src/packets/login/mod.rs
+++ b/azalea-protocol/src/packets/login/mod.rs
@@ -4,6 +4,7 @@ pub mod clientbound_hello_packet;
pub mod clientbound_login_compression_packet;
pub mod clientbound_login_disconnect_packet;
pub mod serverbound_hello_packet;
+pub mod serverbound_key_packet;
use packet_macros::declare_state_packets;
@@ -11,10 +12,13 @@ declare_state_packets!(
LoginPacket,
Serverbound => {
0x00: serverbound_hello_packet::ServerboundHelloPacket,
+ 0x01: serverbound_key_packet::ServerboundKeyPacket,
},
Clientbound => {
// 0x00: clientbound_login_disconnect_packet::ClientboundLoginDisconnectPacket,
- 26: clientbound_login_disconnect_packet::ClientboundLoginDisconnectPacket,
+ // for some reason this is used instead of 0x00??
+ 0x1a: clientbound_login_disconnect_packet::ClientboundLoginDisconnectPacket,
+
0x01: clientbound_hello_packet::ClientboundHelloPacket,
0x02: clientbound_game_profile_packet::ClientboundGameProfilePacket,
0x03: clientbound_login_compression_packet::ClientboundLoginCompressionPacket,
diff --git a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
index a72480f2..eb6a4065 100755
--- a/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_hello_packet.rs
@@ -1,27 +1,7 @@
+use packet_macros::LoginPacket;
use std::hash::Hash;
-use crate::mc_buf::Writable;
-
-use super::LoginPacket;
-
-#[derive(Hash, Clone, Debug)]
+#[derive(Hash, Clone, Debug, LoginPacket)]
pub struct ServerboundHelloPacket {
pub username: String,
}
-
-impl ServerboundHelloPacket {
- pub fn get(self) -> LoginPacket {
- LoginPacket::ServerboundHelloPacket(self)
- }
-
- pub fn write(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> {
- buf.write_utf(&self.username).unwrap();
- Ok(())
- }
-
- pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
- _buf: &mut T,
- ) -> Result<LoginPacket, String> {
- Err("ServerboundHelloPacket::read not implemented".to_string())
- }
-}
diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
new file mode 100644
index 00000000..f402d357
--- /dev/null
+++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
@@ -0,0 +1,10 @@
+use super::LoginPacket;
+use crate::mc_buf::Writable;
+use packet_macros::LoginPacket;
+use std::hash::Hash;
+
+#[derive(Hash, Clone, Debug, LoginPacket)]
+pub struct ServerboundKeyPacket {
+ pub shared_secret: Vec<u8>,
+ pub nonce: Vec<u8>,
+}