9#include <private/qnativesocketengine_p.h>
10#include <private/qsystemerror_p.h>
16#ifndef DNS_ADDR_MAX_SOCKADDR_LENGTH
34# ifndef DNS_QUERY_RESULTS_VERSION1
72 request.QueryName =
reinterpret_cast<const wchar_t *
>(requestName.
constData());
73 request.QueryType = requestType;
74 request.QueryOptions = DNS_QUERY_STANDARD | DNS_QUERY_TREAT_AS_FQDN;
76 if (!nameserver.
isNull()) {
77 memset(dnsAddresses, 0,
sizeof(dnsAddresses));
80 auto sa =
new (
addr[0].MaxSa) sockaddr;
81 request.pDnsServerList->MaxCount =
sizeof(dnsAddresses);
82 request.pDnsServerList->AddrCount = 1;
85 request.pDnsServerList->Family = sa->sa_family;
91 if (status >= DNS_ERROR_RCODE_FORMAT_ERROR && status <= DNS_ERROR_RCODE_LAST)
92 return reply->makeDnsRcodeError(status - DNS_ERROR_RCODE_FORMAT_ERROR + 1);
93 else if (status == ERROR_TIMEOUT)
94 return reply->makeTimeoutError();
95 else if (status != ERROR_SUCCESS)
96 return reply->makeResolverSystemError(status);
101 lastEncodedName =
name;
102 cachedDecodedName = decodeLabel(
name);
103 return cachedDecodedName;
106 return lastEncodedName ==
name ? cachedDecodedName : extractAndCacheHost(
name);
132 record.d->value = extractAndCacheHost(
ptr->Data.Cname.pNameHost);
138 record.d->preference =
ptr->Data.Mx.wPreference;
158 record.d->priority =
ptr->Data.Srv.wPriority;
160 record.d->weight =
ptr->Data.Srv.wWeight;
166 for (
unsigned int i = 0;
i <
ptr->Data.Txt.dwStringCount; ++
i) {
173 DnsRecordListFree(
results.pQueryRecords, DnsFreeRecordList);
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
The QDnsDomainNameRecord class stores information about a domain name record.
The QDnsHostAddressRecord class stores information about a host address record.
The QDnsMailExchangeRecord class stores information about a DNS MX record.
The QDnsServiceRecord class stores information about a DNS SRV record.
The QDnsTextRecord class stores information about a DNS TXT record.
The QHostAddress class provides an IP address.
bool isNull() const
Returns true if this host address is not valid for any host or interface.
QByteArray toLatin1() const
Returns a Latin-1 representation of the string as a QByteArray.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
QT_SOCKLEN_T setSockaddr(sockaddr_in *sin, const QHostAddress &addr, quint16 port=0)
constexpr quint16 DnsPort
struct Qt_DnsAddrArray * PDNS_ADDR_ARRAY
struct Qt_DnsAddr DNS_ADDR
struct Qt_DnsAddrArray DNS_ADDR_ARRAY
VOID WINAPI DNS_QUERY_COMPLETION_ROUTINE(PVOID pQueryContext, PDNS_QUERY_RESULT pQueryResults)
DNS_STATUS WINAPI DnsQueryEx(PDNS_QUERY_REQUEST pQueryRequest, PDNS_QUERY_RESULT pQueryResults, PDNS_QUERY_CANCEL pCancelHandle)
struct Qt_DNS_QUERY_RESULT DNS_QUERY_RESULT
struct Qt_DnsAddr * PDNS_ADDR
struct Qt_DNS_QUERY_RESULT * PDNS_QUERY_RESULT
struct Qt_DNS_QUERY_REQUEST * PDNS_QUERY_REQUEST
DNS_QUERY_COMPLETION_ROUTINE * PDNS_QUERY_COMPLETION_ROUTINE
struct Qt_DNS_QUERY_REQUEST DNS_QUERY_REQUEST
static ControlElement< T > * ptr(QWidget *widget)
QNetworkRequest request(url)
PDNS_ADDR_ARRAY pDnsServerList
PDNS_QUERY_COMPLETION_ROUTINE pQueryCompletionCallback
PDNS_RECORD pQueryRecords
DWORD DnsAddrUserDword[8]