PySide6.QtNetwork.QDnsLookup¶
- class QDnsLookup¶
- The - QDnsLookupclass represents a DNS lookup. More…- Synopsis¶- Properties¶- authenticDataᅟ- Whether the reply was authenticated by the resolver
- 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
- nameserverProtocolᅟ- The protocol to use when sending the DNS query
- typeᅟ- The type of DNS lookup
 - Methods¶- def - __init__()
- def - error()
- def - errorString()
- def - isFinished()
- def - name()
- def - nameserver()
- def - nameserverPort()
- def - pointerRecords()
- def - serviceRecords()
- def - setName()
- def - setNameserver()
- def - setType()
- def - textRecords()
- def - type()
 - Slots¶- Signals¶- def - finished()
- def - nameChanged()
- def - typeChanged()
 - Static functions¶- 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. - QDnsLookupuses the mechanisms provided by the operating system to perform DNS lookups. To perform a lookup you need to specify a- nameand- typethen 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 - QHostInfoinstead.- DNS-over-TLS and Authentic Data¶- QDnsLookupsupports DNS-over-TLS (DoT, as specified by RFC 7858) on some platforms. That currently includes all Unix platforms where regular queries are supported, if- QSslSocketsupport is present in Qt. To query if support is present at runtime, use- isProtocolSupported().- When using DNS-over-TLS, - QDnsLookuponly implements the “Opportunistic Privacy Profile” method of authentication, as described in RFC 7858 section 4.1. In this mode,- QDnsLookup(through- QSslSocket) only validates that the server presents a certificate that is valid for the server being connected to. Clients may use- setSslConfiguration()to impose additional restrictions and- sslConfiguration()to obtain information after the query is complete.- QDnsLookupwill request DNS servers queried over TLS to perform authentication on the data they return. If they confirm the data is valid, the- authenticDataproperty will be set to true.- QDnsLookupdoes not verify the integrity of the data by itself, so applications should only trust this property on servers they have confirmed through other means to be trustworthy.- Authentic Data without TLS¶- QDnsLookuprequest Authentic Data for any server set with- setNameserver(), even if TLS encryption is not required. This is useful when querying a caching nameserver on the same host as the application or on a trusted network. Though similar to the TLS case, the application is responsible for determining if the server it chose to use is trustworthy, and if the unencrypted connection cannot be tampered with.- QDnsLookupobeys the system configuration to request Authentic Data on the default nameserver (that is, if- setNameserver()is not called). This is currently only supported on Linux systems using glibc 2.31 or later. On any other systems,- QDnsLookupwill ignore the AD bit in the query header.- class Error¶
- Indicates all possible error conditions found during the processing of the DNS lookup. - Constant - Description - QDnsLookup.Error.NoError - no error condition. - QDnsLookup.Error.ResolverError - there was an error initializing the system’s DNS resolver. - QDnsLookup.Error.OperationCancelledError - the lookup was aborted using the - abort()method.- QDnsLookup.Error.InvalidRequestError - the requested DNS lookup was invalid. - QDnsLookup.Error.InvalidReplyError - the reply returned by the server was invalid. - QDnsLookup.Error.ServerFailureError - the server encountered an internal failure while processing the request (SERVFAIL). - QDnsLookup.Error.ServerRefusedError - the server refused to process the request for security or policy reasons (REFUSED). - QDnsLookup.Error.NotFoundError - the requested domain name does not exist (NXDOMAIN). - QDnsLookup.Error.TimeoutError - the server was not reached or did not reply in time (since 6.6). 
 - class Type¶
- Indicates the type of DNS lookup that was performed. - Constant - Description - QDnsLookup.Type.A - IPv4 address records. - QDnsLookup.Type.AAAA - IPv6 address records. - QDnsLookup.Type.ANY - any records. - QDnsLookup.Type.CNAME - canonical name records. - QDnsLookup.Type.MX - mail exchange records. - QDnsLookup.Type.NS - name server records. - QDnsLookup.Type.PTR - pointer records. - QDnsLookup.Type.SRV - service records. - QDnsLookup.Type.TLSA - TLS association records. - QDnsLookup.Type.TXT - text records. 
 - class Protocol¶
