aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Luis Marti <joseluis.marti@gmail.com>2023-12-07 16:18:20 +0100
committerJose Luis Marti <joseluis.marti@gmail.com>2023-12-07 16:18:20 +0100
commit00fc14ae5e8a6b9ad627727291e4fb426639064f (patch)
tree96eb522cc2f1e971d7e9265ba4ef16720751b22b
parent49ba27934d228aa7c963dc38b8a143dc8cbd1f23 (diff)
DNSNameCache: check hostname can be an IPv6 address
-rw-r--r--xbmc/network/DNSNameCache.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/xbmc/network/DNSNameCache.cpp b/xbmc/network/DNSNameCache.cpp
index af2ac1ad1f..5a334b8e8f 100644
--- a/xbmc/network/DNSNameCache.cpp
+++ b/xbmc/network/DNSNameCache.cpp
@@ -38,18 +38,19 @@ bool CDNSNameCache::Lookup(const std::string& strHostName, std::string& strIpAdd
return false;
// first see if this is already an ip address
- unsigned long address = inet_addr(strHostName.c_str());
+ in_addr addr4;
+ in6_addr addr6;
strIpAddress.clear();
- if (address != INADDR_NONE)
+ if (inet_pton(AF_INET, strHostName.c_str(), &addr4) ||
+ inet_pton(AF_INET6, strHostName.c_str(), &addr6))
{
- strIpAddress = StringUtils::Format("{}.{}.{}.{}", (address & 0xFF), (address & 0xFF00) >> 8,
- (address & 0xFF0000) >> 16, (address & 0xFF000000) >> 24);
+ strIpAddress = strHostName;
return true;
}
// check if there's a custom entry or if it's already cached
- if(g_DNSCache.GetCached(strHostName, strIpAddress))
+ if (g_DNSCache.GetCached(strHostName, strIpAddress))
return true;
// perform dns lookup