Skip to content

Commit

Permalink
vsock_proxy: Use system-configured nameservers for DNS resolution
Browse files Browse the repository at this point in the history
This commit changes the DNS resolver's initialization to use the system's
configured nameservers instead of the default nameserver provided by
hickoery-resolver crate.

The `Resolver::from_system_conf()` method is now used to initialize the
DNS resolver. This method attempts to read the system's nameserver
configuration, which may come from various sources such as
`/etc/resolv.conf`.

Signed-off-by: Erdem MEYDANLI <[email protected]>
  • Loading branch information
meerd committed Jun 3, 2024
1 parent a28eb09 commit e248e75
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vsock_proxy/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use std::net::IpAddr;

use chrono::{DateTime, Duration, Utc};
use hickory_resolver::config::*;
use hickory_resolver::Resolver;
use idna::domain_to_ascii;

Expand Down Expand Up @@ -51,11 +50,12 @@ pub fn resolve(addr: &str, ip_addr_type: IpAddrType) -> VsockProxyResult<Vec<Dns
// IDNA parsing
let addr = domain_to_ascii(addr).map_err(|_| "Could not parse domain name")?;

// Initialize a DNS resolver using the system's configured nameservers.
let resolver = Resolver::from_system_conf()
.map_err(|_| "Error while initializing DNS resolver!".to_string())?;

// DNS lookup
// It results in a vector of IPs (V4 and V6)
let resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default())
.map_err(|_| "Error while initializing DNS resolver!")?;

let rresults: Vec<DnsResolutionInfo> = resolver
.lookup_ip(addr)
.map_err(|_| "DNS lookup failed!")?
Expand Down

0 comments on commit e248e75

Please sign in to comment.