diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-07 18:20:17 -0500 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-07 18:20:17 -0500 |
commit | 237c379866116a24cb9e83c4d03cb121a063323e (patch) | |
tree | e76202e75b3ad6cbb21cf47984ba9f9284d726c3 | |
parent | aca31c7055bb500cc3783a07ce7158d3ec4e07b7 (diff) | |
download | infinitytier-237c379866116a24cb9e83c4d03cb121a063323e.tar.gz infinitytier-237c379866116a24cb9e83c4d03cb121a063323e.zip |
Choose which tap to use (feth or kext) on Mac based on Darwin version.
-rw-r--r-- | make-mac.mk | 2 | ||||
-rw-r--r-- | objects.mk | 1 | ||||
-rw-r--r-- | service/OneService.cpp | 34 |
3 files changed, 7 insertions, 30 deletions
diff --git a/make-mac.mk b/make-mac.mk index 0735a47f..c71b3f77 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -19,7 +19,7 @@ ZT_VERSION_BUILD=$(shell cat version.h | grep -F VERSION_BUILD | cut -d ' ' -f 3 DEFS+=-DZT_BUILD_PLATFORM=$(ZT_BUILD_PLATFORM) -DZT_BUILD_ARCHITECTURE=$(ZT_BUILD_ARCHITECTURE) include objects.mk -ONE_OBJS+=osdep/MacEthernetTap.o ext/http-parser/http_parser.o +ONE_OBJS+=osdep/MacEthernetTap.o osdep/MacKextEthernetTap.o ext/http-parser/http_parser.o ifeq ($(ZT_CONTROLLER),1) LIBS+=-lpq -lrabbitmq @@ -34,6 +34,7 @@ ONE_OBJS=\ controller/LFDB.o \ controller/PostgreSQL.o \ controller/RabbitMQ.o \ + osdep/EthernetTap.o \ osdep/ManagedRoute.o \ osdep/Http.o \ osdep/OSUtils.o \ diff --git a/service/OneService.cpp b/service/OneService.cpp index 13dca4b0..a434f484 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -118,30 +118,7 @@ namespace ZeroTier { typedef VirtualTap EthernetTap; } #else -#ifdef __APPLE__ -#include "../osdep/MacEthernetTap.hpp" -namespace ZeroTier { typedef MacEthernetTap EthernetTap; } -#endif // __APPLE__ -#ifdef __LINUX__ -#include "../osdep/LinuxEthernetTap.hpp" -namespace ZeroTier { typedef LinuxEthernetTap EthernetTap; } -#endif // __LINUX__ -#ifdef __WINDOWS__ -#include "../osdep/WindowsEthernetTap.hpp" -namespace ZeroTier { typedef WindowsEthernetTap EthernetTap; } -#endif // __WINDOWS__ -#ifdef __FreeBSD__ -#include "../osdep/BSDEthernetTap.hpp" -namespace ZeroTier { typedef BSDEthernetTap EthernetTap; } -#endif // __FreeBSD__ -#ifdef __NetBSD__ -#include "../osdep/NetBSDEthernetTap.hpp" -namespace ZeroTier { typedef NetBSDEthernetTap EthernetTap; } -#endif // __NetBSD__ -#ifdef __OpenBSD__ -#include "../osdep/BSDEthernetTap.hpp" -namespace ZeroTier { typedef BSDEthernetTap EthernetTap; } -#endif // __OpenBSD__ +#include "../osdep/EthernetTap.hpp" #endif // ZT_SDK @@ -543,7 +520,7 @@ public: settings.allowDefault = false; } - EthernetTap *tap; + std::shared_ptr<EthernetTap> tap; ZT_VirtualNetworkConfig config; // memcpy() of raw config from core std::vector<InetAddress> managedIps; std::list< SharedPtr<ManagedRoute> > managedRoutes; @@ -955,8 +932,6 @@ public: { Mutex::Lock _l(_nets_m); - for(std::map<uint64_t,NetworkState>::iterator n(_nets.begin());n!=_nets.end();++n) - delete n->second.tap; _nets.clear(); } @@ -2142,7 +2117,8 @@ public: char friendlyName[128]; OSUtils::ztsnprintf(friendlyName,sizeof(friendlyName),"ZeroTier One [%.16llx]",nwid); - n.tap = new EthernetTap( + n.tap = EthernetTap::newInstance( + nullptr, _homePath.c_str(), MAC(nwc->mac), nwc->mtu, @@ -2232,7 +2208,7 @@ public: std::string winInstanceId(n.tap->instanceId()); #endif *nuptr = (void *)0; - delete n.tap; + n.tap.reset(); _nets.erase(nwid); #if defined(__WINDOWS__) && !defined(ZT_SDK) if ((op == ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY)&&(winInstanceId.length() > 0)) |