mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-21 05:43:59 -07:00
clang-format this branch to match dev
This commit is contained in:
parent
dcb4bc5ef4
commit
5eb3cd2699
133 changed files with 18805 additions and 17036 deletions
|
@ -22,11 +22,11 @@
|
|||
#include <string.h>
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#include <shlobj.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <netioapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -34,13 +34,13 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __LINUX__
|
||||
#include <linux/if_addr.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if_addr.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__LINUX__) && !defined(ZT_SDK)
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && ! defined(__LINUX__) && ! defined(ZT_SDK)
|
||||
#include <net/if.h>
|
||||
#if TARGET_OS_OSX
|
||||
#include <netinet6/in6_var.h>
|
||||
|
@ -51,9 +51,9 @@
|
|||
#include "../node/InetAddress.hpp"
|
||||
#include "../node/Mutex.hpp"
|
||||
#include "../node/Utils.hpp"
|
||||
#include "../osdep/ExtOsdep.hpp"
|
||||
#include "OSUtils.hpp"
|
||||
#include "Phy.hpp"
|
||||
#include "../osdep/ExtOsdep.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
|
@ -132,30 +132,31 @@ class Binder {
|
|||
template <typename PHY_HANDLER_TYPE, typename INTERFACE_CHECKER> void refresh(Phy<PHY_HANDLER_TYPE>& phy, unsigned int* ports, unsigned int portCount, const std::vector<InetAddress> explicitBind, INTERFACE_CHECKER& ifChecker)
|
||||
{
|
||||
std::map<InetAddress, std::string> localIfAddrs;
|
||||
PhySocket *udps;
|
||||
PhySocket* udps;
|
||||
Mutex::Lock _l(_lock);
|
||||
bool interfacesEnumerated = true;
|
||||
|
||||
if (explicitBind.empty()) {
|
||||
#ifdef ZT_EXTOSDEP
|
||||
std::map<InetAddress,std::string> addrs;
|
||||
interfacesEnumerated = ExtOsdep::getBindAddrs(addrs);
|
||||
for (auto &a : addrs) {
|
||||
auto ip = a.first;
|
||||
switch(ip.ipScope()) {
|
||||
default: break;
|
||||
case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
|
||||
case InetAddress::IP_SCOPE_GLOBAL:
|
||||
case InetAddress::IP_SCOPE_SHARED:
|
||||
case InetAddress::IP_SCOPE_PRIVATE:
|
||||
for(int x=0;x<(int)portCount;++x) {
|
||||
ip.setPort(ports[x]);
|
||||
localIfAddrs.insert(std::pair<InetAddress,std::string>(ip,a.second));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else // ZT_EXTOSDEP
|
||||
std::map<InetAddress, std::string> addrs;
|
||||
interfacesEnumerated = ExtOsdep::getBindAddrs(addrs);
|
||||
for (auto& a : addrs) {
|
||||
auto ip = a.first;
|
||||
switch (ip.ipScope()) {
|
||||
default:
|
||||
break;
|
||||
case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
|
||||
case InetAddress::IP_SCOPE_GLOBAL:
|
||||
case InetAddress::IP_SCOPE_SHARED:
|
||||
case InetAddress::IP_SCOPE_PRIVATE:
|
||||
for (int x = 0; x < (int)portCount; ++x) {
|
||||
ip.setPort(ports[x]);
|
||||
localIfAddrs.insert(std::pair<InetAddress, std::string>(ip, a.second));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else // ZT_EXTOSDEP
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
char aabuf[32768];
|
||||
|
@ -252,7 +253,7 @@ class Binder {
|
|||
}
|
||||
}
|
||||
|
||||
if ( (flags & IFA_F_TEMPORARY) != 0) {
|
||||
if ((flags & IFA_F_TEMPORARY) != 0) {
|
||||
continue;
|
||||
}
|
||||
if (devname) {
|
||||
|
@ -338,11 +339,11 @@ class Binder {
|
|||
//
|
||||
(void)gotViaProc;
|
||||
|
||||
#if ! defined(__ANDROID__) // getifaddrs() freeifaddrs() not available on Android
|
||||
#if ! defined(__ANDROID__) // getifaddrs() freeifaddrs() not available on Android
|
||||
if (! gotViaProc) {
|
||||
struct ifaddrs* ifatbl = (struct ifaddrs*)0;
|
||||
struct ifaddrs* ifa;
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__LINUX__) && !defined(ZT_SDK)
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && ! defined(__LINUX__) && ! defined(ZT_SDK)
|
||||
// set up an IPv6 socket so we can check the state of interfaces via SIOCGIFAFLAG_IN6
|
||||
int infoSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
#endif
|
||||
|
@ -351,7 +352,7 @@ class Binder {
|
|||
while (ifa) {
|
||||
if ((ifa->ifa_name) && (ifa->ifa_addr)) {
|
||||
InetAddress ip = *(ifa->ifa_addr);
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__LINUX__) && !defined(ZT_SDK) && TARGET_OS_OSX
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && ! defined(__LINUX__) && ! defined(ZT_SDK) && TARGET_OS_OSX
|
||||
// Check if the address is an IPv6 Temporary Address, macOS/BSD version
|
||||
if (ifa->ifa_addr->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6* sa6 = (struct sockaddr_in6*)ifa->ifa_addr;
|
||||
|
@ -399,7 +400,7 @@ class Binder {
|
|||
else {
|
||||
interfacesEnumerated = false;
|
||||
}
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__LINUX__) && !defined(ZT_SDK)
|
||||
#if (defined(__unix__) || defined(__APPLE__)) && ! defined(__LINUX__) && ! defined(ZT_SDK)
|
||||
close(infoSock);
|
||||
#endif
|
||||
}
|
||||
|
@ -407,7 +408,7 @@ class Binder {
|
|||
|
||||
#endif
|
||||
|
||||
#endif // ZT_EXTOSDEP
|
||||
#endif // ZT_EXTOSDEP
|
||||
}
|
||||
else {
|
||||
for (std::vector<InetAddress>::const_iterator i(explicitBind.begin()); i != explicitBind.end(); ++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue