From c0305a3e4b08d740eb6702b69e9eee079a84fd0a Mon Sep 17 00:00:00 2001 From: Luca BRUNO Date: Thu, 27 Feb 2020 10:50:36 +0000 Subject: [PATCH] cargo: update to latest hostname version This updates the optional `hostname` dependency to the latest version (0.3.0). Signed-off-by: Luca BRUNO --- src/config.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index 36b6185..f0074ae 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,9 +4,6 @@ use std::slice::Iter; use {grammar, Network, ParseError, ScopedIp}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -#[cfg(feature = "system")] -use hostname::get_hostname; - const NAMESERVER_LIMIT:usize = 3; const SEARCH_LIMIT:usize = 6; @@ -278,14 +275,19 @@ impl Config { return self.domain.clone(); } - get_hostname().and_then(|s| { + let hostname = match ::hostname::get().ok() { + Some(name) => name.into_string().ok(), + None => return None, + }; + + hostname.and_then(|s| { if let Some(pos) = s.find('.') { let hn = s[pos + 1..].to_string(); if !hn.is_empty() { return Some(hn) } }; - return None; + None }) } } -- 2.25.1