Resolver structv0.1.0
pub struct Resolver {
// private fields
}
Not copied. A query goes to each server in turn, for the IPv4 addresses and then the IPv6 ones, until a server answers; the whole round is tried again as many times as the attempts allow. Each query waits for its answer up to the timeout, and a name the server says does not exist ends the lookup at once.
Associated functions
WithServers
pub func WithServers(
allocator: Allocator,
servers: SocketAddress[..]
) -> Resolver
A resolver that asks servers, waiting five seconds for each answer and going round them twice.
| Name | Type | Description |
|---|---|---|
allocator | Allocator | what the server list and every lookup's results are kept in |
servers | SocketAddress[..] | the name servers, in the order they are asked; port 53 is DNS's own |
Returns: the resolver
FromSystem
pub func FromSystem(allocator: Allocator) -> Resolver
A resolver configured as the C library's would be: the name servers, and the timeout and attempts
options, of /etc/resolv.conf on Linux. With no servers to read, the one on this machine is asked.
| Name | Type | Description |
|---|---|---|
allocator | Allocator | what the server list and every lookup's results are kept in |
Returns: the resolver
Methods
SetTimeout
pub func SetTimeout(self: &var Resolver, timeout: Duration)
How long a query waits for its answer.
| Name | Type | Description |
|---|---|---|
timeout | Duration | the wait for each answer |
SetAttempts
pub func SetAttempts(self: &var Resolver, attempts: uint)
How many times the servers are gone round before a lookup gives up.
| Name | Type | Description |
|---|---|---|
attempts | uint | the number of rounds, at least one |
Lookup
pub func Lookup(
self: &Resolver,
allocator: Allocator,
host: char8[..],
port: uint16
) -> Vector<SocketAddress> ! IoError
Asks the servers for host's addresses: its IPv4 addresses first, then its IPv6 ones, each with port.
The hosts file is not read; Resolve reads it first.
| Name | Type | Description |
|---|---|---|
allocator | Allocator | what the list is kept in |
host | char8[..] | the name, such as example.com |
port | uint16 | the port every address gets |
Returns: the addresses; NotFound when the name has none or does not exist, TimedOut when no server answered