QDnsLookup¶
The
QDnsLookup
class represents a DNS lookup. More…
Synopsis¶
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)
Detailed Description¶
QDnsLookup
uses the mechanisms provided by the operating system to perform DNS lookups. To perform a lookup you need to specify aname
andtype
then invoke thelookup()
slot. Thefinished()
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:
void MyObject::lookupServers() { // Create a DNS lookup. dns = new QDnsLookup(this); connect(dns, SIGNAL(finished()), this, 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:
void MyObject::handleServers() { // Check the lookup succeeded. if (dns->error() != QDnsLookup::NoError) { qWarning("DNS lookup failed"); dns->deleteLater(); return; } // Handle the results. const auto records = dns->serviceRecords(); for (const QDnsServiceRecord &record : 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 PySide2.QtNetwork.QDnsLookup(type, name[, parent=None])¶
PySide2.QtNetwork.QDnsLookup(type, name, nameserver[, parent=None])
PySide2.QtNetwork.QDnsLookup([parent=None])
- param type:
- param parent:
- param name:
str
- param nameserver:
Constructs a
QDnsLookup
object for the giventype
andname
and setsparent
as the parent object.Constructs a
QDnsLookup
object for the giventype
,name
andnameserver
and setsparent
as the parent object.Constructs a
QDnsLookup
object and setsparent
as the parent object.The
type
property will default toA
.
- PySide2.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).
- PySide2.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.
- PySide2.QtNetwork.QDnsLookup.abort()¶
Aborts the DNS lookup operation.
If the lookup is already finished, does nothing.
- PySide2.QtNetwork.QDnsLookup.canonicalNameRecords()¶
- Return type:
Returns the list of canonical name records associated with this lookup.
- PySide2.QtNetwork.QDnsLookup.error()¶
- Return type:
This property holds the type of error that occurred if the DNS lookup failed, or
NoError
..
- PySide2.QtNetwork.QDnsLookup.errorString()¶
- Return type:
str
This property holds a human-readable description of the error if the DNS lookup failed..
- PySide2.QtNetwork.QDnsLookup.finished()¶
- PySide2.QtNetwork.QDnsLookup.hostAddressRecords()¶
- Return type:
Returns the list of host address records associated with this lookup.
- PySide2.QtNetwork.QDnsLookup.isFinished()¶
- Return type:
bool
Returns whether the reply has finished or was aborted.
- PySide2.QtNetwork.QDnsLookup.lookup()¶
Performs the DNS lookup.
The
finished()
signal is emitted upon completion.
- PySide2.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.
- PySide2.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.
- PySide2.QtNetwork.QDnsLookup.nameChanged(name)¶
- Parameters:
name – str
- PySide2.QtNetwork.QDnsLookup.nameServerRecords()¶
- Return type:
Returns the list of name server records associated with this lookup.
- PySide2.QtNetwork.QDnsLookup.nameserver()¶
- Return type:
This property holds the nameserver to use for DNS lookup..
- PySide2.QtNetwork.QDnsLookup.nameserverChanged(nameserver)¶
- Parameters:
nameserver –
PySide2.QtNetwork.QHostAddress
- PySide2.QtNetwork.QDnsLookup.pointerRecords()¶
- Return type:
Returns the list of pointer records associated with this lookup.
- PySide2.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.
- PySide2.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.
- PySide2.QtNetwork.QDnsLookup.setNameserver(nameserver)¶
- Parameters:
nameserver –
PySide2.QtNetwork.QHostAddress
This property holds the nameserver to use for DNS lookup..
- PySide2.QtNetwork.QDnsLookup.setType(arg__1)¶
- Parameters:
arg__1 –
Type
This property holds the type of DNS lookup..
- PySide2.QtNetwork.QDnsLookup.textRecords()¶
- Return type:
Returns the list of text records associated with this lookup.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.