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;
69 void setError(QDnsLookup::Error err, QString &&msg)
72 errorString = std::move(msg);
77 Q_ASSERT(allAreEmpty());
78 setError(QDnsLookup::ResolverError, qt_error_string(code));
83 Q_ASSERT(allAreEmpty());
84 setError(QDnsLookup::TimeoutError, QDnsLookup::tr(
"Request timed out"));
89 Q_ASSERT(allAreEmpty());
92 error = QDnsLookup::InvalidRequestError;
93 errorString = QDnsLookup::tr(
"Server could not process query");
97 error = QDnsLookup::ServerFailureError;
98 errorString = QDnsLookup::tr(
"Server failure");
101 error = QDnsLookup::NotFoundError;
102 errorString = QDnsLookup::tr(
"Non existent domain");
105 error = QDnsLookup::ServerRefusedError;
106 errorString = QDnsLookup::tr(
"Server refused to answer");
109 error = QDnsLookup::InvalidReplyError;
110 errorString = QDnsLookup::tr(
"Invalid reply received (rcode %1)")
119 msg = QDnsLookup::tr(
"Invalid reply received");
121 msg = QDnsLookup::tr(
"Invalid reply received (%1)").arg(std::move(msg));
123 setError(QDnsLookup::InvalidReplyError, std::move(msg));
127 bool allAreEmpty()
const
129 return canonicalNameRecords.isEmpty()
130 && hostAddressRecords.isEmpty()
131 && mailExchangeRecords.isEmpty()
132 && nameServerRecords.isEmpty()
133 && pointerRecords.isEmpty()
134 && serviceRecords.isEmpty()
135 && tlsAssociationRecords.isEmpty()
136 && textRecords.isEmpty();
151 emit q_func()->nameChanged(name);
154 &QDnsLookupPrivate::nameChanged);
158 emit q_func()->nameserverChanged(nameserver);
161 &QDnsLookupPrivate::nameserverChanged);
165 emit q_func()->typeChanged(type);
169 type, &QDnsLookupPrivate::typeChanged);
173 emit q_func()->nameserverPortChanged(port);
177 port, &QDnsLookupPrivate::nameserverPortChanged);
181 emit q_func()->nameserverProtocolChanged(protocol);
185 protocol, &QDnsLookupPrivate::nameserverProtocolChanged);
195 Q_DECLARE_PUBLIC(QDnsLookup)
220 template <
typename T>
static QString decodeLabel(T encodedLabel)
222 return qt_ACE_do(encodedLabel.toString(), NormalizeAce, ForbidLeadingDot);
226 EncodedLabel requestName;
227 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.
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,...)