Browse Source

some cleanup

pull/1441/head
orignal 5 years ago
parent
commit
34ce06ac17
  1. 29
      libi2pd/util.cpp

29
libi2pd/util.cpp

@ -61,11 +61,11 @@ namespace net @@ -61,11 +61,11 @@ namespace net
{
#ifdef WIN32
bool IsWindowsXPorLater()
{
static bool isRequested = false;
static bool isXP = false;
if (!isRequested)
{
{
static bool isRequested = false;
static bool isXP = false;
if (!isRequested)
{
// request
OSVERSIONINFO osvi;
@ -73,8 +73,8 @@ namespace net @@ -73,8 +73,8 @@ namespace net
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
isXP = osvi.dwMajorVersion <= 5;
isRequested = true;
isXP = osvi.dwMajorVersion <= 5;
isRequested = true;
}
return isXP;
}
@ -208,24 +208,21 @@ namespace net @@ -208,24 +208,21 @@ namespace net
#endif
bool isXP = IsWindowsXPorLater();
{
#define inet_pton inet_pton_xp
}
if(localAddress.is_v4())
{
sockaddr_in inputAddress;
if (isXP)
inet_pton_xp(AF_INET, localAddressUniversal.c_str(), &(inputAddress.sin_addr));
else
if (isXP)
inet_pton_xp(AF_INET, localAddressUniversal.c_str(), &(inputAddress.sin_addr));
else
inet_pton(AF_INET, localAddressUniversal.c_str(), &(inputAddress.sin_addr));
return GetMTUWindowsIpv4(inputAddress, fallback);
}
else if(localAddress.is_v6())
{
sockaddr_in6 inputAddress;
if (isXP)
inet_pton_xp(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr));
sockaddr_in6 inputAddress;
if (isXP)
inet_pton_xp(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr));
else
inet_pton(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr));
return GetMTUWindowsIpv6(inputAddress, fallback);

Loading…
Cancel
Save