From a2530e3b9300e5fc4492ff0e961c7a89d296d27d Mon Sep 17 00:00:00 2001 From: Spotlight Date: Tue, 21 Jun 2022 21:44:16 -0500 Subject: [PATCH 1/2] IOS: Use first available IPv4 nameserver --- Source/Core/Core/IOS/Network/IP/Top.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index 3f94fe737c..05a3600cbd 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -868,9 +868,22 @@ IPCReply NetIPTopDevice::HandleGetInterfaceOptRequest(const IOCtlVRequest& reque if (!Core::WantsDeterminism()) { if (res_init() == 0) - address = ntohl(_res.nsaddr_list[0].sin_addr.s_addr); + { + for (int i = 0; i < _res.nscount; i++) + { + // Find the first available IPv4 nameserver. + sockaddr_in current = _res.nsaddr_list[i]; + if (current.sin_family == AF_INET) + { + address = ntohl(_res.nsaddr_list[i].sin_addr.s_addr); + break; + } + } + } else + { WARN_LOG_FMT(IOS_NET, "Call to res_init failed"); + } } #endif if (address == 0) From 430c58cf27a4e27a28ccd36b2d4399168718cd30 Mon Sep 17 00:00:00 2001 From: Spotlight Date: Tue, 21 Jun 2022 21:46:26 -0500 Subject: [PATCH 2/2] IOS: Use host nameserver on more BSDs --- Source/Core/Core/CMakeLists.txt | 1 + Source/Core/Core/IOS/Network/IP/Top.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 6dc3041eed..f958f7dd70 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -605,6 +605,7 @@ if (APPLE) ${CORESERV_LIBRARY} ${IOB_LIBRARY} ${IOK_LIBRARY} + resolv ) elseif (ANDROID) target_link_libraries(core diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index 05a3600cbd..74b4a02428 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -864,7 +864,8 @@ IPCReply NetIPTopDevice::HandleGetInterfaceOptRequest(const IOCtlVRequest& reque FREE(AdapterAddresses); } } -#elif defined(__linux__) && !defined(__ANDROID__) +#elif (defined(__linux__) && !defined(ANDROID)) || defined(__APPLE__) || defined(__FreeBSD__) || \ + defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) if (!Core::WantsDeterminism()) { if (res_init() == 0)