19#include <QtNetwork/private/qtnetworkglobal_p.h>
20#include "QtCore/qmutex.h"
21#include "QtCore/qrunnable.h"
23#include "QtCore/qthreadpool.h"
25#include "QtNetwork/qdnslookup.h"
26#include "QtNetwork/qhostaddress.h"
27#include "private/qobject_p.h"
28#include "private/qurl_p.h"
31# include "qsslconfiguration.h"
40constexpr qsizetype MaxDomainNameLength = 255;
68 void setError(QDnsLookup::Error err, QString &&msg)
71 errorString = std::move(msg);
76 Q_ASSERT(allAreEmpty());
77 setError(QDnsLookup::ResolverError, qt_error_string(code));
82 Q_ASSERT(allAreEmpty());
83 setError(QDnsLookup::TimeoutError, QDnsLookup::tr(
"Request timed out"));
88 Q_ASSERT(allAreEmpty());
91 error = QDnsLookup::InvalidRequestError;
92 errorString = QDnsLookup::tr(
"Server could not process query");
96 error = QDnsLookup::ServerFailureError;
97 errorString = QDnsLookup::tr(
"Server failure");
100 error = QDnsLookup::NotFoundError;
101 errorString = QDnsLookup::tr(
"Non existent domain");
104 error = QDnsLookup::ServerRefusedError;
105 errorString = QDnsLookup::tr(
"Server refused to answer");
108 error = QDnsLookup::InvalidReplyError;
109 errorString = QDnsLookup::tr(
"Invalid reply received (rcode %1)")
118 msg = QDnsLookup::tr(
"Invalid reply received");
120 msg = QDnsLookup::tr(
"Invalid reply received (%1)").arg(std::move(msg));
122 setError(QDnsLookup::InvalidReplyError, std::move(msg));
126 bool allAreEmpty()
const
128 return canonicalNameRecords.isEmpty()
129 && hostAddressRecords.isEmpty()
130 && mailExchangeRecords.isEmpty()
131 && nameServerRecords.isEmpty()
132 && pointerRecords.isEmpty()
133 && serviceRecords.isEmpty()
134 && tlsAssociationRecords.isEmpty()
135 && textRecords.isEmpty();
150 emit q_func()->nameChanged(name);
153 &QDnsLookupPrivate::nameChanged);
157 emit q_func()->nameserverChanged(nameserver);
160 &QDnsLookupPrivate::nameserverChanged);
164 emit q_func()->typeChanged(type);
168 type, &QDnsLookupPrivate::typeChanged);
172 emit q_func()->nameserverPortChanged(port);
176 port, &QDnsLookupPrivate::nameserverPortChanged);
180 emit q_func()->nameserverProtocolChanged(protocol);
184 protocol, &QDnsLookupPrivate::nameserverProtocolChanged);
194 Q_DECLARE_PUBLIC(QDnsLookup)
219 template <
typename T>
static QString decodeLabel(T encodedLabel)
221 return qt_ACE_do(encodedLabel.toString(), NormalizeAce, ForbidLeadingDot);
225 EncodedLabel requestName;
226 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.
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,...)