- Indicates the type of DNS server that is being queried. - Constant - Description - QDnsLookup.Protocol.Standard - Regular, unencrypted DNS, using UDP and falling back to TCP as necessary (default port: 53) - QDnsLookup.Protocol.DnsOverTls - Encrypted DNS over TLS (DoT, as specified by RFC 7858), over TCP (default port: 853) - Added in version 6.8. 
 - Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property authenticDataᅟ: bool¶
 - This property holds whether the reply was authenticated by the resolver.. - QDnsLookupdoes not perform the authentication itself. Instead, it trusts the name server that was queried to perform the authentication and report it. The application is responsible for determining if any servers it configured with- setNameserver()are trustworthy; if no server was set,- QDnsLookupobeys system configuration on whether responses should be trusted.- This property may be set even if - error()indicates a resolver error occurred.- See also - Access functions:
- Signal - finished()
 
 - property errorᅟ: QDnsLookup.Error¶
 - This property holds the type of error that occurred if the DNS lookup failed, or - NoError..- Access functions:
- Signal - finished()
 
 - property errorStringᅟ: str¶
 - This property holds a human-readable description of the error if the DNS lookup failed.. - Access functions:
- Signal - finished()
 
 - property nameᅟ: str¶
 - This property holds the name to lookup.. - If the name to look up is empty, - QDnsLookupwill attempt to resolve the root domain of DNS. That query is usually performed with- typeset 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:
- Signal - nameChanged()
 
 - property nameserverᅟ: QHostAddress¶
 - This property holds the nameserver to use for DNS lookup.. - Access functions:
 - property nameserverPortᅟ: int¶
 - This property holds the port number of nameserver to use for DNS lookup.. - The value of 0 indicates that - QDnsLookupshould use the default port for the- nameserverProtocol().- 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, if the - nameserverProtocol()to be used- Standard. Notably, the Windows API used by- QDnsLookupis unable to handle alternate port numbers.- Access functions:
 - property nameserverProtocolᅟ: QDnsLookup.Protocol¶
 - This property holds the protocol to use when sending the DNS query. - See also - Access functions:
 - property typeᅟ: QDnsLookup.Type¶
 - This property holds the type of DNS lookup.. - Access functions:
- Signal - typeChanged()
 
 - Constructs a - QDnsLookupobject and sets- parentas the parent object.- The - typeproperty will default to- A.- Constructs a - QDnsLookupobject for the given- typeand- nameand sets- parentas the parent object.- __init__(type, name, nameserver[, parent=None])
- Parameters:
- type – - Type
- name – str 
- nameserver – - QHostAddress
- parent – - QObject
 
 
 - Constructs a - QDnsLookupobject to issue a query for- nameof record type- type, using the DNS server- nameserverrunning on the default DNS port, and sets- parentas the parent object.- __init__(type, name, nameserver, port[, parent=None])
- Parameters:
- type – - Type
- name – str 
- nameserver – - QHostAddress
- port – int 
- parent – - QObject
 
 
 - Constructs a - QDnsLookupobject to issue a query for- nameof record type- type, using the DNS server- nameserverrunning on port- port, and sets- parentas 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, if the - nameserverProtocol()to be used- Standard. Notably, the Windows API used by- QDnsLookupis unable to handle alternate port numbers.- __init__(type, name, protocol, nameserver[, port=0[, parent=None]])
- Parameters:
- type – - Type
- name – str 
- protocol – - Protocol
- nameserver – - QHostAddress
- port – int 
- parent – - QObject
 
 
 - Constructs a - QDnsLookupobject to issue a query for- nameof record type- type, using the DNS server- nameserverrunning on port- port, and sets- parentas the parent object.- The query will be sent using - protocol, if supported. Use- isProtocolSupported()to check if it is supported.- 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, if the - nameserverProtocol()to be used- Standard. Notably, the Windows API used by- QDnsLookupis unable to handle alternate port numbers.- abort()¶
 - Aborts the DNS lookup operation. - If the lookup is already finished, does nothing. - canonicalNameRecords()¶
