support unicode hostname
This commit is contained in:
@@ -258,21 +258,15 @@ impl ConfigLoader for TomlConfigLoader {
|
|||||||
|
|
||||||
match hostname {
|
match hostname {
|
||||||
Some(hostname) => {
|
Some(hostname) => {
|
||||||
|
let hostname = hostname
|
||||||
|
.chars()
|
||||||
|
.filter(|c| !c.is_control())
|
||||||
|
.take(32)
|
||||||
|
.collect::<String>();
|
||||||
|
|
||||||
if !hostname.is_empty() {
|
if !hostname.is_empty() {
|
||||||
let mut name = hostname
|
self.set_hostname(Some(hostname.clone()));
|
||||||
.chars()
|
hostname
|
||||||
.filter(|c| c.is_ascii_alphanumeric() || *c == '-' || *c == '_')
|
|
||||||
.take(32)
|
|
||||||
.collect::<String>();
|
|
||||||
|
|
||||||
if name.len() > 32 {
|
|
||||||
name = name.chars().take(32).collect::<String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if hostname != name {
|
|
||||||
self.set_hostname(Some(name.clone()));
|
|
||||||
}
|
|
||||||
name
|
|
||||||
} else {
|
} else {
|
||||||
self.set_hostname(None);
|
self.set_hostname(None);
|
||||||
gethostname::gethostname().to_string_lossy().to_string()
|
gethostname::gethostname().to_string_lossy().to_string()
|
||||||
|
|||||||
Reference in New Issue
Block a user