1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-28 22:34:16 +00:00

some cleanup

This commit is contained in:
orignal 2019-11-12 14:19:14 -05:00
parent a104c9881e
commit 34ce06ac17

View File

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