Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsock_proxy: Use system-configured nameservers for DNS resolution #622

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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