mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev
This commit is contained in:
commit
39fb4b1b42
1 changed files with 30 additions and 21 deletions
|
@ -672,6 +672,7 @@ bool WindowsEthernetTap::addIp(const InetAddress &ip)
|
||||||
{
|
{
|
||||||
if (!ip.netmaskBits()) // sanity check... netmask of 0.0.0.0 is WUT?
|
if (!ip.netmaskBits()) // sanity check... netmask of 0.0.0.0 is WUT?
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Mutex::Lock _l(_assignedIps_m);
|
Mutex::Lock _l(_assignedIps_m);
|
||||||
if (std::find(_assignedIps.begin(),_assignedIps.end(),ip) != _assignedIps.end())
|
if (std::find(_assignedIps.begin(),_assignedIps.end(),ip) != _assignedIps.end())
|
||||||
return true;
|
return true;
|
||||||
|
@ -682,6 +683,9 @@ bool WindowsEthernetTap::addIp(const InetAddress &ip)
|
||||||
|
|
||||||
bool WindowsEthernetTap::removeIp(const InetAddress &ip)
|
bool WindowsEthernetTap::removeIp(const InetAddress &ip)
|
||||||
{
|
{
|
||||||
|
if (ip.isV6())
|
||||||
|
return true;
|
||||||
|
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_assignedIps_m);
|
Mutex::Lock _l(_assignedIps_m);
|
||||||
std::vector<InetAddress>::iterator aip(std::find(_assignedIps.begin(),_assignedIps.end(),ip));
|
std::vector<InetAddress>::iterator aip(std::find(_assignedIps.begin(),_assignedIps.end(),ip));
|
||||||
|
@ -713,18 +717,20 @@ bool WindowsEthernetTap::removeIp(const InetAddress &ip)
|
||||||
DeleteUnicastIpAddressEntry(&(ipt->Table[i]));
|
DeleteUnicastIpAddressEntry(&(ipt->Table[i]));
|
||||||
FreeMibTable(ipt);
|
FreeMibTable(ipt);
|
||||||
|
|
||||||
std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
|
if (ip.isV4()) {
|
||||||
std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
|
std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
|
||||||
std::string ipstr(ip.toIpString());
|
std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
|
||||||
for(std::vector<std::string>::iterator rip(regIps.begin()),rm(regSubnetMasks.begin());((rip!=regIps.end())&&(rm!=regSubnetMasks.end()));++rip,++rm) {
|
std::string ipstr(ip.toIpString());
|
||||||
if (*rip == ipstr) {
|
for (std::vector<std::string>::iterator rip(regIps.begin()), rm(regSubnetMasks.begin()); ((rip != regIps.end()) && (rm != regSubnetMasks.end())); ++rip, ++rm) {
|
||||||
regIps.erase(rip);
|
if (*rip == ipstr) {
|
||||||
regSubnetMasks.erase(rm);
|
regIps.erase(rip);
|
||||||
_setRegistryIPv4Value("IPAddress",regIps);
|
regSubnetMasks.erase(rm);
|
||||||
_setRegistryIPv4Value("SubnetMask",regSubnetMasks);
|
_setRegistryIPv4Value("IPAddress", regIps);
|
||||||
break;
|
_setRegistryIPv4Value("SubnetMask", regSubnetMasks);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1195,15 +1201,18 @@ void WindowsEthernetTap::_syncIps()
|
||||||
CreateUnicastIpAddressEntry(&ipr);
|
CreateUnicastIpAddressEntry(&ipr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ipStr(aip->toString());
|
if (aip->isV4())
|
||||||
std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
|
{
|
||||||
if (std::find(regIps.begin(),regIps.end(),ipStr) == regIps.end()) {
|
std::string ipStr(aip->toIpString());
|
||||||
std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
|
std::vector<std::string> regIps(_getRegistryIPv4Value("IPAddress"));
|
||||||
regIps.push_back(ipStr);
|
if (std::find(regIps.begin(), regIps.end(), ipStr) == regIps.end()) {
|
||||||
regSubnetMasks.push_back(aip->netmask().toIpString());
|
std::vector<std::string> regSubnetMasks(_getRegistryIPv4Value("SubnetMask"));
|
||||||
_setRegistryIPv4Value("IPAddress",regIps);
|
regIps.push_back(ipStr);
|
||||||
_setRegistryIPv4Value("SubnetMask",regSubnetMasks);
|
regSubnetMasks.push_back(aip->netmask().toIpString());
|
||||||
}
|
_setRegistryIPv4Value("IPAddress", regIps);
|
||||||
|
_setRegistryIPv4Value("SubnetMask", regSubnetMasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue