diff --git a/easytier/src/common/config.rs b/easytier/src/common/config.rs index 9ff51dfa..449ecc63 100644 --- a/easytier/src/common/config.rs +++ b/easytier/src/common/config.rs @@ -258,21 +258,15 @@ impl ConfigLoader for TomlConfigLoader { match hostname { Some(hostname) => { + let hostname = hostname + .chars() + .filter(|c| !c.is_control()) + .take(32) + .collect::(); + if !hostname.is_empty() { - let mut name = hostname - .chars() - .filter(|c| c.is_ascii_alphanumeric() || *c == '-' || *c == '_') - .take(32) - .collect::(); - - if name.len() > 32 { - name = name.chars().take(32).collect::(); - } - - if hostname != name { - self.set_hostname(Some(name.clone())); - } - name + self.set_hostname(Some(hostname.clone())); + hostname } else { self.set_hostname(None); gethostname::gethostname().to_string_lossy().to_string()