QDnsLookup#
The QDnsLookup
class represents a DNS lookup. More…
Synopsis#
Properties#
error
- The type of error that occurred if the DNS lookup failed, or NoErrorerrorString
- Human-readable description of the error if the DNS lookup failedname
- The name to lookupnameserver
- The nameserver to use for DNS lookuptype
- The type of DNS lookup
Functions#
def
canonicalNameRecords
()def
error
()def
errorString
()def
hostAddressRecords
()def
isFinished
()def
mailExchangeRecords
()def
name
()def
nameServerRecords
()def
nameserver
()def
pointerRecords
()def
serviceRecords
()def
setName
(name)def
setNameserver
(nameserver)def
setType
(arg__1)def
textRecords
()def
type
()
Slots#
Signals#
def
finished
()def
nameChanged
(name)def
nameserverChanged
(nameserver)def
typeChanged
(type)
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([parent=None])
- Parameters:
name – str
nameserver –
PySide6.QtNetwork.QHostAddress
type –
Type
parent –
PySide6.QtCore.QObject
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
.
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
..
- property PᅟySide6.QtNetwork.QDnsLookup.errorString: str#
This property holds a human-readable description of the error if the DNS lookup failed..
- Access functions:
errorString
()Signal
finished
()
- property PᅟySide6.QtNetwork.QDnsLookup.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.
- Access functions:
name
()setName
(name)Signal
nameChanged
(name)
- property PᅟySide6.QtNetwork.QDnsLookup.nameserver: PySide6.QtNetwork.QHostAddress#
This property holds the nameserver to use for DNS lookup..
- Access functions:
nameserver
()setNameserver
(nameserver)Signal
nameserverChanged
(nameserver)
- property PᅟySide6.QtNetwork.QDnsLookup.type: Type#
This property holds the type of DNS lookup..
- Access functions:
type
()setType
(arg__1)Signal
typeChanged
(type)
- 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.
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:
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.
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:
Returns the list of name server records associated with this lookup.
- PySide6.QtNetwork.QDnsLookup.nameserver()#
- Return type:
See also
Getter of property nameserver
.
- PySide6.QtNetwork.QDnsLookup.nameserverChanged(nameserver)#
- Parameters:
nameserver –
PySide6.QtNetwork.QHostAddress
Notification signal of property nameserver
.
- 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.
Setter of property name
.
- PySide6.QtNetwork.QDnsLookup.setNameserver(nameserver)#
- Parameters:
nameserver –
PySide6.QtNetwork.QHostAddress
See also
Setter of property nameserver
.
Setter of property type
.
- PySide6.QtNetwork.QDnsLookup.textRecords()#
- Return type:
Returns the list of text records associated with this lookup.
Getter of property type
.
This signal is emitted when the lookup type
changes. type
is the new lookup type.
Notification signal of property type
.