move hostname function to utils

This commit is contained in:
Luna Yao
2026-04-20 00:51:59 +02:00
parent 11626d8082
commit 524c8d9987
3 changed files with 11 additions and 14 deletions
+2 -8
View File
@@ -22,6 +22,7 @@ use crate::{
common::{CompressionAlgoPb, PortForwardConfigPb, SecureModeConfig, SocketType},
},
tunnel::generate_digest_from_str,
utils,
};
pub type Flags = crate::proto::common::FlagsInConfig;
@@ -580,14 +581,7 @@ impl ConfigLoader for TomlConfigLoader {
.filter(|h| !h.is_empty());
self.set_hostname(hostname.clone());
hostname.unwrap_or_else(|| {
sanitize(
hostname::get()
.unwrap_or_else(|_| "localhost".into())
.to_string_lossy()
.as_ref(),
)
})
hostname.unwrap_or_else(|| sanitize(utils::hostname()))
}
fn set_hostname(&self, name: Option<String>) {