Added ifdef checks to omit some ManagedRoute code in SDK builds

This commit is contained in:
Joseph Henry 2018-08-01 17:17:04 -07:00
parent e75a093a8c
commit e01c0adff2
2 changed files with 9 additions and 2 deletions

View file

@ -46,7 +46,9 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#ifndef ZT_SDK
#include <net/route.h> #include <net/route.h>
#endif
#include <net/if.h> #include <net/if.h>
#ifdef __BSD__ #ifdef __BSD__
#include <net/if_dl.h> #include <net/if_dl.h>
@ -109,6 +111,7 @@ struct _RTE
#ifdef __BSD__ // ------------------------------------------------------------ #ifdef __BSD__ // ------------------------------------------------------------
#define ZT_ROUTING_SUPPORT_FOUND 1 #define ZT_ROUTING_SUPPORT_FOUND 1
#ifndef ZT_SDK
static std::vector<_RTE> _getRTEs(const InetAddress &target,bool contains) static std::vector<_RTE> _getRTEs(const InetAddress &target,bool contains)
{ {
std::vector<_RTE> rtes; std::vector<_RTE> rtes;
@ -243,6 +246,7 @@ static std::vector<_RTE> _getRTEs(const InetAddress &target,bool contains)
return rtes; return rtes;
} }
#endif
static void _routeCmd(const char *op,const InetAddress &target,const InetAddress &via,const char *ifscope,const char *localInterface) 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 * Linux default route override implies asymmetric routes, which then
* trigger Linux's "martian packet" filter. */ * trigger Linux's "martian packet" filter. */
#ifndef ZT_SDK
bool ManagedRoute::sync() bool ManagedRoute::sync()
{ {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
@ -519,6 +524,7 @@ bool ManagedRoute::sync()
return true; return true;
} }
#endif
void ManagedRoute::remove() void ManagedRoute::remove()
{ {
@ -562,4 +568,4 @@ void ManagedRoute::remove()
_applied.clear(); _applied.clear();
} }
} // namespace ZeroTier } // namespace ZeroTier

View file

@ -1646,7 +1646,7 @@ public:
} }
if (haveRoute) if (haveRoute)
continue; continue;
#ifndef ZT_SDK
// If we've already applied this route, just sync it and continue // If we've already applied this route, just sync it and continue
for(std::list< SharedPtr<ManagedRoute> >::iterator mr(n.managedRoutes.begin());mr!=n.managedRoutes.end();++mr) { for(std::list< SharedPtr<ManagedRoute> >::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()) ) ) { 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<ManagedRoute>(new ManagedRoute(*target,*via,tapdev))); n.managedRoutes.push_back(SharedPtr<ManagedRoute>(new ManagedRoute(*target,*via,tapdev)));
if (!n.managedRoutes.back()->sync()) if (!n.managedRoutes.back()->sync())
n.managedRoutes.pop_back(); n.managedRoutes.pop_back();
#endif
} }
} }
} }