From 21f4f16e63f45577a614e25066e71080740fe175 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Mon, 14 Jan 2019 11:34:46 -0800 Subject: Disable HTTP control plane for libzt builds, introduction of getRoutes() for SDK API --- service/OneService.cpp | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'service/OneService.cpp') diff --git a/service/OneService.cpp b/service/OneService.cpp index 44ad515d..a1c53764 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -112,7 +112,7 @@ namespace ZeroTier { typedef TestEthernetTap EthernetTap; } #include "../controller/EmbeddedNetworkController.hpp" #include "../node/Node.hpp" // Use the virtual netcon endpoint instead of a tun/tap port driver -#include "../include/VirtualTap.h" +#include "../include/VirtualTap.hpp" namespace ZeroTier { typedef VirtualTap EthernetTap; } #else @@ -142,7 +142,7 @@ namespace ZeroTier { typedef NetBSDEthernetTap EthernetTap; } namespace ZeroTier { typedef BSDEthernetTap EthernetTap; } #endif // __OpenBSD__ -#endif // ZT_SERVICE_NETCON +#endif // ZT_SDK #endif // ZT_USE_TEST_TAP @@ -158,7 +158,9 @@ namespace ZeroTier { typedef BSDEthernetTap EthernetTap; } #define ZT_TAP_CHECK_MULTICAST_INTERVAL 5000 // TCP fallback relay (run by ZeroTier, Inc. -- this will eventually go away) +#ifndef ZT_SDK #define ZT_TCP_FALLBACK_RELAY "204.80.128.1/443" +#endif // Frequency at which we re-resolve the TCP fallback relay #define ZT_TCP_FALLBACK_RERESOLVE_DELAY 86400000 @@ -1112,44 +1114,26 @@ public: } #ifdef ZT_SDK - virtual void leave(const uint64_t hp) - { - _node->leave(hp, NULL, NULL); - } - - virtual void join(const uint64_t hp) - { - _node->join(hp, NULL, NULL); - } - virtual std::string givenHomePath() { return _homePath; } - std::vector *getRoutes(uint64_t nwid) + void getRoutes(uint64_t nwid, void *routeArray, unsigned int *numRoutes) { Mutex::Lock _l(_nets_m); NetworkState &n = _nets[nwid]; - std::vector *routes = new std::vector(); - for(int i=0; ipush_back(n.config.routes[i]); + *numRoutes = *numRoutes < n.config.routeCount ? *numRoutes : n.config.routeCount; + for(unsigned int i=0; i<*numRoutes; i++) { + ZT_VirtualNetworkRoute *vnr = (ZT_VirtualNetworkRoute*)routeArray; + memcpy(&vnr[i], &(n.config.routes[i]), sizeof(ZT_VirtualNetworkRoute)); } - return routes; } virtual Node *getNode() { return _node; } - - virtual void removeNets() - { - Mutex::Lock _l(_nets_m); - std::map::iterator i; - for(i = _nets.begin(); i != _nets.end(); i++) - delete i->second.tap; - } #endif // ZT_SDK virtual void terminate() @@ -1962,6 +1946,13 @@ public: _phy.close(sockN,false); return; } else { +#ifdef ZT_SDK + // Immediately close new local connections. The intention is to prevent the backplane from being accessed when operating as libzt + if (!allowHttpBackplaneManagement && ((InetAddress*)from)->ipScope() == InetAddress::IP_SCOPE_LOOPBACK) { + _phy.close(sockN,false); + return; + } +#endif TcpConnection *tc = new TcpConnection(); { Mutex::Lock _l(_tcpConnections_m); -- cgit v1.2.3