IOS: Use first available IPv4 nameserver

This commit is contained in:
Spotlight 2022-06-21 21:44:16 -05:00
parent 57750f3d8f
commit a2530e3b93
No known key found for this signature in database
GPG Key ID: 874AA355B3209BDC
1 changed files with 14 additions and 1 deletions

View File

@ -868,9 +868,22 @@ IPCReply NetIPTopDevice::HandleGetInterfaceOptRequest(const IOCtlVRequest& reque
if (!Core::WantsDeterminism()) if (!Core::WantsDeterminism())
{ {
if (res_init() == 0) 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 else
{
WARN_LOG_FMT(IOS_NET, "Call to res_init failed"); WARN_LOG_FMT(IOS_NET, "Call to res_init failed");
}
} }
#endif #endif
if (address == 0) if (address == 0)