• DnsClient
  • Readme
  • Api Docs
  • MichaCo.net
    Show / Hide Table of Contents

    Class LookupClient

    The LookupClient is the main query class of this library and should be used for any kind of DNS lookup query.

    It implements ILookupClient and IDnsQuery which contains a number of extension methods, too. The extension methods internally all invoke the standard IDnsQuery queries though.

    Inheritance
    Object
    LookupClient
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace:DnsClient
    Assembly:DnsClient.dll
    Syntax
    public class LookupClient : ILookupClient, IDnsQuery
    Examples

    A basic example wihtout specifying any DNS server, which will use the DNS server configured by your local network.

    var client = new LookupClient();
    var result = client.Query("google.com", QueryType.A);

    foreach (var aRecord in result.Answers.ARecords()) { Console.WriteLine(aRecord); }

    Constructors

    | Improve this Doc View Source

    LookupClient()

    Creates a new instance of LookupClient without specifying any name server. This will implicitly use the name server(s) configured by the local network adapter.

    Declaration
    public LookupClient()
    Remarks

    This uses ResolveNameServers(Boolean, Boolean). The resulting list of name servers is highly dependent on the local network configuration and OS.

    Examples

    In the following example, we will create a new LookupClient without explicitly defining any DNS server. This will use the DNS server configured by your local network.

    var client = new LookupClient();
    var result = client.Query("google.com", QueryType.A);

    foreach (var aRecord in result.Answers.ARecords()) { Console.WriteLine(aRecord); }

    | Improve this Doc View Source

    LookupClient(IPAddress, Int32)

    Create a new instance of LookupClient with one DNS server defined by address and port.

    Declaration
    public LookupClient(IPAddress address, int port)
    Parameters
    Type Name Description
    IPAddress address

    The IPAddress of the DNS server.

    Int32 port

    The port of the DNS server.

    Examples

    In case you want to connect to one specific DNS server which does not run on the default port 53, you can do so like in the following example:

    var client = new LookupClient(IPAddress.Parse("127.0.0.1"), 8600);

    | Improve this Doc View Source

    LookupClient(IPAddress[])

    Creates a new instance of LookupClient with one or more DNS servers identified by their IPAddress. The default port 53 will be used for all IPAddresss provided.

    Declaration
    public LookupClient(params IPAddress[] nameServers)
    Parameters
    Type Name Description
    IPAddress[] nameServers

    The IPAddress(s) to be used by this LookupClient instance.

    Examples

    To connect to one or more DNS server using the default port, we can use this overload:

    // configuring the client to use google's public IPv4 DNS servers.
    var client = new LookupClient(IPAddress.Parse("8.8.8.8"), IPAddress.Parse("8.8.4.4"));

    | Improve this Doc View Source

    LookupClient(IPEndPoint[])

    Creates a new instance of LookupClient with one or more IPAddress and port combination stored in IPEndPoint(s).

    Declaration
    public LookupClient(params IPEndPoint[] nameServers)
    Parameters
    Type Name Description
    IPEndPoint[] nameServers

    The IPEndPoint(s) to be used by this LookupClient instance.

    Examples

    In this example, we instantiate a new IPEndPoint using an IPAddress and custom port which is different than the default port 53.

    // Using localhost and port 8600 to connect to a Consul agent.
    var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8600);
    var client = new LookupClient(endpoint);

    The NameServer class also contains pre defined IPEndPoints for the public google DNS servers, which can be used as follows:

    var client = new LookupClient(NameServer.GooglePublicDns, NameServer.GooglePublicDnsIPv6);

    Properties

    | Improve this Doc View Source

    EnableAuditTrail

    Declaration
    public bool EnableAuditTrail { get; set; }
    Property Value
    Type Description
    Boolean
    Implements
    ILookupClient.EnableAuditTrail
    | Improve this Doc View Source

    MinimumCacheTimeout

    Declaration
    public TimeSpan? MinimumCacheTimeout { get; set; }
    Property Value
    Type Description
    Nullable<TimeSpan>
    Implements
    ILookupClient.MinimumCacheTimeout
    | Improve this Doc View Source

    NameServers

    Declaration
    public IReadOnlyCollection<NameServer> NameServers { get; }
    Property Value
    Type Description
    IReadOnlyCollection<NameServer>
    Implements
    ILookupClient.NameServers
    | Improve this Doc View Source

    Recursion

    Declaration
    public bool Recursion { get; set; }
    Property Value
    Type Description
    Boolean
    Implements
    ILookupClient.Recursion
    | Improve this Doc View Source

    Retries

    Declaration
    public int Retries { get; set; }
    Property Value
    Type Description
    Int32
    Implements
    ILookupClient.Retries
    | Improve this Doc View Source

    ThrowDnsErrors

    Declaration
    public bool ThrowDnsErrors { get; set; }
    Property Value
    Type Description
    Boolean
    Implements
    ILookupClient.ThrowDnsErrors
    | Improve this Doc View Source

    Timeout

    Declaration
    public TimeSpan Timeout { get; set; }
    Property Value
    Type Description
    TimeSpan
    Implements
    ILookupClient.Timeout
    | Improve this Doc View Source

    UseCache

    Declaration
    public bool UseCache { get; set; }
    Property Value
    Type Description
    Boolean
    Implements
    ILookupClient.UseCache
    | Improve this Doc View Source

    UseTcpFallback

    Declaration
    public bool UseTcpFallback { get; set; }
    Property Value
    Type Description
    Boolean
    Implements
    ILookupClient.UseTcpFallback
    | Improve this Doc View Source

    UseTcpOnly

    Declaration
    public bool UseTcpOnly { get; set; }
    Property Value
    Type Description
    Boolean
    Implements
    ILookupClient.UseTcpOnly

    Methods

    | Improve this Doc View Source

    Query(String, QueryType)

    Declaration
    public IDnsQueryResponse Query(string query, QueryType queryType)
    Parameters
    Type Name Description
    String query
    QueryType queryType
    Returns
    Type Description
    IDnsQueryResponse
    Implements
    IDnsQuery.Query(String, QueryType)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    | Improve this Doc View Source

    Query(String, QueryType, QueryClass)

    Declaration
    public IDnsQueryResponse Query(string query, QueryType queryType, QueryClass queryClass)
    Parameters
    Type Name Description
    String query
    QueryType queryType
    QueryClass queryClass
    Returns
    Type Description
    IDnsQueryResponse
    Implements
    IDnsQuery.Query(String, QueryType, QueryClass)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    | Improve this Doc View Source

    QueryAsync(String, QueryType)

    Declaration
    public Task<IDnsQueryResponse> QueryAsync(string query, QueryType queryType)
    Parameters
    Type Name Description
    String query
    QueryType queryType
    Returns
    Type Description
    Task<IDnsQueryResponse>
    Implements
    IDnsQuery.QueryAsync(String, QueryType)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    | Improve this Doc View Source

    QueryAsync(String, QueryType, QueryClass)

    Declaration
    public Task<IDnsQueryResponse> QueryAsync(string query, QueryType queryType, QueryClass queryClass)
    Parameters
    Type Name Description
    String query
    QueryType queryType
    QueryClass queryClass
    Returns
    Type Description
    Task<IDnsQueryResponse>
    Implements
    IDnsQuery.QueryAsync(String, QueryType, QueryClass)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    | Improve this Doc View Source

    QueryAsync(String, QueryType, QueryClass, CancellationToken)

    Declaration
    public Task<IDnsQueryResponse> QueryAsync(string query, QueryType queryType, QueryClass queryClass, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    String query
    QueryType queryType
    QueryClass queryClass
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<IDnsQueryResponse>
    Implements
    IDnsQuery.QueryAsync(String, QueryType, QueryClass, CancellationToken)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    | Improve this Doc View Source

    QueryAsync(String, QueryType, CancellationToken)

    Declaration
    public Task<IDnsQueryResponse> QueryAsync(string query, QueryType queryType, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    String query
    QueryType queryType
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<IDnsQueryResponse>
    Implements
    IDnsQuery.QueryAsync(String, QueryType, CancellationToken)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    | Improve this Doc View Source

    QueryReverse(IPAddress)

    Declaration
    public IDnsQueryResponse QueryReverse(IPAddress ipAddress)
    Parameters
    Type Name Description
    IPAddress ipAddress
    Returns
    Type Description
    IDnsQueryResponse
    Implements
    IDnsQuery.QueryReverse(IPAddress)
    | Improve this Doc View Source

    QueryReverseAsync(IPAddress)

    Declaration
    public Task<IDnsQueryResponse> QueryReverseAsync(IPAddress ipAddress)
    Parameters
    Type Name Description
    IPAddress ipAddress
    Returns
    Type Description
    Task<IDnsQueryResponse>
    Implements
    IDnsQuery.QueryReverseAsync(IPAddress)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    | Improve this Doc View Source

    QueryReverseAsync(IPAddress, CancellationToken)

    Declaration
    public Task<IDnsQueryResponse> QueryReverseAsync(IPAddress ipAddress, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    IPAddress ipAddress
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<IDnsQueryResponse>
    Implements
    IDnsQuery.QueryReverseAsync(IPAddress, CancellationToken)
    Remarks

    The behavior of the query can be controlled by the properties of this LookupClient instance. Recursion for example can be disabled and would instruct the DNS server to return no additional records.

    Extension Methods

    DnsQueryExtensions.GetHostEntry(IDnsQuery, String)
    DnsQueryExtensions.GetHostEntryAsync(IDnsQuery, String)
    DnsQueryExtensions.GetHostEntry(IDnsQuery, IPAddress)
    DnsQueryExtensions.GetHostEntryAsync(IDnsQuery, IPAddress)
    DnsQueryExtensions.GetHostName(IDnsQuery, IPAddress)
    DnsQueryExtensions.GetHostNameAsync(IDnsQuery, IPAddress)
    DnsQueryExtensions.ResolveService(IDnsQuery, String, String, ProtocolType)
    DnsQueryExtensions.ResolveServiceAsync(IDnsQuery, String, String, ProtocolType)
    DnsQueryExtensions.ResolveService(IDnsQuery, String, String, String)
    DnsQueryExtensions.ResolveServiceAsync(IDnsQuery, String, String, String)

    See Also

    IDnsQuery
    ILookupClient
    • Improve this Doc
    • View Source
    © 2017 by Michael Conrad. All rights reserved. - MichaCo.net