unix::resolvconf+x86_64 +linux

unix::resolvconf implements a parser for /etc/resolv.conf files which has feature parity with the resolv.conf format supported by glibc 2.36. However, most options are not supported by Hare internally, i.e. via net::dns.

The user may parse a resolv.conf file manually via the read and next functions. Additionally, this module maintains a global copy of the local resolv.conf file, parsed once at runtime and cached for the lifetime of the process, which is available via load.

Index

Types

type config = struct {
	nameservers: []ip::addr,
	search: []str,
	sortlist: []ip::subnet,
	options: options,
};
type options = struct {
	debug: bool,
	ndots: uint,
	timeout: uint,
	attempts: uint,
	rotate: bool,
	no_aaaa: bool,
	no_check_names: bool,
	inet6: bool,
	edns0: bool,
	single_request: bool,
	single_request_reopen: bool,
	no_tld_query: bool,
	use_vc: bool,
	no_reload: bool,
	trust_ad: bool,
};
type parameter = struct {
	name: const str,
	value: value,
};
type subnet_list = []ip::subnet;
type value = (ip::addr | subnet_list | *options | []str);

// Undocumented types:
type reader = struct {
	scan: bufio::scanner,
	// Only one of these is valid at a time (return values from [[next]] are
	// borrowed from this).
	union {
		addr_list: []ip::addr,
		subnet_list: []ip::subnet,
		str_list: []str,
	},
	options: options,
};

Errors

type error = !(errors::error | io::error | utf8::invalid | ip::invalid | invalid);
type invalid = !void;

Functions

fn finish(rd: *reader) void;
fn load() *config;
fn next(rd: *reader) (parameter | io::EOF | error);
fn read(in: io::handle) reader;
fn strerror(err: error) const str;

Types

type config[link]

type config = struct {
	nameservers: []ip::addr,
	search: []str,
	sortlist: []ip::subnet,
	options: options,
};

A complete configuration parsed from resolv.conf.

type options[link]

type options = struct {
	debug: bool,
	ndots: uint,
	timeout: uint,
	attempts: uint,
	rotate: bool,
	no_aaaa: bool,
	no_check_names: bool,
	inet6: bool,
	edns0: bool,
	single_request: bool,
	single_request_reopen: bool,
	no_tld_query: bool,
	use_vc: bool,
	no_reload: bool,
	trust_ad: bool,
};

Values set in an "options" directive.

type parameter[link]

type parameter = struct {
	name: const str,
	value: value,
};

A configuration parameter from resolv.conf.

type subnet_list[link]

type subnet_list = []ip::subnet;

A list of net::ip::subnets.

type value[link]

type value = (ip::addr | subnet_list | *options | []str);

The value associated with a configuration parameter.

type reader[link]

Show undocumented member
type reader = struct {
	scan: bufio::scanner,
	// Only one of these is valid at a time (return values from [[next]] are
	// borrowed from this).
	union {
		addr_list: []ip::addr,
		subnet_list: []ip::subnet,
		str_list: []str,
	},
	options: options,
};

Errors

type error[link]

type error = !(errors::error | io::error | utf8::invalid | ip::invalid | invalid);

Any error which can be raised by the resolv.conf parser.

type invalid[link]

type invalid = !void;

The resolv.conf file is not well-formatted.

Functions

fn finish[link]

fn finish(rd: *reader) void;

Frees resources associated with a reader.

fn load[link]

fn load() *config;

Reads /etc/resolv.conf (or the platform-specific equivalent path) and returns the configuration therein. If the file does not exist, or is poorly formatted, returns the default resolver configuration.

fn next[link]

fn next(rd: *reader) (parameter | io::EOF | error);

Reads the next parameter from a resolv.conf reader. The return value is borrowed from the reader.

fn read[link]

fn read(in: io::handle) reader;

Reads an /etc/resolv.conf-formatted file from the provided I/O handle. Use next to enumerate directives from the file and pass the return value to finish to free resources associated with the reader.

fn strerror[link]

fn strerror(err: error) const str;

Converts an error into a human-friendly representation.