#include <netnames.h>
Public Types | |
| enum | Type { A, Aaaa, Mx, Srv, Cname, Ptr, Txt, Hinfo, Ns, Null, Any } |
Public Member Functions | |
| NameRecord () | |
| NameRecord (const QByteArray &owner, int ttl) | |
| NameRecord (const NameRecord &from) | |
| ~NameRecord () | |
| NameRecord & | operator= (const NameRecord &from) |
| bool | isNull () const |
| QByteArray | owner () const |
| int | ttl () const |
| Type | type () const |
| QHostAddress | address () const |
| QByteArray | name () const |
| int | priority () const |
| int | weight () const |
| int | port () const |
| QList< QByteArray > | texts () const |
| QByteArray | cpu () const |
| QByteArray | os () const |
| QByteArray | rawData () const |
| void | setOwner (const QByteArray &name) |
| void | setTTL (int seconds) |
| void | setAddress (const QHostAddress &a) |
| void | setMx (const QByteArray &name, int priority) |
| void | setSrv (const QByteArray &name, int port, int priority, int weight) |
| void | setCname (const QByteArray &name) |
| void | setPtr (const QByteArray &name) |
| void | setTxt (const QList< QByteArray > &texts) |
| void | setHinfo (const QByteArray &cpu, const QByteArray &os) |
| void | setNs (const QByteArray &name) |
| void | setNull (const QByteArray &rawData) |
NameRecord provides a DNS (Domain Name System) record, which is information assicated with a domain name. For most purposes, the information is an IP address. However, DNS records are capable of holding a variety of data types, such as named pointers to other domain names and even arbitrary text strings. The results of a NameResolver operation are a list of NameRecords.
The most common type is the address record, "A", which contains an IPv4 address. Here is an example of how to get the IP address out of an address record:
NameRecord record = ... // obtain a record from somewhere if(record.type() == NameRecord::A) { QHostAddress ip = record.address(); // get the IP ... }
Getting the data out of a NameRecord involves calling the right retrieval functions, depending on the type. Many types share retrieval functions. For example, the "AAAA" type holds an IPv6 address, which is accessed the same way as the "A" type, by calling address(). See the NameRecord::Type enum for further information about which retrieval functions should be called for each type.
To create a NameRecord, use setOwner() and setTTL() as necessary, and then call one of the setX functions (where X is the desired type). For example, to set an A or AAAA record, use setAddress() like this:
// make example.com the owner, with 1 hour TTL NameRecord record("example.com", 3600); record.setAddress(QHostAddress("1.2.3.4"));
Note that in the case of setAddress(), the record type need not be specified. NameRecord will determine the type to use based on the given QHostAddress.
|
|
The type of DNS record. The retrieval functions are shown for each type.
|
|
|
Constructs a null record object.
|
|
||||||||||||
|
Constructs a partially initialized record object, with the given owner and ttl. For the record to be usable, call an appropriate setX function (where X is the desired type) afterwards. |
|
|
Constructs a copy of from.
|
|
|
Destroys the record object.
|
|
|
Returns the IP address. For NameRecord::A and NameRecord::Aaaa types. |
|
|
Returns the architecture identifier string. For the NameRecord::Hinfo type. |
|
|
Returns true if this record object is null, otherwise returns false. Be sure not to confuse a null object with the NULL type (NameRecord::Null). Don't ask why DNS has a type called NULL that contains valid data. |
|
|
Returns the domain name. For NameRecord::Mx, NameRecord::Srv, NameRecord::Cname, NameRecord::Ptr, and NameRecord::Ns types. |
|
|
Assigns from to this object and returns a reference to this object.
|
|
|
Returns the operating system identifier string. For the NameRecord::Hinfo type. |
|
|
Returns the owner of this record. The owner is usually not a useful attribute, since it will be the same as the name searched for with NameResolver. For example, if the A record of "example.com" is looked up, then the resulting records will all have "example.com" as the owner.
|
|
|
Returns the port. For the NameRecord::Srv type. |
|
|
Returns the priority. For NameRecord::Mx and NameRecord::Srv types. |
|
|
Returns the raw data. For the NameRecord::Null type. |
|
|
Set as A or AAAA record, with data a. The protocol of a determines whether the type will be NameRecord::A or NameRecord::Aaaa. |
|
|
Set as CNAME record, with data name.
|
|
||||||||||||
|
Set as HINFO record, with data cpu and os.
|
|
||||||||||||
|
Set as MX record, with data name and priority.
|
|
|
Set as NS record, with data name.
|
|
|
Set as NULL record, with data rawData.
|
|
|
Sets the owner of this record to name.
|
|
|
Set as PTR record, with data name.
|
|
||||||||||||||||||||
|
Set as SRV record, with data name, port, priority, and weight.
|
|
|
Sets the TTL (time-to-live) of this record to ttl seconds.
|
|
|
Set as TXT record, with data texts.
|
|
|
Returns the list of text strings. For the NameRecord::Txt type. |
|
|
Returns the TTL (time-to-live) of this record. This is the number of seconds the record should be considered valid, which is useful information when performing caching. As a special exception, a TTL of 0 when performing a long-lived lookup indicates that a record is no longer available.
|
|
|
Returns the type of this record.
|
|
|
Returns the weight. For the NameRecord::Srv type. |
1.4.6