2025-05-12 10:37:16 +08:00

40 lines
769 B
Rust
Executable File

mod command;
pub use command::*;
mod socks;
use rand::Rng;
use sdlan_sn_rs::utils::Mac;
pub use socks::*;
mod pid_recorder;
pub use pid_recorder::PidRecorder;
// pub const CRC_HASH: crc::Crc<u32> = crc::Crc::<u32>::new(&crc::CRC_32_XFER);
#[allow(unused)]
pub fn caculate_crc(data: &[u8]) -> u32 {
let res = crc32fast::hash(data);
res
}
pub fn mac_to_string(mac: &Mac) -> String {
format!(
"[{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}]",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
)
}
pub fn generate_mac_address() -> Mac {
let mut rng = rand::thread_rng();
let mut mac = [0; 6];
for i in 0..6 {
let number: u8 = rng.gen();
mac[i] = number;
}
mac[0] &= !0x01;
mac[0] |= 0x02;
mac
}