Indy 9
|
TIdDNSResolver = class(TIdUDPClient)
TIdDNSResolver provides facilities for accessing the Domain Name Space and Resource Records retrieved from a DNS Server using queries for specified domain names, resource types, and resource classes.
TIdDNSResolver provides properties and methods that simplify the process of creating a valid DNS query, and accessing the resource records returned in the query results.
Use QueryRecords to indicate DNS Resource Record types to be returned by the DNS Query. QueryRecords must contain on or more of the values from TQueryRecordTypes.
Set AllowRecursiveQueries to the value to be used in the DNS Query header. AllowRecursiveQueries permits a DNS server to pursue the query for DNS resource records on another name server. AllowRecursiveQueries has no effect if the DNS server does not implement recursive queries.
Use the Resolve method to peform a DNS Query for the specified domain name. Resolve creates the DNS Query packet, including the DNS header, transmits the request to the DNS host, and captures and parses the query results.
Use QueryResult to determine the number of resource records returned by the QueryClass, QueryType, and DomainName in the DNS Query, and to access the TResultRecord object instances containing the data for the resource records. Items in QueryResults may also be cast to an instance of a TResultRecord descendant class to access additional properties and methods based on its resource record type and class.
Note: Currently, the TIdDNSResolver implementation does not support all aspects of the DNS protocol, and includes the following limitations:
property AllowRecursiveQueries: Boolean;
AllowRecursiveQueries will have no effect when the DNS does not implement recursive queries, as indicated in the DNS Header RA field from the server response.
The default value for AllowRecursiveQueries is True, as assigned in the Create constructor. Set the desired value for AllowRecursiveQueries prior to calling Resolve.
property QueryRecords: TQueryType;
QueryRecords may contain one or more of the TQueryType values, including the following:
Update QueryRecords to include the values desired prior to calling the Resolve method.
property QueryResult: TQueryResult;
QueryResult is updated when the Resolve method parses values found in the Answer portion of the DNS response.
QueryResult is a collection for TResultRecord resource records, and Items in the collection can be accessed using their integer position. Items in QueryResult may also be cast to a TResultRecord descendant class instance to allow access to additional properties and method specific to the resource record type.
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Resolve(ADomain: string);
ADomain is the domain name to be resolved in the DNS query using the values specified in AllowRecursiveQueries and QueryRecords. Update QueryRecords and AllowRecursiveQueries prior to calling the Resolve method.
Resolve creates a DNS query packet, including the DNS header, using the value specified in ADomain. Resolve can raise an EIdDnsResolverError exception if a valid DNS query cannot be created using the values in ADomain, AllowRecursiveQueries, and QueryRecords.
Resolve send the DNS query packet to the server, and reads the DNS response. Resolve handles parsing of values in the DNS response into the DNS header and QueryResult. Resolve can raise an EIdDnsResolverError if a timeout occurs, or an incomplete data packet is received, while waiting for a DNS server response.