aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-client/src')
-rwxr-xr-xazalea-client/src/connect.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs
index 6e58bee6..44eff33f 100755
--- a/azalea-client/src/connect.rs
+++ b/azalea-client/src/connect.rs
@@ -4,7 +4,10 @@ use azalea_protocol::{
packets::{
game::GamePacket,
handshake::client_intention_packet::ClientIntentionPacket,
- login::{serverbound_hello_packet::ServerboundHelloPacket, LoginPacket},
+ login::{
+ serverbound_hello_packet::ServerboundHelloPacket,
+ serverbound_key_packet::ServerboundKeyPacket, LoginPacket,
+ },
ConnectionProtocol, PROTOCOL_VERSION,
},
resolver, ServerAddress,
@@ -39,6 +42,20 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> {
Ok(packet) => match packet {
LoginPacket::ClientboundHelloPacket(p) => {
println!("Got encryption request {:?} {:?}", p.nonce, p.public_key);
+ let e = azalea_auth::encryption::encrypt(&p.public_key, &p.nonce).unwrap();
+
+ // TODO: authenticate with the server here (authenticateServer)
+ println!("Sending encryption response {:?}", e);
+
+ conn.write(
+ ServerboundKeyPacket {
+ nonce: e.encrypted_nonce.into(),
+ shared_secret: e.encrypted_public_key.into(),
+ }
+ .get(),
+ )
+ .await;
+ conn.set_encryption_key(e.secret_key);
}
LoginPacket::ClientboundLoginCompressionPacket(p) => {
println!("Got compression request {:?}", p.compression_threshold);
@@ -57,6 +74,7 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> {
LoginPacket::ClientboundCustomQueryPacket(p) => {
println!("Got custom query {:?}", p);
}
+ LoginPacket::ServerboundKeyPacket(_) => todo!(),
},
Err(e) => {
panic!("Error: {:?}", e);