20#include <QtNetwork/private/qtnetworkglobal_p.h>
21#include "QtCore/qmutex.h"
22#include "QtCore/qrunnable.h"
24#include "QtCore/qthreadpool.h"
26#include "QtNetwork/qdnslookup.h"
27#include "QtNetwork/qhostaddress.h"
28#include "private/qobject_p.h"
29#include "private/qurl_p.h"
32# include "qsslconfiguration.h"
41constexpr qsizetype MaxDomainNameLength = 255;
45#if QT_CONFIG(android_dnsresolver)
47bool qt_androidDnsResolverAvailable();
74 void setError(QDnsLookup::Error err, QString &&msg)
77 errorString = std::move(msg);
82 Q_ASSERT(allAreEmpty());
83 setError(QDnsLookup::ResolverError, qt_error_string(code));
88 Q_ASSERT(allAreEmpty());
89 setError(QDnsLookup::TimeoutError, QDnsLookup::tr(
"Request timed out"));
94 Q_ASSERT(allAreEmpty());
97 error = QDnsLookup::InvalidRequestError;
98 errorString = QDnsLookup::tr(
"Server could not process query");
102 error = QDnsLookup::ServerFailureError;
103 errorString = QDnsLookup::tr(
"Server failure");
106 error = QDnsLookup::NotFoundError;
107 errorString = QDnsLookup::tr(
"Non existent domain");
110 error = QDnsLookup::ServerRefusedError;
111 errorString = QDnsLookup::tr(
"Server refused to answer");
114 error = QDnsLookup::InvalidReplyError;
115 errorString = QDnsLookup::tr(
"Invalid reply received (rcode %1)")
124 msg = QDnsLookup::tr(
"Invalid reply received");
126 msg = QDnsLookup::tr(
"Invalid reply received (%1)").arg(std::move(msg));
128 setError(QDnsLookup::InvalidReplyError, std::move(msg));
132 bool allAreEmpty()
const
134 return canonicalNameRecords.isEmpty()
135 && hostAddressRecords.isEmpty()
136 && mailExchangeRecords.isEmpty()
137 && nameServerRecords.isEmpty()
138 && pointerRecords.isEmpty()
139 && serviceRecords.isEmpty()
140 && tlsAssociationRecords.isEmpty()
141 && textRecords.isEmpty();
156 emit q_func()->nameChanged(name);
159 &QDnsLookupPrivate::nameChanged);
163 emit q_func()->nameserverChanged(nameserver);
166 &QDnsLookupPrivate::nameserverChanged);
170 emit q_func()->typeChanged(type);
174 type, &QDnsLookupPrivate::typeChanged);
178 emit q_func()->nameserverPortChanged(port);
182 port, &QDnsLookupPrivate::nameserverPortChanged);
186 emit q_func()->nameserverProtocolChanged(protocol);
190 protocol, &QDnsLookupPrivate::nameserverProtocolChanged);
200 Q_DECLARE_PUBLIC(QDnsLookup)
225 template <
typename T>
static QString decodeLabel(T encodedLabel)
227 return qt_ACE_do(encodedLabel.toString(), NormalizeAce, ForbidLeadingDot);
230#if QT_CONFIG(libresolv) || QT_CONFIG(android_dnsresolver)
235 EncodedLabel requestName;
236 QHostAddress nameserver;
QDnsDomainNameRecordPrivate()
The QDnsDomainNameRecord class stores information about a domain name record.
QDnsHostAddressRecordPrivate()
The QDnsHostAddressRecord class stores information about a host address record.
Q_OBJECT_BINDABLE_PROPERTY(QDnsLookupPrivate, QString, name, &QDnsLookupPrivate::nameChanged)
QDnsLookupRunnable * runnable
void nameserverProtocolChanged()
void nameserverPortChanged()
void setError(QDnsLookup::Error err, QString &&msg)
QList< QDnsMailExchangeRecord > mailExchangeRecords
void makeDnsRcodeError(quint8 rcode)
QList< QDnsServiceRecord > serviceRecords
void makeInvalidReplyError(QString &&msg=QString())
QList< QDnsDomainNameRecord > canonicalNameRecords
QList< QDnsDomainNameRecord > nameServerRecords
QList< QDnsDomainNameRecord > pointerRecords
QList< QDnsHostAddressRecord > hostAddressRecords
void makeResolverSystemError(int code=-1)
QList< QDnsTlsAssociationRecord > tlsAssociationRecords
QList< QDnsTextRecord > textRecords
QDnsLookupRunnable(const QDnsLookupPrivate *d)
void run() override
Implement this pure virtual function in your subclass.
static constexpr qsizetype ReplyBufferSize
bool sendDnsOverTls(QDnsLookupReply *reply, QSpan< unsigned char > query, ReplyBuffer &response)
The QDnsLookup class represents a DNS lookup.
QDnsMailExchangeRecordPrivate()
The QDnsMailExchangeRecord class stores information about a DNS MX record.
QDnsServiceRecordPrivate()
The QDnsServiceRecord class stores information about a DNS SRV record.
QList< QByteArray > values
The QDnsTextRecord class stores information about a DNS TXT record.
QDnsTlsAssociationRecord::CertificateUsage usage
QDnsTlsAssociationRecord::MatchingType matchType
QDnsTlsAssociationRecord::Selector selector
The QDnsTlsAssociationRecord class stores information about a DNS TLSA record.
void swap(QDnsTlsAssociationRecord &other) noexcept
QDnsTlsAssociationRecord(QDnsTlsAssociationRecord &&other) noexcept=default
Q_NETWORK_EXPORT ~QDnsTlsAssociationRecord()
Destroys this TLS Association record object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(animation)
#define Q_APPLICATION_STATIC(TYPE, NAME,...)
static void qt_qdnsmailexchangerecord_sort(QList< QDnsMailExchangeRecord > &records)
static void qt_qdnsservicerecord_sort(QList< QDnsServiceRecord > &records)
static bool qt_qdnsmailexchangerecord_less_than(const QDnsMailExchangeRecord &r1, const QDnsMailExchangeRecord &r2)
static bool qt_qdnsservicerecord_less_than(const QDnsServiceRecord &r1, const QDnsServiceRecord &r2)
static QDnsLookupRunnable::EncodedLabel encodeLabel(const QString &label)
QT_REQUIRE_CONFIG(dnslookup)
constexpr quint16 DnsPort
constexpr quint16 DnsOverTlsPort
QDebug operator<<(QDebug &, QDnsLookupRunnable *)
#define qCWarning(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)