This commit is contained in:
Adam Ierymenko 2016-12-12 12:55:14 -08:00
commit 39fb4b1b42

View file

@ -672,6 +672,7 @@ bool WindowsEthernetTap::addIp(const InetAddress &ip)
{
if (!ip.netmaskBits()) // sanity check... netmask of 0.0.0.0 is WUT?
return false;
Mutex::Lock _l(_assignedIps_m);
if (std::find(_assignedIps.begin(),_assignedIps.end(),ip) != _assignedIps.end())
return true;
@ -682,6 +683,9 @@ bool WindowsEthernetTap::addIp(const InetAddress &ip)
bool WindowsEthernetTap::removeIp(const InetAddress &ip)
{
if (ip.isV6())
return true;
{
Mutex::Lock _l(_assignedIps_m);
std::vector<InetAddress>::iterator aip(std::find(_assignedIps.begin(),_assignedIps.end(),ip));
@ -713,6 +717,7 @@ bool WindowsEthernetTap::removeIp(const InetAddress &ip)
DeleteUnicastIpAddressEntry(&(ipt->Table[i]));
FreeMibTable(ipt);
if (ip.isV4()) {
std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
std::string ipstr(ip.toIpString());
@ -724,6 +729,7 @@ bool WindowsEthernetTap::removeIp(const InetAddress &ip)
_setRegistryIPv4Value("SubnetMask", regSubnetMasks);
break;
}
}
}
return true;
@ -1195,7 +1201,9 @@ void WindowsEthernetTap::_syncIps()
CreateUnicastIpAddressEntry(&ipr);
}
std::string ipStr(aip->toString());
if (aip->isV4())
{
std::string ipStr(aip->toIpString());
std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
if (std::find(regIps.begin(), regIps.end(), ipStr) == regIps.end()) {
std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
@ -1206,5 +1214,6 @@ void WindowsEthernetTap::_syncIps()
}
}
}
}
} // namespace ZeroTier