aboutsummaryrefslogtreecommitdiff
path: root/azalea-auth
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-12-03 02:41:09 -0600
committermat <git@matdoes.dev>2023-12-03 02:41:09 -0600
commit1f46ef8c115db0c53e21dfb6a3e633825c6747c3 (patch)
tree74e5fa5e76ac95bb68e6d07b999187e5a4e617c0 /azalea-auth
parent0713223e1204438f839566ce8cf954f0c9ff7f91 (diff)
downloadazalea-drasl-1f46ef8c115db0c53e21dfb6a3e633825c6747c3.tar.xz
make it so plugins can send and receive packets during the login state
Diffstat (limited to 'azalea-auth')
-rw-r--r--azalea-auth/Cargo.toml3
-rwxr-xr-xazalea-auth/src/lib.rs1
-rw-r--r--azalea-auth/src/offline.rs17
3 files changed, 20 insertions, 1 deletions
diff --git a/azalea-auth/Cargo.toml b/azalea-auth/Cargo.toml
index 3e25b6a4..93d9c7f3 100644
--- a/azalea-auth/Cargo.toml
+++ b/azalea-auth/Cargo.toml
@@ -25,7 +25,8 @@ serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
thiserror = "1.0.50"
tokio = { version = "1.34.0", features = ["fs"] }
-uuid = { version = "1.5.0", features = ["serde"] }
+uuid = { version = "1.5.0", features = ["serde", "v3"] }
+md-5 = "0.10.6"
[dev-dependencies]
env_logger = "0.10.1"
diff --git a/azalea-auth/src/lib.rs b/azalea-auth/src/lib.rs
index bd151eb3..1643bf04 100755
--- a/azalea-auth/src/lib.rs
+++ b/azalea-auth/src/lib.rs
@@ -4,6 +4,7 @@ mod auth;
pub mod cache;
pub mod certs;
pub mod game_profile;
+pub mod offline;
pub mod sessionserver;
pub use auth::*;
diff --git a/azalea-auth/src/offline.rs b/azalea-auth/src/offline.rs
new file mode 100644
index 00000000..737555e8
--- /dev/null
+++ b/azalea-auth/src/offline.rs
@@ -0,0 +1,17 @@
+use md5::{Digest, Md5};
+use uuid::Uuid;
+
+pub fn generate_uuid(username: &str) -> Uuid {
+ uuid::Builder::from_md5_bytes(hash(format!("OfflinePlayer:{username}").as_bytes())).into_uuid()
+}
+
+fn hash(data: &[u8]) -> [u8; 16] {
+ let mut hasher = Md5::new();
+
+ hasher.update(data);
+
+ let mut bytes = [0; 16];
+ bytes.copy_from_slice(&hasher.finalize()[..16]);
+
+ bytes
+}