Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdnslookup.h
Go to the documentation of this file.
1// Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QDNSLOOKUP_H
5#define QDNSLOOKUP_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/qlist.h>
9#include <QtCore/qobject.h>
10#include <QtCore/qshareddata.h>
11#include <QtCore/qstring.h>
12#include <QtCore/qproperty.h>
13
15
17
18class QHostAddress;
27
29
30class Q_NETWORK_EXPORT QDnsDomainNameRecord
31{
32public:
38
39 void swap(QDnsDomainNameRecord &other) noexcept { d.swap(other.d); }
40
41 QString name() const;
42 quint32 timeToLive() const;
43 QString value() const;
44
45private:
46 QSharedDataPointer<QDnsDomainNameRecordPrivate> d;
47 friend class QDnsLookupRunnable;
48};
49
50Q_DECLARE_SHARED(QDnsDomainNameRecord)
51
52class Q_NETWORK_EXPORT QDnsHostAddressRecord
53{
54public:
60
61 void swap(QDnsHostAddressRecord &other) noexcept { d.swap(other.d); }
62
63 QString name() const;
64 quint32 timeToLive() const;
65 QHostAddress value() const;
66
67private:
68 QSharedDataPointer<QDnsHostAddressRecordPrivate> d;
69 friend class QDnsLookupRunnable;
70};
71
72Q_DECLARE_SHARED(QDnsHostAddressRecord)
73
74class Q_NETWORK_EXPORT QDnsMailExchangeRecord
75{
76public:
82
83 void swap(QDnsMailExchangeRecord &other) noexcept { d.swap(other.d); }
84
85 QString exchange() const;
86 QString name() const;
87 quint16 preference() const;
88 quint32 timeToLive() const;
89
90private:
91 QSharedDataPointer<QDnsMailExchangeRecordPrivate> d;
92 friend class QDnsLookupRunnable;
93};
94
95Q_DECLARE_SHARED(QDnsMailExchangeRecord)
96
97class Q_NETWORK_EXPORT QDnsServiceRecord
98{
99public:
103 QDnsServiceRecord &operator=(const QDnsServiceRecord &other);
105
106 void swap(QDnsServiceRecord &other) noexcept { d.swap(other.d); }
107
108 QString name() const;
109 quint16 port() const;
110 quint16 priority() const;
111 QString target() const;
112 quint32 timeToLive() const;
113 quint16 weight() const;
114
115private:
116 QSharedDataPointer<QDnsServiceRecordPrivate> d;
117 friend class QDnsLookupRunnable;
118};
119
120Q_DECLARE_SHARED(QDnsServiceRecord)
121
122class Q_NETWORK_EXPORT QDnsTextRecord
123{
124public:
127 QDnsTextRecord &operator=(QDnsTextRecord &&other) noexcept { swap(other); return *this; }
128 QDnsTextRecord &operator=(const QDnsTextRecord &other);
130
131 void swap(QDnsTextRecord &other) noexcept { d.swap(other.d); }
132
133 QString name() const;
134 quint32 timeToLive() const;
135 QList<QByteArray> values() const;
136
137private:
138 QSharedDataPointer<QDnsTextRecordPrivate> d;
139 friend class QDnsLookupRunnable;
140};
141
142Q_DECLARE_SHARED(QDnsTextRecord)
143
144class Q_NETWORK_EXPORT QDnsTlsAssociationRecord
145{
147 Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
148public:
150 // https://www.iana.org/assignments/dane-parameters/dane-parameters.xhtml#certificate-usages
151 // RFC 6698
152 CertificateAuthorityConstrait = 0,
153 ServiceCertificateConstraint = 1,
154 TrustAnchorAssertion = 2,
155 DomainIssuedCertificate = 3,
156 PrivateUse = 255,
157
158 // Aliases by RFC 7218
159 PKIX_TA = 0,
160 PKIX_EE = 1,
161 DANE_TA = 2,
162 DANE_EE = 3,
163 PrivCert = 255,
164 };
165 Q_ENUM(CertificateUsage)
166
167 enum class Selector : quint8 {
168 // https://www.iana.org/assignments/dane-parameters/dane-parameters.xhtml#selectors
169 // RFC 6698
170 FullCertificate = 0,
171 SubjectPublicKeyInfo = 1,
172 PrivateUse = 255,
173
174 // Aliases by RFC 7218
175 Cert = FullCertificate,
176 SPKI = SubjectPublicKeyInfo,
177 PrivSel = PrivateUse,
178 };
179 Q_ENUM(Selector)
180
181 enum class MatchingType : quint8 {
182 // https://www.iana.org/assignments/dane-parameters/dane-parameters.xhtml#matching-types
183 // RFC 6698
184 Exact = 0,
185 Sha256 = 1,
186 Sha512 = 2,
187 PrivateUse = 255,
188 PrivMatch = PrivateUse,
189 };
190 Q_ENUM(MatchingType)
191
195 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QDnsTlsAssociationRecord)
198
200
201 QString name() const;
202 quint32 timeToLive() const;
203 CertificateUsage usage() const;
204 Selector selector() const;
205 MatchingType matchType() const;
206 QByteArray value() const;
207
208private:
209 QExplicitlySharedDataPointer<QDnsTlsAssociationRecordPrivate> d;
210 friend class QDnsLookupRunnable;
211};
212
213Q_DECLARE_SHARED(QDnsTlsAssociationRecord)
214
215class Q_NETWORK_EXPORT QDnsLookup : public QObject
216{
219 Q_PROPERTY(bool authenticData READ isAuthenticData NOTIFY finished)
220 Q_PROPERTY(QString errorString READ errorString NOTIFY finished)
221 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged BINDABLE bindableName)
222 Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged BINDABLE bindableType)
223 Q_PROPERTY(QHostAddress nameserver READ nameserver WRITE setNameserver NOTIFY nameserverChanged
224 BINDABLE bindableNameserver)
225 Q_PROPERTY(quint16 nameserverPort READ nameserverPort WRITE setNameserverPort
226 NOTIFY nameserverPortChanged BINDABLE bindableNameserverPort)
227 Q_PROPERTY(Protocol nameserverProtocol READ nameserverProtocol WRITE setNameserverProtocol
228 NOTIFY nameserverProtocolChanged BINDABLE bindableNameserverProtocol)
229
230public:
244
245 enum Type
246 {
247 A = 1,
248 AAAA = 28,
249 ANY = 255,
250 CNAME = 5,
251 MX = 15,
252 NS = 2,
253 PTR = 12,
254 SRV = 33,
255 TLSA = 52,
256 TXT = 16
257 };
258 Q_ENUM(Type)
259
261 Standard = 0,
263 };
264 Q_ENUM(Protocol)
265
266 explicit QDnsLookup(QObject *parent = nullptr);
267 QDnsLookup(Type type, const QString &name, QObject *parent = nullptr);
268 QDnsLookup(Type type, const QString &name, const QHostAddress &nameserver, QObject *parent = nullptr);
269 QDnsLookup(Type type, const QString &name, const QHostAddress &nameserver, quint16 port,
270 QObject *parent = nullptr);
271 QDnsLookup(Type type, const QString &name, Protocol protocol, const QHostAddress &nameserver,
272 quint16 port = 0, QObject *parent = nullptr);
273 ~QDnsLookup();
274
275 bool isAuthenticData() const;
276 Error error() const;
277 QString errorString() const;
278 bool isFinished() const;
279
280 QString name() const;
281 void setName(const QString &name);
282 QBindable<QString> bindableName();
283
284 Type type() const;
286 QBindable<Type> bindableType();
287
288 QHostAddress nameserver() const;
289 void setNameserver(const QHostAddress &nameserver);
290 QBindable<QHostAddress> bindableNameserver();
291 quint16 nameserverPort() const;
292 void setNameserverPort(quint16 port);
293 QBindable<quint16> bindableNameserverPort();
294 Protocol nameserverProtocol() const;
295 void setNameserverProtocol(Protocol protocol);
296 QBindable<Protocol> bindableNameserverProtocol();
297 void setNameserver(Protocol protocol, const QHostAddress &nameserver, quint16 port = 0);
298 QT_NETWORK_INLINE_SINCE(6, 8)
299 void setNameserver(const QHostAddress &nameserver, quint16 port);
300
301 QList<QDnsDomainNameRecord> canonicalNameRecords() const;
302 QList<QDnsHostAddressRecord> hostAddressRecords() const;
303 QList<QDnsMailExchangeRecord> mailExchangeRecords() const;
304 QList<QDnsDomainNameRecord> nameServerRecords() const;
305 QList<QDnsDomainNameRecord> pointerRecords() const;
306 QList<QDnsServiceRecord> serviceRecords() const;
307 QList<QDnsTextRecord> textRecords() const;
308 QList<QDnsTlsAssociationRecord> tlsAssociationRecords() const;
309
310#if QT_CONFIG(ssl)
311 void setSslConfiguration(const QSslConfiguration &sslConfiguration);
312 QSslConfiguration sslConfiguration() const;
313#endif
314
315 static bool isProtocolSupported(Protocol protocol);
316 static quint16 defaultPortForProtocol(Protocol protocol) noexcept Q_DECL_CONST_FUNCTION;
317
318public Q_SLOTS:
319 void abort();
320 void lookup();
321
323 void finished();
326 void nameserverChanged(const QHostAddress &nameserver);
329
330private:
331 Q_DECLARE_PRIVATE(QDnsLookup)
332};
333
334#if QT_NETWORK_INLINE_IMPL_SINCE(6, 8)
335void QDnsLookup::setNameserver(const QHostAddress &nameserver, quint16 port)
336{
338}
339#endif
340
342
343#endif // QDNSLOOKUP_H
\inmodule QtCore
Definition qbytearray.h:57
The QDnsDomainNameRecord class stores information about a domain name record.
Definition qdnslookup.h:31
void swap(QDnsDomainNameRecord &other) noexcept
Swaps this domain-name record instance with other.
Definition qdnslookup.h:39
QDnsDomainNameRecord & operator=(QDnsDomainNameRecord &&other) noexcept
Definition qdnslookup.h:35
The QDnsHostAddressRecord class stores information about a host address record.
Definition qdnslookup.h:53
void swap(QDnsHostAddressRecord &other) noexcept
Swaps this host address record instance with other.
Definition qdnslookup.h:61
QDnsHostAddressRecord & operator=(QDnsHostAddressRecord &&other) noexcept
Definition qdnslookup.h:57
void finished(const QDnsLookupReply &reply)
The QDnsLookup class represents a DNS lookup.
Definition qdnslookup.h:216
Type
Indicates the type of DNS lookup that was performed.
Definition qdnslookup.h:246
void typeChanged(QDnsLookup::Type type)
This signal is emitted when the lookup \l type changes.
QHostAddress nameserver
the nameserver to use for DNS lookup.
Definition qdnslookup.h:224
void nameserverPortChanged(quint16 port)
Error
Indicates all possible error conditions found during the processing of the DNS lookup.
Definition qdnslookup.h:232
@ InvalidReplyError
Definition qdnslookup.h:237
@ OperationCancelledError
Definition qdnslookup.h:235
@ ServerRefusedError
Definition qdnslookup.h:239
@ ServerFailureError
Definition qdnslookup.h:238
@ InvalidRequestError
Definition qdnslookup.h:236
void finished()
This signal is emitted when the reply has finished processing.
Protocol
Indicates the type of DNS server that is being queried.
Definition qdnslookup.h:260
void nameserverProtocolChanged(QDnsLookup::Protocol protocol)
void setNameserver(const QHostAddress &nameserver)
void nameChanged(const QString &name)
This signal is emitted when the lookup \l name changes.
void nameserverChanged(const QHostAddress &nameserver)
The QDnsMailExchangeRecord class stores information about a DNS MX record.
Definition qdnslookup.h:75
void swap(QDnsMailExchangeRecord &other) noexcept
Swaps this mail exchange record with other.
Definition qdnslookup.h:83
QDnsMailExchangeRecord & operator=(QDnsMailExchangeRecord &&other) noexcept
Definition qdnslookup.h:79
The QDnsServiceRecord class stores information about a DNS SRV record.
Definition qdnslookup.h:98
void swap(QDnsServiceRecord &other) noexcept
Swaps this service record instance with other.
Definition qdnslookup.h:106
QDnsServiceRecord & operator=(QDnsServiceRecord &&other) noexcept
Definition qdnslookup.h:102
The QDnsTextRecord class stores information about a DNS TXT record.
Definition qdnslookup.h:123
void swap(QDnsTextRecord &other) noexcept
Swaps this text record instance with other.
Definition qdnslookup.h:131
QDnsTextRecord & operator=(QDnsTextRecord &&other) noexcept
Definition qdnslookup.h:127
The QDnsTlsAssociationRecord class stores information about a DNS TLSA record.
Definition qdnslookup.h:145
void swap(QDnsTlsAssociationRecord &other) noexcept
Definition qdnslookup.h:199
CertificateUsage
This enumeration contains valid values for the certificate usage field of TLS Association queries.
Definition qdnslookup.h:149
Selector
This enumeration contains valid values for the selector field of TLS Association queries.
Definition qdnslookup.h:167
QDnsTlsAssociationRecord(QDnsTlsAssociationRecord &&other) noexcept=default
MatchingType
This enumeration contains valid values for the matching type field of TLS Association queries.
Definition qdnslookup.h:181
QDnsTlsAssociationRecord(const QDnsTlsAssociationRecord &other)
Constructs a copy of other.
The QHostAddress class provides an IP address.
Definition qlist.h:76
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
The QSslConfiguration class holds the configuration and state of an SSL connection.
QSslConfiguration & operator=(QSslConfiguration &&other) noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
employee setName("Richard Schmit")
Combined button and popup list for selecting options.
#define Q_DECL_CONST_FUNCTION
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputPortEXT port
#define NS(x)
Definition qmetatype.cpp:64
n varying highp vec2 A
GLenum GLsizei GLsizei GLint * values
[15]
GLuint GLuint GLfloat weight
GLenum type
GLenum target
GLuint name
GLsizeiptr const void GLenum usage
Definition qopenglext.h:543
#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR(Class)
@ NoError
Definition main.cpp:34
#define QT_REQUIRE_CONFIG(feature)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_CLASSINFO(name, value)
#define Q_SLOTS
#define Q_GADGET
#define Q_SIGNALS
unsigned int quint32
Definition qtypes.h:50
unsigned short quint16
Definition qtypes.h:48
unsigned char quint8
Definition qtypes.h:46
QFileSelector selector
[1]
QSharedPointer< T > other(t)
[5]
this swap(other)
proxy setType(QNetworkProxy::Socks5Proxy)
sslSocket setSslConfiguration(config)
Definition moc.h:23