aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
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-client/src
parentb7641ff308aab7840d2a2253ae50f8ee496b2a97 (diff)
parentf4dd3a9293367fa8f3d839a184e8055b22595204 (diff)
downloadazalea-drasl-dac943e3d79def7d2c322450790f16f027735941.tar.xz
Merge pull request #3 from mat-1/auth
Auth
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);