1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::io;
use std::net::SocketAddr;
use std::time::Duration;
#[derive(Clone, Debug)]
pub struct DnsConfig {
pub name_servers: Vec<SocketAddr>,
pub search: Vec<String>,
pub n_dots: u32,
pub timeout: Duration,
pub attempts: u32,
pub rotate: bool,
pub use_inet6: bool,
}
pub fn default_config() -> io::Result<DnsConfig> {
default_config_impl()
}
#[cfg(unix)]
fn default_config_impl() -> io::Result<DnsConfig> {
use resolv_conf::load;
load()
}
#[cfg(windows)]
fn default_config_impl() -> io::Result<DnsConfig> {
Err(io::Error::new(io::ErrorKind::Other, "Nameserver list not available on Windows"))
}