QDnsLookup/Unix: add support for res_setservers()
This API is found on FreeBSD, Darwin, Solaris, AIX, and Android Bionic. That means we complement IPv6 support for most platforms. Test on macOS: $ $objdir/tests/manual/qdnslookup/qdnslookup @fe80::1e1b:dff:fee2:49e6%en0 ; <<>> QDnsLookup 6.6.0 ;; status: NoError ;; QUESTION: ;qt-project.org IN A ;; ANSWER: qt-project.org 3336 IN A 52.18.144.254 ;; Query time: 2 ms ;; SERVER: fe80::1e1b:dff:fee2:49e6%en0#53 Dnsmasq log on the server confirms it was queried. Change-Id: I3e3bfef633af4130a03afffd175d59c67faa463f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
eb9f88a078
commit
678964b242
@ -119,6 +119,25 @@ int main()
|
||||
"
|
||||
)
|
||||
|
||||
# res_setserver
|
||||
qt_config_compile_test(res_setservers
|
||||
LABEL "res_setservers()"
|
||||
LIBRARIES
|
||||
WrapResolv::WrapResolv
|
||||
CODE
|
||||
"#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <resolv.h>
|
||||
int main()
|
||||
{
|
||||
union res_sockaddr_union sa;
|
||||
res_state s = nullptr;
|
||||
res_setservers(s, &sa, 1);
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
)
|
||||
|
||||
# sctp
|
||||
qt_config_compile_test(sctp
|
||||
LABEL "SCTP support"
|
||||
@ -235,6 +254,10 @@ qt_feature("res_ninit" PRIVATE
|
||||
CONDITION TEST_res_ninit
|
||||
AUTODETECT UNIX
|
||||
)
|
||||
qt_feature("res_setservers" PRIVATE
|
||||
LABEL "res_setservers()"
|
||||
CONDITION QT_FEATURE_res_ninit AND TEST_res_setservers
|
||||
)
|
||||
qt_feature("securetransport" PUBLIC
|
||||
LABEL "SecureTransport"
|
||||
CONDITION APPLE
|
||||
|
@ -24,6 +24,19 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#if QT_CONFIG(res_setservers)
|
||||
// https://www.ibm.com/docs/en/i/7.3?topic=ssw_ibm_i_73/apis/ressetservers.html
|
||||
// https://docs.oracle.com/cd/E86824_01/html/E54774/res-setservers-3resolv.html
|
||||
static const char *applyNameServer(res_state state, const QHostAddress &nameserver, quint16 port)
|
||||
{
|
||||
if (nameserver.isNull())
|
||||
return nullptr;
|
||||
union res_sockaddr_union u;
|
||||
setSockaddr(reinterpret_cast<sockaddr *>(&u.sin), nameserver, port);
|
||||
res_setservers(state, &u, 1);
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
template <typename T> void setNsMap(T &ext, std::enable_if_t<sizeof(T::nsmap) != 0, uint16_t> v)
|
||||
{
|
||||
// Set nsmap[] to indicate that nsaddrs[0] is an IPv6 address
|
||||
@ -84,6 +97,7 @@ static const char *applyNameServer(res_state state, const QHostAddress &nameserv
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif // !QT_CONFIG(res_setservers)
|
||||
|
||||
void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user