Table of Contents

Class Resolver

Namespace
Ubiety.Dns.Core
Assembly
Ubiety.Dns.Core.dll

Represents a DNS resolver that performs DNS queries and manages response caching with support for customizable transport protocols and query configurations.

public class Resolver
Inheritance
Resolver
Inherited Members

Properties

Recursion

Gets a value indicating whether DNS recursion is enabled for the resolver. When enabled, recursive DNS queries are performed, allowing the resolver to fetch complete DNS responses.

public bool Recursion { get; init; }

Property Value

bool

Retries

Gets or initializes the number of retry attempts for DNS queries in case of failure.

public int Retries { get; init; }

Property Value

int

Timeout

Gets or initializes the timeout duration, in milliseconds, for DNS queries. This value determines how long the resolver waits for a response before timing out.

public int Timeout { get; init; }

Property Value

int

TransportType

Gets or sets the transport protocol used for DNS queries. Determines whether queries are sent over UDP or TCP.

public TransportType TransportType { get; set; }

Property Value

TransportType

UseCache

Gets a value indicating whether the DNS resolver should use caching for responses. When set to false, the existing cache is cleared.

public bool UseCache { get; init; }

Property Value

bool

Version

Gets the version information for the current assembly.

public static string? Version { get; }

Property Value

string

Methods

ClearCache()

Clears all entries in the DNS response cache.

public void ClearCache()

GetArpaFromEnumerator(string)

Converts an enumerator string to its corresponding ARPA address.

public static string GetArpaFromEnumerator(string enumerator)

Parameters

enumerator string

The enumerator representing a numerical address to convert.

Returns

string

The resulting ARPA address as a string.

GetArpaFromIp(IPAddress)

Converts the given IP address into its corresponding reverse DNS ARPA address.

public static string GetArpaFromIp(IPAddress ip)

Parameters

ip IPAddress

The IP address to be converted into an ARPA address.

Returns

string

A string representing the reverse DNS ARPA address for the provided IP address. If the address family is unsupported, returns "?".

Query(string, QuestionType, QuestionClass)

Sends a DNS query for the specified domain name, question type, and question class.

public Response Query(string domainName, QuestionType questionType, QuestionClass questionClass = QuestionClass.IN)

Parameters

domainName string

The domain name to resolve.

questionType QuestionType

The type of DNS query (e.g., A, AAAA, MX).

questionClass QuestionClass

The class of DNS query (e.g., IN for Internet).

Returns

Response

A Response containing the result of the DNS query.

Exceptions

InvalidOperationException

The resolver has no DNS servers configured.

QueryAsync(string, QuestionType, CancellationToken)

Sends a DNS query asynchronously in the internet class.

public Task<Response> QueryAsync(string domainName, QuestionType questionType, CancellationToken cancellationToken)

Parameters

domainName string

The domain name to resolve.

questionType QuestionType

The type of DNS query (e.g., A, AAAA, MX).

cancellationToken CancellationToken

Cancels the query.

Returns

Task<Response>

A Response containing the result of the DNS query.

Remarks

Saves passing IN just to reach the token, which is the class almost every caller wants.

Exceptions

InvalidOperationException

The resolver has no DNS servers configured.

OperationCanceledException

cancellationToken was cancelled.

QueryAsync(string, QuestionType, QuestionClass, CancellationToken)

Sends a DNS query asynchronously.

public Task<Response> QueryAsync(string domainName, QuestionType questionType, QuestionClass questionClass = QuestionClass.IN, CancellationToken cancellationToken = default)

Parameters

domainName string

The domain name to resolve.

questionType QuestionType

The type of DNS query (e.g., A, AAAA, MX).

questionClass QuestionClass

The class of DNS query (e.g., IN for Internet).

cancellationToken CancellationToken

Cancels the query.

Returns

Task<Response>

A Response containing the result of the DNS query.

Remarks

A cached answer is returned without awaiting anything. Cancellation is distinct from the configured timeout: a timeout fails over to the next server, cancellation abandons the query.

Exceptions

InvalidOperationException

The resolver has no DNS servers configured.

OperationCanceledException

cancellationToken was cancelled.