abla/dns
Generated from source.
Import with import "abla/dns".
Source: abla/dns/entry.ab
DnsAddress (class)
class DnsAddress(
val family: int,
val address: string,
val ttlSeconds: int
)
Holds a numeric IP address, its address family, and the DNS record's lifetime in seconds.
DnsResolution (class)
class DnsResolution(
val addresses: array<DnsAddress>,
val succeeded: bool,
val timedOut: bool,
val errorCode: int,
// The name server answered NXDOMAIN for every candidate name (errorCode 2).
val nameNotFound: bool = false
)
Holds resolved addresses, completion and timeout flags, and any resolution error.
DnsDecodedName (class)
class DnsDecodedName(
val name: string,
val nextOffset: int,
val valid: bool
)
Holds the decoded domain name and the next offset, with a false validity flag for malformed input.
dnsAppendU16 (fun)
fun dnsAppendU16(var output: ByteBuffer, value: int): void
Appends the low 16 bits of the value to the buffer in network byte order.
dnsReadU16 (fun)
fun dnsReadU16(input: string, offset: int): int
Returns the unsigned 16-bit value at the byte offset, or -1 if two bytes are unavailable.
dnsEncodeName (fun)
fun dnsEncodeName(host: string): string
Returns a DNS label encoding or empty text when the hostname or label length is invalid.
dnsQuery (fun)
fun dnsQuery(host: string, recordType: int, identifier: int): string
Returns a DNS A or AAAA query packet or empty text for an invalid hostname or unsupported record type.
dnsDecodeName (fun)
fun dnsDecodeName(input: string, start: int): DnsDecodedName
Returns the name and next offset from a possibly compressed DNS name, marking invalid pointers or truncated labels as failure. A pointer must point before itself (RFC 1035 4.1.4: to a prior occurrence of a name), so a loop is an error and not a name after 128 hops; the name's wire form is at most 255 bytes.
dnsReplyQuestionMatches (fun)
fun dnsReplyQuestionMatches(input: string, identifier: int, name: string, recordType: int): bool
Whether input is a reply to the query for name and recordType with this identifier: the response bit set, the identifier equal, one question whose name (ASCII case ignored), type and class IN are the ones asked. A reply that fails this is not an answer to our question and is to be ignored.
dnsParseResponse (fun)
fun dnsParseResponse(
input: string,
identifier: int,
maximumAddresses: int = 32,
queryName: string = ""
): DnsResolution
Returns the addresses from a bounded DNS response or a failure for malformed data or a mismatched transaction identifier. With a non-empty queryName only the records whose owner is that name (ASCII case ignored) or a name reached from it by CNAME records earlier in the answer (at most eight links) count; the others, which a server has no business sending for this question, are skipped. An empty queryName keeps every address record.
DnsConfiguration (class)
class DnsConfiguration(
val nameservers: array<string>,
val search: array<string>,
val ndots: int
)
What /etc/resolv.conf configures: IPv4 name servers in order, the search domains (the last search or domain line), and options ndots:N (default 1, at most 15).
dnsParseConfiguration (fun)
fun dnsParseConfiguration(text: string): DnsConfiguration
Returns resolver nameservers, search domains, and the dot threshold parsed from configuration text.
dnsConfigurationText (fun)
fun dnsConfigurationText(file: string): string
The text of the resolver configuration file: the file, except that the default /etc/resolv.conf on Windows is the system's DNS servers (dnsWindowsConfigurationText).
dnsHostsText (fun)
fun dnsHostsText(file: string): string
The text of the hosts file file: the file, except that the default /etc/hosts on Windows is the one under %SystemRoot%/System32/drivers/etc.
dnsReadConfiguration (fun)
fun dnsReadConfiguration(path: string = "/etc/resolv.conf"): DnsConfiguration
Returns parsed resolver settings from the host file, with defaults when the file cannot be read.
dnsChooseServer (fun)
fun dnsChooseServer(server: string, configuration: DnsConfiguration): string
The name server to ask: server when given, else the configuration's first, else systemd-resolved's stub.
dnsCandidates (fun)
fun dnsCandidates(host: string, configuration: DnsConfiguration): array<string>
The names to ask for, in order, as a C library's resolver tries them: a name ending in a dot only as written; a name with at least ndots dots as written first, then with each search domain; any other name with each search domain first, then as written. Names that cannot be encoded are left out.
dnsHostsLookup (fun)
fun dnsHostsLookup(text: string, host: string, recordType: int): array<DnsAddress>
The addresses of recordType (1 = A, 28 = AAAA) that a hosts file gives host (its canonical name or an alias, compared without case), in file order.
dnsLiteral (fun)
fun dnsLiteral(host: string, recordType: int): DnsResolution?
A literal address's resolution for recordType (the address when its family matches, no addresses otherwise), or null for a name.
dnsResponseCode (fun)
fun dnsResponseCode(input: string, identifier: int, name: string): int
The response code of a reply to the query identifier for name (the header's identifier and question must match, the reply bit be set), or -1.
dnsExhausted (fun)
fun dnsExhausted(sawNoData: bool): DnsResolution
The resolution after every candidate failed with NXDOMAIN or no records: no records (succeeded, no addresses) when any candidate exists without records of the type, otherwise not found.
DnsExchange (class)
class DnsExchange(val resolution: DnsResolution, val notFound: bool)
One UDP exchange for name: what the first datagram gave, and whether it was an authentic NXDOMAIN (from the server asked, matching the query).
dnsResolveType (fun)
fun dnsResolveType(
host: string,
recordType: int,
timeoutMilliseconds: int = 2000,
server: string = "",
serverPort: int = 53,
configurationPath: string = "/etc/resolv.conf",
hostsPath: string = "/etc/hosts",
deadline: int = 0
): DnsResolution
Resolves host for recordType (1 = A, 28 = AAAA), blocking for up to timeoutMilliseconds per name asked. A literal address is itself; the hosts file answers next; then each candidate name (dnsCandidates) is asked in turn, moving on after NXDOMAIN or no records of the type. Any other failure (a timeout, a server error, a malformed reply) ends the search. deadline, when nonzero, is an absolute monotonic millisecond deadline shared across candidates and record types.
dnsResolve (fun)
fun dnsResolve(
host: string,
timeoutMilliseconds: int = 2000,
server: string = "",
serverPort: int = 53,
configurationPath: string = "/etc/resolv.conf",
hostsPath: string = "/etc/hosts",
deadline: int = 0
): DnsResolution
Resolves host for AAAA and A records, returning IPv6 results first. Uses hostsPath before querying server at serverPort, or the server selected from configurationPath when none is supplied. timeoutMilliseconds bounds each exchange and a positive deadline caps the overall wait. The result reports success if either lookup succeeds, plus timeout or error information.
tcpConnectHost (fun)
fun tcpConnectHost(
host: string,
port: int,
timeoutMilliseconds: int = 5000,
deadline: int = 0
): TcpConnection
Connects to host (a numeric address or DNS name) on port. Uses timeoutMilliseconds for waits and caps them by a positive monotonic deadline. Returns a negative descriptor when resolution or connection fails.
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.