From 33429dddc9f712f8bad660c58a3c262d07c0f2fa Mon Sep 17 00:00:00 2001 From: Denis Drakhnia Date: Sat, 7 Oct 2023 19:41:55 +0300 Subject: [PATCH] Remove byteorder dependency --- Cargo.lock | 7 ------- Cargo.toml | 1 - src/client.rs | 7 +++---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 874a241..2b46e47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,12 +35,6 @@ version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - [[package]] name = "cc" version = "1.0.83" @@ -94,7 +88,6 @@ name = "hlmaster" version = "0.1.0" dependencies = [ "bitflags", - "byteorder", "chrono", "fastrand", "getopts", diff --git a/Cargo.toml b/Cargo.toml index d205725..2147485 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ thiserror = "1.0.49" getopts = "0.2.21" log = "<0.4.19" bitflags = "2.4" -byteorder = "1.4.3" fastrand = "2.0.1" [dependencies.chrono] diff --git a/src/client.rs b/src/client.rs index 6dfe6f8..1b23029 100644 --- a/src/client.rs +++ b/src/client.rs @@ -2,11 +2,10 @@ // SPDX-FileCopyrightText: 2023 Denis Drakhnia use std::fmt; -use std::io::{self, Cursor}; +use std::io; use std::ops::Deref; use std::str; -use byteorder::{ReadBytesExt, LE}; use log::debug; use thiserror::Error; @@ -57,8 +56,8 @@ impl<'a> Packet<'a> { Ok(Self::QueryServers(region, Filter(filter))) } - [b'q', 0xff, tail @ ..] => { - let challenge = Cursor::new(tail).read_u32::()?; + [b'q', 0xff, b0, b1, b2, b3] => { + let challenge = u32::from_le_bytes([*b0, *b1, *b2, *b3]); Ok(Self::Challenge(Some(challenge))) } [b'0', b'\n', tail @ ..] => {