Indy 9
|
TResultRecord = class(TCollectionItem)
Resource records are returned in the Answer, Authority, and Additional sections of a DNS response, and they all share the same format: a variable number of resource records, where the number of records is specified in the corresponding count field in the header.
A resource record has the following format:
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | . . . NAME . . . | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TYPE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | CLASS | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TTL | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | RDLENGTH | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| . . . RDATA . . . +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
TResultRecord provides properties that represent the values found in a resource record, including the resource record type, resource class, Time-To-Live, data for the resource record, and the length of data in the resource record.
TResultRecord also provides methods to handle parsing of raw data from a DNS query response, and storing the resulting values in properties for the object instance.
TResultRecord is also an ancestor class for other resource record types such as TARecord, TCNRecord, THINFORecord, TMINFORecord, TMXRecord, TNAMERecord, TNSRecord, TPTRRecord, TRDATARecord, TSOARecord, TTextRecord, and TWKSRecord. These descendant classes provide additional properties used for labels in the RDATA field that are specific to the resource class and resource record type.
TResultRecord is the type used to represent collection items maintained in the TQueryResult collection, and the item class returned when accessing the resource records returned by a DNS query in TIdDNSResolver.QueryResult.Items.
property Name: string;
Many name servers internally form tree or hash structures for the domain name space, and link resource records to these nodes. The remaining resource record values are the fixed header (RecType, RecClass, and TTL) which is consistent for all resource records. Variable data that describes the resource record is attached to the RData property.
property RData: String;
RData is often used to provide the raw data used for property values in TResultRecord decendant classes like TRDATARecord and TWKSRecord. Values in RData frequently contain "pointers" to other data in the Domain Name Space. Other TResultRecord descendants will use RData to populate properties, including the following resource record types and usages:
property RDataLength: Integer;
property RecClass: word;
Note: Currently, the TIdDNSResolver implementation does not support all aspects of the DNS protocol, and includes the following limitations:
RecClass is updated when resource records are parsed, and added to TQueryResult from the TIdDNSResolver.Resolve method.
property RecType: TQueryRecordTypes;
RecType will normally contain one of the TQueryRecordTypes values specified in TIdDNSResolver.QueryRecords prior to calling TIdDNSResolver.Resolve.
RecType may contain one of the following values and associated meanings for the resource record type:
RecType is updated when TQueryResult.Add is used to create a resource record read from a DNS response in TIdDNSResolver.Resolve.
property TTL: cardinal;
TTL does not apply to authoritative data in a DNS zone, but can timeout by use of refreshing policies for the zone. TTL is assigned by the administrator for the zone where the data originates.
While short TTLs can be used to minimize caching, and a zero TTL prohibits caching, the realities of Internet performance suggest that these times should be on the order of days for the typical host. If a change can be anticipated, the TTL can be reduced on the DNS server prior to the change to minimize inconsistency during the change, and then increased back to its former value following the change.
destructor Destroy; override;
procedure Parse(CompleteMessage: String; APos: Integer); virtual;
APos is the one-based integer position where data for the resource record can be located in the values specified in CompleteMessage.
Parse is not implemented in TResultRecord, and should be overridden in TResultRecord descendant classes to perform parsing specific to the content for the resource record type.
Parse is used by TIdDNSResolver when resolving a DNS query, and parsing the answer values returned in the DNS response.