mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
🐞 fix: hostname empty
This commit is contained in:
@@ -226,6 +226,7 @@ impl ConfigLoader for TomlConfigLoader {
|
|||||||
|
|
||||||
match hostname {
|
match hostname {
|
||||||
Some(hostname) => {
|
Some(hostname) => {
|
||||||
|
if !hostname.is_empty() {
|
||||||
let re = regex::Regex::new(r"[^\u4E00-\u9FA5a-zA-Z0-9\-]*").unwrap();
|
let re = regex::Regex::new(r"[^\u4E00-\u9FA5a-zA-Z0-9\-]*").unwrap();
|
||||||
let mut name = re.replace_all(&hostname, "").to_string();
|
let mut name = re.replace_all(&hostname, "").to_string();
|
||||||
|
|
||||||
@@ -237,6 +238,10 @@ impl ConfigLoader for TomlConfigLoader {
|
|||||||
self.set_hostname(Some(name.clone()));
|
self.set_hostname(Some(name.clone()));
|
||||||
}
|
}
|
||||||
name
|
name
|
||||||
|
} else {
|
||||||
|
self.set_hostname(None);
|
||||||
|
gethostname::gethostname().to_string_lossy().to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => gethostname::gethostname().to_string_lossy().to_string(),
|
None => gethostname::gethostname().to_string_lossy().to_string(),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user