QDnsLookup

The QDnsLookup class represents a DNS lookup. More

Inheritance diagram of PySide6.QtNetwork.QDnsLookup

Synopsis

Functions

Slots

Signals

Detailed Description

QDnsLookup uses the mechanisms provided by the operating system to perform DNS lookups. To perform a lookup you need to specify a name and type then invoke the lookup() slot. The finished() signal will be emitted upon completion.

For example, you can determine which servers an XMPP chat client should connect to for a given domain with:

def lookupServers(self):

    # Create a DNS lookup.
    dns = QDnsLookup(self)
    connect(dns, SIGNAL(finished()),
            self, SLOT(handleServers()))
    # Find the XMPP servers for gmail.com
    dns.setType(QDnsLookup.SRV)
    dns.setName("_xmpp-client._tcp.gmail.com")
    dns.lookup()

Once the request finishes you can handle the results with:

def handleServers(self):

    # Check the lookup succeeded.
    if (dns.error() != QDnsLookup.NoError) {
        qWarning("DNS lookup failed")
        dns.deleteLater()
        return

    # Handle the results.
    records = dns.serviceRecords()
    for record in records:
        ...

    dns.deleteLater()

Note

If you simply want to find the IP address(es) associated with a host name, or the host name associated with an IP address you should use QHostInfo instead.

class PySide6.QtNetwork.QDnsLookup(type, name[, parent=None])

PySide6.QtNetwork.QDnsLookup(type, name, nameserver[, parent=None])

PySide6.QtNetwork.QDnsLookup([parent=None])

Parameters

Constructs a QDnsLookup object for the given type and name and sets parent as the parent object.

Constructs a QDnsLookup object for the given type, name and nameserver and sets parent as the parent object.

Constructs a QDnsLookup object and sets parent as the parent object.

The type property will default to A .

PySide6.QtNetwork.QDnsLookup.Error

Indicates all possible error conditions found during the processing of the DNS lookup.

Constant

Description

QDnsLookup.NoError

no error condition.

QDnsLookup.ResolverError

there was an error initializing the system’s DNS resolver.

QDnsLookup.OperationCancelledError

the lookup was aborted using the abort() method.

QDnsLookup.InvalidRequestError

the requested DNS lookup was invalid.

QDnsLookup.InvalidReplyError

the reply returned by the server was invalid.

QDnsLookup.ServerFailureError

the server encountered an internal failure while processing the request (SERVFAIL).

QDnsLookup.ServerRefusedError

the server refused to process the request for security or policy reasons (REFUSED).

QDnsLookup.NotFoundError

the requested domain name does not exist (NXDOMAIN).

PySide6.QtNetwork.QDnsLookup.Type

Indicates the type of DNS lookup that was performed.

Constant

Description

QDnsLookup.A

IPv4 address records.

QDnsLookup.AAAA

IPv6 address records.

QDnsLookup.ANY

any records.

QDnsLookup.CNAME

canonical name records.

QDnsLookup.MX

mail exchange records.

QDnsLookup.NS

name server records.

QDnsLookup.PTR

pointer records.

QDnsLookup.SRV

service records.

QDnsLookup.TXT

text records.

PySide6.QtNetwork.QDnsLookup.abort()

Aborts the DNS lookup operation.

If the lookup is already finished, does nothing.

PySide6.QtNetwork.QDnsLookup.canonicalNameRecords()
Return type

Returns the list of canonical name records associated with this lookup.

PySide6.QtNetwork.QDnsLookup.error()
Return type

Error

This property holds the type of error that occurred if the DNS lookup failed, or NoError ..

PySide6.QtNetwork.QDnsLookup.errorString()
Return type

str

This property holds a human-readable description of the error if the DNS lookup failed..

PySide6.QtNetwork.QDnsLookup.finished()
PySide6.QtNetwork.QDnsLookup.hostAddressRecords()
Return type

Returns the list of host address records associated with this lookup.

PySide6.QtNetwork.QDnsLookup.isFinished()
Return type

bool

Returns whether the reply has finished or was aborted.

PySide6.QtNetwork.QDnsLookup.lookup()

Performs the DNS lookup.

The finished() signal is emitted upon completion.

PySide6.QtNetwork.QDnsLookup.mailExchangeRecords()
Return type

Returns the list of mail exchange records associated with this lookup.

The records are sorted according to RFC 5321 , so if you use them to connect to servers, you should try them in the order they are listed.

PySide6.QtNetwork.QDnsLookup.name()
Return type

str

This property holds the name to lookup..

Note

The name will be encoded using IDNA, which means it’s unsuitable for querying SRV records compatible with the DNS-SD specification.

PySide6.QtNetwork.QDnsLookup.nameChanged(name)
Parameters

name – str

PySide6.QtNetwork.QDnsLookup.nameServerRecords()
Return type

Returns the list of name server records associated with this lookup.

PySide6.QtNetwork.QDnsLookup.nameserver()
Return type

PySide6.QtNetwork.QHostAddress

This property holds the nameserver to use for DNS lookup..

PySide6.QtNetwork.QDnsLookup.nameserverChanged(nameserver)
Parameters

nameserverPySide6.QtNetwork.QHostAddress

PySide6.QtNetwork.QDnsLookup.pointerRecords()
Return type

Returns the list of pointer records associated with this lookup.

PySide6.QtNetwork.QDnsLookup.serviceRecords()
Return type

Returns the list of service records associated with this lookup.

The records are sorted according to RFC 2782 , so if you use them to connect to servers, you should try them in the order they are listed.

PySide6.QtNetwork.QDnsLookup.setName(name)
Parameters

name – str

This property holds the name to lookup..

Note

The name will be encoded using IDNA, which means it’s unsuitable for querying SRV records compatible with the DNS-SD specification.

PySide6.QtNetwork.QDnsLookup.setNameserver(nameserver)
Parameters

nameserverPySide6.QtNetwork.QHostAddress

This property holds the nameserver to use for DNS lookup..

PySide6.QtNetwork.QDnsLookup.setType(arg__1)
Parameters

arg__1Type

This property holds the type of DNS lookup..

PySide6.QtNetwork.QDnsLookup.textRecords()
Return type

Returns the list of text records associated with this lookup.

PySide6.QtNetwork.QDnsLookup.type()
Return type

Type

This property holds the type of DNS lookup..

PySide6.QtNetwork.QDnsLookup.typeChanged(type)
Parameters

typeType