From 381857ea492a04930eab12591e5618c951c7ba32 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Jan 2018 11:55:45 -0800 Subject: [PATCH 1/3] macOS: add libcurl to libraries when ZT_VAULT_SUPPORT=1 is specified on the make command line --- make-mac.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/make-mac.mk b/make-mac.mk index 60aa465ac..1178437a9 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -63,6 +63,11 @@ ifeq ($(ZT_TRACE),1) DEFS+=-DZT_TRACE endif +ifeq ($(ZT_VAULT_SUPPORT),1) + DEFS+=-DZT_VAULT_SUPPORT=1 + LIBS+=-lcurl +endif + CXXFLAGS=$(CFLAGS) -std=c++11 -stdlib=libc++ all: one macui @@ -70,7 +75,7 @@ all: one macui ext/x64-salsa2012-asm/salsa2012.o: $(CC) $(CFLAGS) -c ext/x64-salsa2012-asm/salsa2012.s -o ext/x64-salsa2012-asm/salsa2012.o -one: $(CORE_OBJS) $(ONE_OBJS) one.o +one: $(CORE_OBJS) $(ONE_OBJS) one.o $(CXX) $(CXXFLAGS) -o zerotier-one $(CORE_OBJS) $(ONE_OBJS) one.o $(LIBS) $(STRIP) zerotier-one ln -sf zerotier-one zerotier-idtool From bdb2cc7c859b3c27a38f23f00f00f62eba30e577 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 16 Feb 2018 15:08:04 -0800 Subject: [PATCH 2/3] Linux: link system libcurl when compiling with ZT_VAULT_SUPPORT=1 Requires libcurl and development headers to be installed --- make-linux.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/make-linux.mk b/make-linux.mk index 064a4608c..8fa70e2fc 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -88,6 +88,11 @@ ifeq ($(ZT_USE_TEST_TAP),1) override DEFS+=-DZT_USE_TEST_TAP endif +ifeq ($(ZT_VAULT_SUPPORT),1) + override DEFS+=-DZT_VAULT_SUPPORT=1 + override LDLIBS+=-lcurl +endif + # Uncomment for gprof profile build #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS) #CXXFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS) From 2d289a330870458ed5f0be4619d48eb551cb152d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 16 Feb 2018 15:20:07 -0800 Subject: [PATCH 3/3] Just a little cleanup --- service/OneService.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service/OneService.cpp b/service/OneService.cpp index 7013d9dc8..7340c954b 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -531,10 +531,12 @@ public: #ifdef ZT_USE_MINIUPNPC ,_portMapper((PortMapper *)0) #endif +#ifdef ZT_VAULT_SUPPORT ,_vaultEnabled(false) ,_vaultURL() ,_vaultToken() ,_vaultPath("cubbyhole/zerotier") +#endif ,_run(true) { _ports[0] = 0; @@ -551,6 +553,10 @@ public: _binder.closeAll(_phy); _phy.close(_localControlSocket4); _phy.close(_localControlSocket6); +#if ZT_VAULT_SUPPORT + curl_global_cleanup(); +#endif + #ifdef ZT_USE_MINIUPNPC delete _portMapper; #endif @@ -1541,6 +1547,7 @@ public: } } +#if ZT_VAULT_SUPPORT json &vault = settings["vault"]; if (vault.is_object()) { const std::string url(OSUtils::jsonString(vault["vaultURL"], "").c_str()); @@ -1579,6 +1586,7 @@ public: if (!_vaultURL.empty() && !_vaultToken.empty()) { _vaultEnabled = true; } +#endif } // Checks if a managed IP or route target is allowed