From e01c0adff28602d48ad6f0d618bee072ec7843da Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Wed, 1 Aug 2018 17:17:04 -0700 Subject: [PATCH] Added ifdef checks to omit some ManagedRoute code in SDK builds --- osdep/ManagedRoute.cpp | 8 +++++++- service/OneService.cpp | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/osdep/ManagedRoute.cpp b/osdep/ManagedRoute.cpp index 324fada0a..453d810a4 100644 --- a/osdep/ManagedRoute.cpp +++ b/osdep/ManagedRoute.cpp @@ -46,7 +46,9 @@ #include #include #include +#ifndef ZT_SDK #include +#endif #include #ifdef __BSD__ #include @@ -109,6 +111,7 @@ struct _RTE #ifdef __BSD__ // ------------------------------------------------------------ #define ZT_ROUTING_SUPPORT_FOUND 1 +#ifndef ZT_SDK static std::vector<_RTE> _getRTEs(const InetAddress &target,bool contains) { std::vector<_RTE> rtes; @@ -243,6 +246,7 @@ static std::vector<_RTE> _getRTEs(const InetAddress &target,bool contains) return rtes; } +#endif static void _routeCmd(const char *op,const InetAddress &target,const InetAddress &via,const char *ifscope,const char *localInterface) { @@ -409,6 +413,7 @@ static bool _winHasRoute(const NET_LUID &interfaceLuid, const NET_IFINDEX &inter * Linux default route override implies asymmetric routes, which then * trigger Linux's "martian packet" filter. */ +#ifndef ZT_SDK bool ManagedRoute::sync() { #ifdef __WINDOWS__ @@ -519,6 +524,7 @@ bool ManagedRoute::sync() return true; } +#endif void ManagedRoute::remove() { @@ -562,4 +568,4 @@ void ManagedRoute::remove() _applied.clear(); } -} // namespace ZeroTier +} // namespace ZeroTier \ No newline at end of file diff --git a/service/OneService.cpp b/service/OneService.cpp index 389cdc91d..a34db4b44 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1646,7 +1646,7 @@ public: } if (haveRoute) continue; - +#ifndef ZT_SDK // If we've already applied this route, just sync it and continue for(std::list< SharedPtr >::iterator mr(n.managedRoutes.begin());mr!=n.managedRoutes.end();++mr) { if ( ((*mr)->target() == *target) && ( ((via->ss_family == target->ss_family)&&((*mr)->via().ipsEqual(*via))) || (tapdev == (*mr)->device()) ) ) { @@ -1662,6 +1662,7 @@ public: n.managedRoutes.push_back(SharedPtr(new ManagedRoute(*target,*via,tapdev))); if (!n.managedRoutes.back()->sync()) n.managedRoutes.pop_back(); +#endif } } }