dns-resolver: externalize unwrapping on UnboundResolver initialization

This commit is contained in:
Dirkjan Ochtman
2024-10-15 08:54:24 -07:00
committed by Wez Furlong
parent a9132e201d
commit 4553cafeca
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ static IP_CACHE: LazyLock<StdMutex<LruCacheWithTtl<Name, Arc<Vec<IpAddr>>>>> =
#[cfg(feature = "default-unbound")]
fn default_resolver() -> Resolver {
Resolver::Unbound(UnboundResolver::new())
Resolver::Unbound(UnboundResolver::new().unwrap())
}
#[cfg(not(feature = "default-unbound"))]
+6 -6
View File
@@ -54,14 +54,14 @@ pub struct UnboundResolver {
#[cfg(feature = "unbound")]
impl UnboundResolver {
pub fn new() -> Self {
pub fn new() -> Result<Self, libunbound::Error> {
// This resolves directly against the root
let context = Context::new().unwrap();
let context = Context::new()?;
// and enables DNSSEC
context.add_builtin_trust_anchors().unwrap();
Self {
cx: context.into_async().unwrap(),
}
context.add_builtin_trust_anchors()?;
Ok(Self {
cx: context.into_async()?,
})
}
}