1、优化从linux或wsl系统获取id

2、增加.gitignore文件
This commit is contained in:
ziyouwa
2024-03-25 15:36:18 +08:00
parent b26c4b97b2
commit c7b9f61bd2
2 changed files with 11 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
target/*
vnt/src/proto/message.rs
vnt-cli/src/generated_serial_number.rs
Cargo.lock
+7
View File
@@ -51,6 +51,13 @@ pub fn get_unique_identifier() -> Option<String> {
#[cfg(target_os = "linux")]
pub fn get_unique_identifier() -> Option<String> {
use std::process::Command;
// 对 linux 或 wsl 来说,读取 /etc/machine-id 即可获取当前操作系统的
// 唯一标识,而且某些环境没有预装`dmidecode`命令
if let Ok(identifier) = std::fs::read_to_string("/etc/machine-id") {
return Some(identifier);
}
let output = match Command::new("dmidecode")
.arg("-s")
.arg("system-uuid")