24 QDnsLookupThreadPool()
37 return r1.preference() <
r2.preference();
47 if (records.
size() <= 1)
54 while (
i < records.
size()) {
58 const quint16 slicePreference = records.
at(
i).preference();
59 for (
int j =
i;
j < records.
size(); ++
j) {
60 if (records.
at(
j).preference() != slicePreference)
62 slice << records.
at(
j);
77 return r1.priority() <
r2.priority()
78 || (
r1.priority() ==
r2.priority()
79 &&
r1.weight() == 0 &&
r2.weight() > 0);
89 if (records.
size() <= 1)
97 while (
i < records.
size()) {
101 const quint16 slicePriority = records.
at(
i).priority();
102 unsigned int sliceWeight = 0;
103 for (
int j =
i;
j < records.
size(); ++
j) {
104 if (records.
at(
j).priority() != slicePriority)
106 sliceWeight += records.
at(
j).weight();
107 slice << records.
at(
j);
109#ifdef QDNSLOOKUP_DEBUG
110 qDebug(
"qt_qdnsservicerecord_sort() : priority %i (size: %i, total weight: %i)",
111 slicePriority, slice.
size(), sliceWeight);
117 unsigned int summedWeight = 0;
118 for (
int j = 0;
j < slice.
size(); ++
j) {
119 summedWeight += slice.
at(
j).weight();
120 if (summedWeight >= weightThreshold) {
121#ifdef QDNSLOOKUP_DEBUG
122 qDebug(
"qt_qdnsservicerecord_sort() : adding %s %i (weight: %i)",
124 slice.
at(
j).weight());
127 sliceWeight -= slice.
at(
j).weight();
320 return d_func()->reply.error;
330 return d_func()->reply.errorString;
339 return d_func()->isFinished;
356 return d_func()->name;
378 return d_func()->type;
400 return d_func()->nameserver;
412 return &
d->nameserver;
424 return d_func()->port;
461 return d_func()->reply.canonicalNameRecords;
470 return d_func()->reply.hostAddressRecords;
483 return d_func()->reply.mailExchangeRecords;
492 return d_func()->reply.nameServerRecords;
501 return d_func()->reply.pointerRecords;
514 return d_func()->reply.serviceRecords;
523 return d_func()->reply.textRecords;
536 d->runnable =
nullptr;
539 d->reply.errorString =
tr(
"Operation cancelled");
540 d->isFinished =
true;
554 d->isFinished =
false;
558 qWarning(
"QDnsLookup requires a QCoreApplication");
565#ifdef QDNSLOOKUP_DEBUG
569 d->runnable =
nullptr;
570 d->isFinished =
true;
578 theDnsLookupThreadPool->start(
d->runnable);
1058 if (
label.isEmpty())
1063 return encodedLabel;
1065 return std::move(encodedLabel).
toLatin1();
1071 nameserver(
d->nameserver),
1072 requestType(
d->
type),
1110 <<
"DNS lookup failed (" <<
reply.
error <<
"): "
1112 <<
"; request was " <<
this;
1121 d <<
"... (truncated)";
1122 d <<
" type " <<
r->requestType;
1123 if (!
r->nameserver.isNull())
1125 <<
" port " << (
r->port ?
r->port :
DnsPort);
1131#include "moc_qdnslookup.cpp"
1132#include "moc_qdnslookup_p.cpp"
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
The QDnsDomainNameRecord class stores information about a domain name record.
QString name() const
Returns the name for this record.
QString value() const
Returns the value for this domain name record.
QDnsDomainNameRecord & operator=(QDnsDomainNameRecord &&other) noexcept
QDnsDomainNameRecord()
Constructs an empty domain name record object.
quint32 timeToLive() const
Returns the duration in seconds for which this record is valid.
~QDnsDomainNameRecord()
Destroys a domain name record.
The QDnsHostAddressRecord class stores information about a host address record.
QHostAddress value() const
Returns the value for this host address record.
~QDnsHostAddressRecord()
Destroys a host address record.
QDnsHostAddressRecord()
Constructs an empty host address record object.
quint32 timeToLive() const
Returns the duration in seconds for which this record is valid.
QDnsHostAddressRecord & operator=(QDnsHostAddressRecord &&other) noexcept
QString name() const
Returns the name for this record.
void finished(const QDnsLookupReply &reply)
QDnsLookupRunnable(const QDnsLookupPrivate *d)
void run() override
Implement this pure virtual function in your subclass.
The QDnsLookup class represents a DNS lookup.
quint16 nameserverPort
the port number of nameserver to use for DNS lookup.
Type
Indicates the type of DNS lookup that was performed.
QBindable< QString > bindableName()
QString errorString
a human-readable description of the error if the DNS lookup failed.
QHostAddress nameserver
the nameserver to use for DNS lookup.
QList< QDnsServiceRecord > serviceRecords() const
Returns the list of service records associated with this lookup.
bool isFinished() const
Returns whether the reply has finished or was aborted.
QList< QDnsMailExchangeRecord > mailExchangeRecords() const
Returns the list of mail exchange records associated with this lookup.
void setName(const QString &name)
QList< QDnsDomainNameRecord > nameServerRecords() const
Returns the list of name server records associated with this lookup.
Error
Indicates all possible error conditions found during the processing of the DNS lookup.
@ OperationCancelledError
void abort()
Aborts the DNS lookup operation.
QBindable< quint16 > bindableNameserverPort()
void finished()
This signal is emitted when the reply has finished processing.
Error error
the type of error that occurred if the DNS lookup failed, or NoError.
void setType(QDnsLookup::Type)
QDnsLookup(QObject *parent=nullptr)
Constructs a QDnsLookup object and sets parent as the parent object.
QList< QDnsDomainNameRecord > canonicalNameRecords() const
Returns the list of canonical name records associated with this lookup.
void lookup()
Performs the DNS lookup.
void setNameserver(const QHostAddress &nameserver)
~QDnsLookup()
Destroys the QDnsLookup object.
QBindable< QHostAddress > bindableNameserver()
QList< QDnsDomainNameRecord > pointerRecords() const
Returns the list of pointer records associated with this lookup.
QBindable< Type > bindableType()
void setNameserverPort(quint16 port)
QList< QDnsHostAddressRecord > hostAddressRecords() const
Returns the list of host address records associated with this lookup.
Type type
the type of DNS lookup.
QString name
the name to lookup.
QList< QDnsTextRecord > textRecords() const
Returns the list of text records associated with this lookup.
The QDnsMailExchangeRecord class stores information about a DNS MX record.
~QDnsMailExchangeRecord()
Destroys a mail exchange record.
quint16 preference() const
Returns the preference for this record.
quint32 timeToLive() const
Returns the duration in seconds for which this record is valid.
QString name() const
Returns the name for this record.
QDnsMailExchangeRecord()
Constructs an empty mail exchange record object.
QDnsMailExchangeRecord & operator=(QDnsMailExchangeRecord &&other) noexcept
QString exchange() const
Returns the domain name of the mail exchange for this record.
The QDnsServiceRecord class stores information about a DNS SRV record.
QString target() const
Returns the domain name of the target host for this service record.
QDnsServiceRecord & operator=(QDnsServiceRecord &&other) noexcept
quint16 weight() const
Returns the weight for this service record.
quint32 timeToLive() const
Returns the duration in seconds for which this record is valid.
~QDnsServiceRecord()
Destroys a service record.
quint16 priority() const
Returns the priority for this service record.
QString name() const
Returns the name for this record.
quint16 port() const
Returns the port on the target host for this service record.
QDnsServiceRecord()
Constructs an empty service record object.
QList< QByteArray > values
The QDnsTextRecord class stores information about a DNS TXT record.
quint32 timeToLive() const
Returns the duration in seconds for which this record is valid.
QDnsTextRecord & operator=(QDnsTextRecord &&other) noexcept
QDnsTextRecord()
Constructs an empty text record object.
~QDnsTextRecord()
Destroys a text record.
QList< QByteArray > values() const
Returns the values for this text record.
QString name() const
Returns the name for this text record.
The QHostAddress class provides an IP address.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
NetworkError error() const
Returns the error that was found during the processing of this request.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
\threadsafe
double bounded(double highest)
Generates one random double in the range between 0 (inclusive) and highest (exclusive).
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
void setMaxThreadCount(int maxThreadCount)
Combined button and popup list for selecting options.
Q_CORE_EXPORT void beginPropertyUpdateGroup()
@ BlockingQueuedConnection
Q_CORE_EXPORT void endPropertyUpdateGroup()
#define Q_APPLICATION_STATIC(TYPE, NAME,...)
static void qt_qdnsmailexchangerecord_sort(QList< QDnsMailExchangeRecord > &records)
static void qt_qdnsservicerecord_sort(QList< QDnsServiceRecord > &records)
QDebug operator<<(QDebug &d, QDnsLookupRunnable *r)
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)
constexpr quint16 DnsPort
QT_BEGIN_NAMESPACE constexpr qsizetype MaxDomainNameLength
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
GLuint GLsizei const GLchar * label
[43]
#define qPrintable(string)
#define qUtf16Printable(string)
QString Q_CORE_EXPORT qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot, QUrl::AceProcessingOptions options={})
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent