Struct resolv_conf::Config [] [src]

pub struct Config {
    pub nameservers: Vec<ScopedIp>,
    pub search: Vec<String>,
    pub sortlist: Vec<Network>,
    pub debug: bool,
    pub ndots: u32,
    pub timeout: u32,
    pub attempts: u32,
    pub rotate: bool,
    pub no_check_names: bool,
    pub inet6: bool,
    pub ip6_bytestring: bool,
    pub ip6_dotint: bool,
    pub edns0: bool,
    pub single_request: bool,
    pub single_request_reopen: bool,
    pub no_tld_query: bool,
    pub use_vc: bool,
}

Represent a resolver configuration, as described in man 5 resolv.conf on linux. The options and defaults match those in this man page.

extern crate resolv_conf;

use std::net::Ipv4Addr;
use resolv_conf::{Config, ScopedIp};

fn main() {
    // Create a new config
    let mut config = Config::new();
    config.nameservers.push(ScopedIp::V4(Ipv4Addr::new(8, 8, 8, 8)));
    config.search.push("example.com".into());

    // Parse a config
    let parsed = Config::parse("nameserver 8.8.8.8\nsearch example.com").unwrap();
    assert_eq!(parsed, config);
}

Fields

List of nameservers

List of suffixes to append to name when it doesn't contain ndots

List of preferred addresses

Enable DNS resolve debugging

Number of dots in name to try absolute resolving first (default 1)

Dns query timeout (default 5 [sec])

Number of attempts to resolve name if server is inaccesible (default 2)

Round-robin selection of servers (default false)

Don't check names for validity (default false)

Try AAAA query before A

Use reverse lookup of ipv6 using bit-label format described instead of nibble format

Do ipv6 reverse lookups in ip6.int zone instead of ip6.arpa (default false)

Enable dns extensions described in RFC 2671

Don't make ipv4 and ipv6 requests simultaneously

Use same socket for the A and AAAA requests

Don't resolve unqualified name as top level domain

Force using TCP for DNS resolution

Methods

impl Config
[src]

[src]

Create a new Config object with default values.

use resolv_conf::Config;
assert_eq!(
    Config::new(),
    Config {
        nameservers: vec![],
        search: vec![],
        sortlist: vec![],
        debug: false,
        ndots: 1,
        timeout: 5,
        attempts: 2,
        rotate: false,
        no_check_names: false,
        inet6: false,
        ip6_bytestring: false,
        ip6_dotint: false,
        edns0: false,
        single_request: false,
        single_request_reopen: false,
        no_tld_query: false,
        use_vc: false,
    });

[src]

Parse a buffer and return the corresponding Config object.

use resolv_conf::{ScopedIp, Config};
let config_str = "# /etc/resolv.conf
nameserver  8.8.8.8
nameserver  8.8.4.4
search      example.com sub.example.com
options     ndots:8 attempts:8";

// Parse the config
let parsed_config = Config::parse(&config_str).expect("Failed to parse config");

// Print the config
println!("{:?}", parsed_config);

Trait Implementations

impl Clone for Config
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Config
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Config
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Config
[src]