QDnsLookup#

The QDnsLookup class represents a DNS lookup. More

Inheritance diagram of PySide6.QtNetwork.QDnsLookup

Synopsis#

Properties#

  • error - The type of error that occurred if the DNS lookup failed, or NoError

  • errorString - Human-readable description of the error if the DNS lookup failed

  • name - The name to lookup

  • nameserver - The nameserver to use for DNS lookup

  • nameserverPort - The port number of nameserver to use for DNS lookup

  • type - The type of DNS lookup

Functions#

Slots#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

Warning

This section contains snippets that were automatically translated from C++ to Python and may contain errors.

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)
    dns.finished.connect(self.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(type, name, nameserver, port[, 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 to issue a query for name of record type type, using the DNS server nameserver running on the default DNS port, and sets parent as the parent object.

Constructs a QDnsLookup object to issue a query for name of record type type, using the DNS server nameserver running on port port, and sets parent as the parent object.

Note

Setting the port number to any value other than the default (53) can cause the name resolution to fail, depending on the operating system limitations and firewalls. Notably, the Windows API used by QDnsLookup is unable to handle alternate port numbers.

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

The type property will default to A .

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property PᅟySide6.QtNetwork.QDnsLookup.error: Error#

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

Access functions:
property PᅟySide6.QtNetwork.QDnsLookup.errorString: str#

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

Access functions:
property PᅟySide6.QtNetwork.QDnsLookup.name: str#

This property holds the name to lookup..

If the name to look up is empty, QDnsLookup will attempt to resolve the root domain of DNS. That query is usually performed with type set to NS .

Note

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

Access functions:
property PᅟySide6.QtNetwork.QDnsLookup.nameserver: PySide6.QtNetwork.QHostAddress#

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

Access functions:
property PᅟySide6.QtNetwork.QDnsLookup.nameserverPort: int#

This property holds the port number of nameserver to use for DNS lookup..

Note

Setting the port number to any value other than the default (53) can cause the name resolution to fail, depending on the operating system limitations and firewalls. Notably, the Windows API used by QDnsLookup is unable to handle alternate port numbers.

Access functions:
property PᅟySide6.QtNetwork.QDnsLookup.type: Type#

This property holds the type of DNS lookup..

Access functions:
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).

QDnsLookup.TimeoutError

the server was not reached or did not reply in time (since 6.6).

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:

.list of QDnsDomainNameRecord

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

PySide6.QtNetwork.QDnsLookup.error()#
Return type:

Error

Getter of property error .

PySide6.QtNetwork.QDnsLookup.errorString()#
Return type:

str

Getter of property errorString .

PySide6.QtNetwork.QDnsLookup.finished()#

This signal is emitted when the reply has finished processing.

Notification signal of property error .

PySide6.QtNetwork.QDnsLookup.hostAddressRecords()#
Return type:

.list of QDnsHostAddressRecord

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:

.list of QDnsMailExchangeRecord

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

See also

setName()

Getter of property name .

PySide6.QtNetwork.QDnsLookup.nameChanged(name)#
Parameters:

name – str

This signal is emitted when the lookup name changes. name is the new lookup name.

Notification signal of property name .

PySide6.QtNetwork.QDnsLookup.nameServerRecords()#
Return type:

.list of QDnsDomainNameRecord

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

PySide6.QtNetwork.QDnsLookup.nameserver()#
Return type:

PySide6.QtNetwork.QHostAddress

See also

setNameserver()

Getter of property nameserver .

PySide6.QtNetwork.QDnsLookup.nameserverChanged(nameserver)#
Parameters:

nameserverPySide6.QtNetwork.QHostAddress

Notification signal of property nameserver .

PySide6.QtNetwork.QDnsLookup.nameserverPort()#
Return type:

int

Getter of property nameserverPort .

PySide6.QtNetwork.QDnsLookup.nameserverPortChanged(port)#
Parameters:

port – int

Notification signal of property nameserverPort .

PySide6.QtNetwork.QDnsLookup.pointerRecords()#
Return type:

.list of QDnsDomainNameRecord

Returns the list of pointer records associated with this lookup.

PySide6.QtNetwork.QDnsLookup.serviceRecords()#
Return type:

.list of QDnsServiceRecord

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

See also

name()

Setter of property name .

PySide6.QtNetwork.QDnsLookup.setNameserver(nameserver)#
Parameters:

nameserverPySide6.QtNetwork.QHostAddress

See also

nameserver()

Setter of property nameserver .

PySide6.QtNetwork.QDnsLookup.setNameserver(nameserver, port)
Parameters:

Sets the nameserver to nameserver and the port to port.

Note

Setting the port number to any value other than the default (53) can cause the name resolution to fail, depending on the operating system limitations and firewalls. Notably, the Windows API used by QDnsLookup is unable to handle alternate port numbers.

PySide6.QtNetwork.QDnsLookup.setNameserverPort(port)#
Parameters:

port – int

See also

nameserverPort()

Setter of property nameserverPort .

PySide6.QtNetwork.QDnsLookup.setType(arg__1)#
Parameters:

arg__1Type

See also

type()

Setter of property type .

PySide6.QtNetwork.QDnsLookup.textRecords()#
Return type:

.list of QDnsTextRecord

Returns the list of text records associated with this lookup.

PySide6.QtNetwork.QDnsLookup.type()#
Return type:

Type

See also

setType()

Getter of property type .

PySide6.QtNetwork.QDnsLookup.typeChanged(type)#
Parameters:

typeType

This signal is emitted when the lookup type changes. type is the new lookup type.

Notification signal of property type .