mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 02:40:13 +00:00
Refactor to eliminate copypasta.
This commit is contained in:
parent
ab19e19f00
commit
eea634a432
@ -763,6 +763,13 @@ public:
|
||||
if ((now - lastLocalInterfaceAddressCheck) >= ZT_LOCAL_INTERFACE_CHECK_INTERVAL) {
|
||||
lastLocalInterfaceAddressCheck = now;
|
||||
|
||||
_node->clearLocalInterfaceAddresses();
|
||||
#ifdef ZT_USE_MINIUPNPC
|
||||
std::vector<InetAddress> mappedAddresses(_portMapper->get());
|
||||
for(std::vector<InetAddress>::const_iterator ext(mappedAddresses.begin());ext!=mappedAddresses.end();++ext)
|
||||
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&(*ext)));
|
||||
#endif
|
||||
|
||||
#ifdef __UNIX_LIKE__
|
||||
std::vector<std::string> ztDevices;
|
||||
{
|
||||
@ -770,15 +777,6 @@ public:
|
||||
for(std::map< uint64_t,EthernetTap *>::const_iterator t(_taps.begin());t!=_taps.end();++t)
|
||||
ztDevices.push_back(t->second->deviceName());
|
||||
}
|
||||
|
||||
_node->clearLocalInterfaceAddresses();
|
||||
|
||||
#ifdef ZT_USE_MINIUPNPC
|
||||
std::vector<InetAddress> mappedAddresses(_portMapper->get());
|
||||
for(std::vector<InetAddress>::const_iterator ext(mappedAddresses.begin());ext!=mappedAddresses.end();++ext)
|
||||
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&(*ext)));
|
||||
#endif
|
||||
|
||||
struct ifaddrs *ifatbl = (struct ifaddrs *)0;
|
||||
if ((getifaddrs(&ifatbl) == 0)&&(ifatbl)) {
|
||||
struct ifaddrs *ifa = ifatbl;
|
||||
@ -810,15 +808,6 @@ public:
|
||||
for(std::map< uint64_t,EthernetTap *>::const_iterator t(_taps.begin());t!=_taps.end();++t)
|
||||
ztDevices.push_back(t->second->luid());
|
||||
}
|
||||
|
||||
_node->clearLocalInterfaceAddresses();
|
||||
|
||||
#ifdef ZT_USE_MINIUPNPC
|
||||
std::vector<InetAddress> mappedAddresses(_portMapper->get());
|
||||
for(std::vector<InetAddress>::const_iterator ext(mappedAddresses.begin());ext!=mappedAddresses.end();++ext)
|
||||
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&(*ext)));
|
||||
#endif
|
||||
|
||||
char aabuf[16384];
|
||||
ULONG aalen = sizeof(aabuf);
|
||||
if (GetAdaptersAddresses(AF_UNSPEC,GAA_FLAG_SKIP_ANYCAST|GAA_FLAG_SKIP_MULTICAST|GAA_FLAG_SKIP_DNS_SERVER,(void *)0,reinterpret_cast<PIP_ADAPTER_ADDRESSES>(aabuf),&aalen) == NO_ERROR) {
|
||||
|
Loading…
Reference in New Issue
Block a user