Skip to content

Commit

Permalink
Fix deriving domainname from hostname for search domain
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspustina committed Mar 11, 2024
1 parent e154814 commit 223bfc6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ impl NameBuilderOpts {

/// Creates a new `NameBuilderOpts` by using the domain name from the local host's hostname as search domain.
pub fn from_hostname(ndots: u8) -> Result<Self> {
let search_domain = hostname::get()
let hostname = hostname::get()
.context("failed to get local hostname")?
.to_string_lossy()
.to_string();
let name = Name::from_str(&hostname)
.context("failed to parse local hostname")?;
let search_domain = name.base_name();
NameBuilderOpts::new(ndots, search_domain)
}
}
Expand Down

0 comments on commit 223bfc6

Please sign in to comment.