using System; using System.Collections.Generic; using System.Net; using System.Threading; using System.Threading.Tasks; namespace DnsClient { /// /// Generic contract to query DNS endpoints. Implemented by . /// public interface IDnsQuery { /// /// Performs a DNS lookup for the given , and . /// /// The domain name query. /// The . /// The . /// Query options to be used instead of 's settings. /// /// The which contains the response headers and lists of resource records. /// /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. IDnsQueryResponse Query(string query, QueryType queryType, QueryClass queryClass = QueryClass.IN, DnsQueryOptions queryOptions = null); /// /// Performs a DNS lookup for the given . /// /// The domain name query. /// /// The which contains the response headers and lists of resource records. /// /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. IDnsQueryResponse Query(DnsQuestion question); /// /// Performs a DNS lookup for the given . /// /// The domain name query. /// Query options to be used instead of 's settings. /// /// The which contains the response headers and lists of resource records. /// /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. IDnsQueryResponse Query(DnsQuestion question, DnsQueryOptions queryOptions); /// /// Performs a DNS lookup for the given , and /// /// The domain name query. /// The . /// The . /// The cancellation token. /// Query options to be used instead of 's settings. /// /// The which contains the response headers and lists of resource records. /// /// If is null. /// If cancellation has been requested for the passed in . /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. Task QueryAsync(string query, QueryType queryType, QueryClass queryClass = QueryClass.IN, DnsQueryOptions queryOptions = null, CancellationToken cancellationToken = default); /// /// Performs a DNS lookup for the given . /// /// The domain name query. /// The cancellation token. /// /// The which contains the response headers and lists of resource records. /// /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. Task QueryAsync(DnsQuestion question, CancellationToken cancellationToken = default); /// /// Performs a DNS lookup for the given . /// /// The domain name query. /// Query options to be used instead of 's settings. /// The cancellation token. /// /// The which contains the response headers and lists of resource records. /// /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. Task QueryAsync(DnsQuestion question, DnsQueryOptions queryOptions, CancellationToken cancellationToken = default); /// /// Does a reverse lookup for the . /// /// The . /// /// The which might contain the for the . /// /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. IDnsQueryResponse QueryReverse(IPAddress ipAddress); /// /// Does a reverse lookup for the . /// /// The . /// Query options to be used instead of 's settings. /// /// The which might contain the for the . /// /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. IDnsQueryResponse QueryReverse(IPAddress ipAddress, DnsQueryOptions queryOptions); /// /// Does a reverse lookup for the . /// /// The . /// The cancellation token. /// /// The which might contain the for the . /// /// If is null. /// If cancellation has been requested for the passed in . /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. Task QueryReverseAsync(IPAddress ipAddress, CancellationToken cancellationToken = default); /// /// Does a reverse lookup for the . /// /// The . /// Query options to be used instead of 's settings. /// The cancellation token. /// /// The which might contain the for the . /// /// If is null. /// If cancellation has been requested for the passed in . /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. Task QueryReverseAsync(IPAddress ipAddress, DnsQueryOptions queryOptions, CancellationToken cancellationToken = default); /// /// Performs a DNS lookup for the given , and /// using only the passed in . /// /// /// To query specific servers can be useful in cases where you have to use a different DNS server than initially configured /// (without creating a new instance of for example). /// /// The list of one or more server(s) which should be used for the lookup. /// The domain name query. /// The . /// The . /// /// The which contains the response headers and lists of resource records. /// /// If the collection doesn't contain any elements. /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. IDnsQueryResponse QueryServer(IReadOnlyCollection servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN); /// /// Performs a DNS lookup for the given , and /// using only the passed in . /// /// /// To query specific servers can be useful in cases where you have to use a different DNS server than initially configured /// (without creating a new instance of for example). /// /// The list of one or more server(s) which should be used for the lookup. /// The domain name query. /// The . /// The . /// The cancellation token. /// /// The which contains the response headers and lists of resource records. /// /// If the collection doesn't contain any elements. /// If is null. /// If cancellation has been requested for the passed in . /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. Task QueryServerAsync(IReadOnlyCollection servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN, CancellationToken cancellationToken = default); /// /// Does a reverse lookup for the /// using only the passed in . /// /// The list of one or more server(s) which should be used for the lookup. /// The . /// /// The which might contain the for the . /// /// If the collection doesn't contain any elements. /// If is null. /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. IDnsQueryResponse QueryServerReverse(IReadOnlyCollection servers, IPAddress ipAddress); /// /// Does a reverse lookup for the /// using only the passed in . /// /// The list of one or more server(s) which should be used for the lookup. /// The . /// The cancellation token. /// /// The which might contain the for the . /// /// If the collection doesn't contain any elements. /// If is null. /// If cancellation has been requested for the passed in . /// After retries and fallbacks, if none of the servers were accessible, timed out or (if is enabled) returned error results. Task QueryServerReverseAsync(IReadOnlyCollection servers, IPAddress ipAddress, CancellationToken cancellationToken = default); } }