34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
extern crate workshop_token;
|
|
use workshop_token::DeviceIdGenerator;
|
|
|
|
// server/src/auth/device_id_example.rs
|
|
|
|
// 主要使用示例
|
|
fn main() -> Result<(), ()> {
|
|
println!("=== 设备ID生成器 ===");
|
|
|
|
// 生成标准设备ID
|
|
let device_id = DeviceIdGenerator::generate_device_id()?;
|
|
println!("设备ID: {}", device_id);
|
|
|
|
// 生成短设备ID
|
|
let short_id = DeviceIdGenerator::generate_short_device_id()?;
|
|
println!("短设备ID: {}", short_id);
|
|
|
|
// 生成详细报告
|
|
let report = DeviceIdGenerator::generate_device_report()?;
|
|
println!("\n=== 设备详细信息 ===");
|
|
println!("用户名: {}", report.device_info.username);
|
|
println!("主机名: {}", report.device_info.hostname);
|
|
println!("操作系统: {} {}", report.device_info.os_name, report.device_info.os_version);
|
|
println!("架构: {}", report.device_info.architecture);
|
|
println!("CPU: {} {}", report.device_info.cpu_info.vendor_id, report.device_info.cpu_info.brand);
|
|
println!("CPU特性: {}", report.device_info.cpu_info.features.join(", "));
|
|
|
|
// 验证设备ID
|
|
let is_valid = DeviceIdGenerator::verify_device_id(&device_id)?;
|
|
println!("\n设备ID验证: {}", if is_valid { "通过" } else { "失败" });
|
|
|
|
Ok(())
|
|
}
|