aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2022-04-25 03:50:17 +0000
committerGitHub <noreply@github.com>2022-04-25 03:50:17 +0000
commitdac943e3d79def7d2c322450790f16f027735941 (patch)
tree3beafa3c8035c69a33b7d0f12779236bf786cf36 /azalea-protocol/src/packets
parentb7641ff308aab7840d2a2253ae50f8ee496b2a97 (diff)
parentf4dd3a9293367fa8f3d839a184e8055b22595204 (diff)
downloadazalea-drasl-dac943e3d79def7d2c322450790f16f027735941.tar.xz
Merge pull request #3 from mat-1/auth
Auth
Diffstat (limited to 'azalea-protocol/src/packets')
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_hello_packet.rs7
-rwxr-xr-xazalea-protocol/src/packets/login/mod.rs8
-rwxr-xr-xazalea-protocol/src/packets/login/serverbound_hello_packet.rs24
-rw-r--r--azalea-protocol/src/packets/login/serverbound_key_packet.rs10
4 files changed, 21 insertions, 28 deletions
diff --git a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
index 9d0cec39..d36f1335 100755
--- a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
@@ -1,14 +1,13 @@
use std::hash::Hash;
-use crate::mc_buf::Readable;
-
use super::LoginPacket;
+use crate::mc_buf::{ByteArray, Readable};
#[derive(Hash, Clone, Debug)]
pub struct ClientboundHelloPacket {
pub server_id: String,
- pub public_key: Vec<u8>,
- pub nonce: Vec<u8>,
+ pub public_key: ByteArray,
+ pub nonce: ByteArray,
}
impl ClientboundHelloPacket {
diff --git a/azalea-protocol/src/packets/login/mod.rs b/azalea-protocol/src/packets/login/mod.rs
index ab68518c..b160a28c 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,
+ 0x00: clientbound_login_disconnect_packet::ClientboundLoginDisconnectPacket,
+ // sometimes this is used for some reason?
+ // 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..3750331f
--- /dev/null
+++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
@@ -0,0 +1,10 @@
+use super::LoginPacket;
+use crate::mc_buf::{ByteArray, Writable};
+use packet_macros::LoginPacket;
+use std::hash::Hash;
+
+#[derive(Hash, Clone, Debug, LoginPacket)]
+pub struct ServerboundKeyPacket {
+ pub shared_secret: ByteArray,
+ pub nonce: ByteArray,
+}