- Return type:
- .list of QDnsDomainNameRecord 
 
 - Returns the list of canonical name records associated with this lookup. - Returns the standard (default) port number for the protocol - protocol.- See also - Getter of property - errorᅟ.- errorString()¶
- Return type:
- str 
 
 - Getter of property - errorStringᅟ.- finished()¶
 - This signal is emitted when the reply has finished processing. - Notification signal of property - errorᅟ.- hostAddressRecords()¶
- Return type:
- .list of QDnsHostAddressRecord 
 
 - Returns the list of host address records associated with this lookup. - isAuthenticData()¶
- Return type:
- bool 
 
 - Getter of property - authenticDataᅟ.- isFinished()¶
- Return type:
- bool 
 
 - Returns whether the reply has finished or was aborted. - Returns true if DNS queries using - protocolare supported with- QDnsLookup.- See also - lookup()¶
 - Performs the DNS lookup. - The - finished()signal is emitted upon completion.- 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. - Getter of property - nameᅟ.- nameChanged(name)¶
- Parameters:
- name – str 
 
 - This signal is emitted when the lookup - namechanges.- nameis the new lookup name.- Notification signal of property - nameᅟ.- nameServerRecords()¶
- Return type:
- .list of QDnsDomainNameRecord 
 
 - Returns the list of name server records associated with this lookup. - nameserver()¶
- Return type:
 - See also 
 - Getter of property - nameserverᅟ.- nameserverChanged(nameserver)¶
- Parameters:
- nameserver – - QHostAddress
 
 - Notification signal of property - nameserverᅟ.- nameserverPort()¶
- Return type:
- int 
 - See also 
 - Getter of property - nameserverPortᅟ.- nameserverPortChanged(port)¶
- Parameters:
- port – int 
 
 - Notification signal of property - nameserverPortᅟ.- nameserverProtocol()¶
- Return type:
 - See also 
 - Getter of property - nameserverProtocolᅟ.- Notification signal of property - nameserverProtocolᅟ.- pointerRecords()¶
- Return type:
- .list of QDnsDomainNameRecord 
 
 - Returns the list of pointer records associated with this lookup. - 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. - Setter of property - nameᅟ.- setNameserver(nameserver)¶
- Parameters:
- nameserver – - QHostAddress
 - See also 
 - Setter of property - nameserverᅟ.- setNameserver(nameserver, port)
- Parameters:
- nameserver – - QHostAddress
- port – int 
 
 
 - Sets the nameserver to - nameserverand 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, if the - nameserverProtocol()to be used- Standard. Notably, the Windows API used by- QDnsLookupis unable to handle alternate port numbers.- See also - setNameserver(protocol, nameserver[, port=0])
- Parameters:
- protocol – - Protocol
- nameserver – - QHostAddress
- port – int 
 
 - See also 
 - setNameserverPort(port)¶
- Parameters:
- port – int 
 - See also 
 - Setter of property - nameserverPortᅟ.- Setter of property - nameserverProtocolᅟ.- setSslConfiguration(sslConfiguration)¶
- Parameters:
- sslConfiguration – - QSslConfiguration
 
 - Sets the - sslConfigurationto use for outgoing DNS-over-TLS connections.- See also - Setter of property - typeᅟ.- sslConfiguration()¶
- Return type:
 
 - Returns the current SSL configuration. - See also - textRecords()¶
- Return type:
- .list of QDnsTextRecord 
 
 - Returns the list of text records associated with this lookup. - tlsAssociationRecords()¶
- Return type:
- .list of QDnsTlsAssociationRecord 
 
 - Returns the list of TLS association records associated with this lookup. - According to the standards relating to DNS-based Authentication of Named Entities (DANE), this field should be ignored and must not be used for verifying the authentity of a given server if the authenticity of the DNS reply cannot itself be confirmed. See - isAuthenticData()for more information.- Getter of property - typeᅟ.- This signal is emitted when the lookup - typechanges.- typeis the new lookup type.- Notification signal of property - typeᅟ.