Skip to content

Commit

Permalink
Fix addIp being called with applied ips (#1897)
Browse files Browse the repository at this point in the history
This was getting called outside of the check for existing ips
Because of the added ifdef and a brace getting moved to the
wrong place.

```
if (! n.tap()->addIp(*ip)) {
	fprintf(stderr, "ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString(ipbuf));
}
WinFWHelper::newICMPRule(*ip, n.config().nwid);

```
  • Loading branch information
laduke authored Mar 10, 2023
1 parent 12cdf39 commit a372619
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions service/OneService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2307,8 +2307,10 @@ class OneServiceImpl : public OneService
auto same_subnet = [ip](InetAddress i){
return ip->network() == i.network();
};
#endif

if (std::find(n.managedIps().begin(),n.managedIps().end(),*ip) == n.managedIps().end()) {
#ifdef __APPLE__
// if same subnet as a previously added address
if (
std::find_if(n.managedIps().begin(),n.managedIps().end(), same_subnet) != n.managedIps().end() ||
Expand All @@ -2322,15 +2324,17 @@ class OneServiceImpl : public OneService
} else {
newManagedIps2.push_back(*ip);
}
}
#endif

if (!n.tap()->addIp(*ip))
fprintf(stderr,"ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString(ipbuf));

#ifdef __WINDOWS__
WinFWHelper::newICMPRule(*ip, n.config().nwid);
#endif
if (! n.tap()->addIp(*ip)) {
fprintf(stderr, "ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString(ipbuf));
}
else {
#ifdef __WINDOWS__
WinFWHelper::newICMPRule(*ip, n.config().nwid);
#endif
}
}
}

#ifdef __APPLE__
Expand Down

0 comments on commit a372619

Please sign in to comment.