summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-12-04 13:19:31 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-12-04 13:19:31 -0800
commit425d311ce81a366f78a7b9a2490b94b011cf625a (patch)
tree3d10dfd99483c1432d16743a8327b04be0848ebf
parentac8918992b647c80c6da4b7c0956fd383b15e9d7 (diff)
downloadinfinitytier-425d311ce81a366f78a7b9a2490b94b011cf625a.tar.gz
infinitytier-425d311ce81a366f78a7b9a2490b94b011cf625a.zip
Merge of netcon with edge and unification of make processes.
-rwxr-xr-x.gitignore1
-rw-r--r--make-freebsd.mk12
-rw-r--r--make-linux.mk24
-rw-r--r--make-mac.mk4
-rw-r--r--netcon/NetconEthernetTap.cpp4
-rw-r--r--netcon/NetconEthernetTap.hpp4
-rwxr-xr-xnetcon/docker-test/zerotier-clibin747928 -> 0 bytes
-rwxr-xr-xnetcon/docker-test/zerotier-intercept54
-rwxr-xr-xnetcon/docker-test/zerotier-onebin747928 -> 0 bytes
-rw-r--r--netcon/make-intercept.mk53
-rw-r--r--objects.mk3
-rw-r--r--one.cpp2
-rw-r--r--service/OneService.cpp23
13 files changed, 36 insertions, 148 deletions
diff --git a/.gitignore b/.gitignore
index 27e0e191..12d6e0d5 100755
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@ Thumbs.db
*.rpm
*.autosave
*.tmp
+.depend
node_modules
cluster-geo/cluster-geo/config.js
cluster-geo/cluster-geo/cache.*
diff --git a/make-freebsd.mk b/make-freebsd.mk
index 022540d2..7148896e 100644
--- a/make-freebsd.mk
+++ b/make-freebsd.mk
@@ -6,21 +6,21 @@ DEFS=
LIBS=
include objects.mk
-OBJS+=osdep/BSDEthernetTap.o
+OBJS+=osdep/BSDEthernetTap.o
# "make official" is a shortcut for this
ifeq ($(ZT_OFFICIAL_RELEASE),1)
- DEFS+=-DZT_OFFICIAL_RELEASE
+ DEFS+=-DZT_OFFICIAL_RELEASE
endif
# Build with ZT_ENABLE_CLUSTER=1 to build with cluster support
ifeq ($(ZT_ENABLE_CLUSTER),1)
- DEFS+=-DZT_ENABLE_CLUSTER
+ DEFS+=-DZT_ENABLE_CLUSTER
endif
# "make debug" is a shortcut for this
ifeq ($(ZT_DEBUG),1)
- DEFS+=-DZT_TRACE
+ DEFS+=-DZT_TRACE
CFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS)
LDFLAGS+=
STRIP=echo
@@ -38,8 +38,8 @@ CXXFLAGS+=$(CFLAGS) -fno-rtti
all: one
-one: $(OBJS) one.o
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
+one: $(OBJS) service/OneService.o one.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) service/OneService.o one.o $(LIBS)
$(STRIP) zerotier-one
ln -sf zerotier-one zerotier-idtool
ln -sf zerotier-one zerotier-cli
diff --git a/make-linux.mk b/make-linux.mk
index 2e823993..2cf1d128 100644
--- a/make-linux.mk
+++ b/make-linux.mk
@@ -28,13 +28,11 @@ endif
#UNAME_M=$(shell $(CC) -dumpmachine | cut -d '-' -f 1)
-INCLUDES=-Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6
-DEFS=-DZT_ENABLE_NETCON
-#CXXFLAGS+=-Wc++11-compat-deprecated-writable-strings -Wformat
+INCLUDES?=
+DEFS?=
LDLIBS?=
include objects.mk
-OBJS+=osdep/LinuxEthernetTap.o netcon/NetconEthernetTap.o
# "make official" is a shortcut for this
ifeq ($(ZT_OFFICIAL_RELEASE),1)
@@ -91,12 +89,20 @@ endif
all: one
-one: $(OBJS) one.o
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LDLIBS)
+one: $(OBJS) service/OneService.o one.o osdep/LinuxEthernetTap.o
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) service/OneService.o one.o osdep/LinuxEthernetTap.o $(LDLIBS)
$(STRIP) zerotier-one
ln -sf zerotier-one zerotier-idtool
ln -sf zerotier-one zerotier-cli
+netcon: one
+ # Need to selectively rebuild one.cpp and OneService.cpp with ZT_SERVICE_NETCON and ZT_ONE_NO_ROOT_CHECK defined, and also NetconEthernetTap
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -DZT_SERVICE_NETCON -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -o zerotier-netcon-service one.cpp service/OneService.cpp netcon/NetconEthernetTap.cpp $(OBJS) $(LDLIBS) -ldl
+ # Build netcon/liblwip.so which must be placed in ZT home for zerotier-netcon-service to work
+ cd netcon ; make -f make-liblwip.mk
+ # Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
+ cd netcon ; gcc -g -O2 -Wall -std=c99 -fPIC -DVERBOSE -DDEBUG_RPC -DCHECKS -D_GNU_SOURCE -DNETCON_INTERCEPT -I. -nostdlib -shared -o ../libzerotierintercept.so Intercept.c
+
selftest: $(OBJS) selftest.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LDLIBS)
$(STRIP) zerotier-selftest
@@ -105,9 +111,9 @@ installer: one FORCE
./ext/installfiles/linux/buildinstaller.sh
clean:
- rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o $(OBJS) zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm
- # Remove files from all the funny places we put them for tests
- find netcon -type f \( -name '*.o' -o -name '*.so' -o -name '*.1.0' -o -name 'zerotier-one' -o -name 'zerotier-cli' \) -delete
+ rm -rf *.so *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o $(OBJS) zerotier-one zerotier-idtool zerotier-cli zerotier-selftest zerotier-netcon-service build-* ZeroTierOneInstaller-* *.deb *.rpm
+ # Remove files from all the funny places we put them for netcon tests
+ find netcon -type f \( -name '*.o' -o -name '*.so' -o -name '.depend' -o -name '*.1.0' -o -name 'zerotier-one' -o -name 'zerotier-cli' \) -delete
find netcon/docker-test -name "zerotier-intercept" -type f -delete
debug: FORCE
diff --git a/make-mac.mk b/make-mac.mk
index 7c4ef907..ffaf822d 100644
--- a/make-mac.mk
+++ b/make-mac.mk
@@ -71,8 +71,8 @@ CXXFLAGS=$(CFLAGS) -fno-rtti
all: one
-one: $(OBJS) one.o
- $(CXX) $(CXXFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
+one: $(OBJS) service/OneService.o one.o
+ $(CXX) $(CXXFLAGS) -o zerotier-one $(OBJS) service/OneService.o one.o $(LIBS)
$(STRIP) zerotier-one
ln -sf zerotier-one zerotier-idtool
ln -sf zerotier-one zerotier-cli
diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp
index 3f772883..f33e7ffa 100644
--- a/netcon/NetconEthernetTap.cpp
+++ b/netcon/NetconEthernetTap.cpp
@@ -25,8 +25,6 @@
* LLC. Start here: http://www.zerotier.com/
*/
-#ifdef ZT_ENABLE_NETCON
-
#include <algorithm>
#include <utility>
#include <dlfcn.h>
@@ -1551,5 +1549,3 @@ void NetconEthernetTap::handle_write(TcpConnection *conn)
}
} // namespace ZeroTier
-
-#endif // ZT_ENABLE_NETCON
diff --git a/netcon/NetconEthernetTap.hpp b/netcon/NetconEthernetTap.hpp
index dd51a19d..f6fdb6e1 100644
--- a/netcon/NetconEthernetTap.hpp
+++ b/netcon/NetconEthernetTap.hpp
@@ -28,8 +28,6 @@
#ifndef ZT_NETCONETHERNETTAP_HPP
#define ZT_NETCONETHERNETTAP_HPP
-#ifdef ZT_ENABLE_NETCON
-
#include <stdio.h>
#include <stdlib.h>
@@ -182,6 +180,4 @@ private:
} // namespace ZeroTier
-#endif // ZT_ENABLE_NETCON
-
#endif
diff --git a/netcon/docker-test/zerotier-cli b/netcon/docker-test/zerotier-cli
deleted file mode 100755
index 95e82b3d..00000000
--- a/netcon/docker-test/zerotier-cli
+++ /dev/null
Binary files differ
diff --git a/netcon/docker-test/zerotier-intercept b/netcon/docker-test/zerotier-intercept
deleted file mode 100755
index 85e9fba1..00000000
--- a/netcon/docker-test/zerotier-intercept
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-# usage:
-# /usr/bin/intercept program <args>
-
-if [ $# = 0 ] ; then
- echo "$0: insufficient arguments"
- exit
-fi
-
-case "$1" in
- on)
- if [ -z "$LD_PRELOAD" ]
- then
- export LD_PRELOAD="/lib/libzerotierintercept.so.1.0"
- else
- echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so.1.0" || \
- export LD_PRELOAD="/lib/libzerotierintercept.so $LD_PRELOAD"
- fi
- ;;
- off)
- export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/lib\/libzerotierintercept.so.1.0 \?//'`
- if [ -z "$LD_PRELOAD" ]
- then
- unset LD_PRELOAD
- fi
- ;;
- show|sh)
- echo "LD_PRELOAD=\"$LD_PRELOAD\""
- ;;
- -h|-?)
- echo ""
- ;;
- *)
- if [ -z "$LD_PRELOAD" ]
- then
- export LD_PRELOAD="/lib/libzerotierintercept.so.1.0"
- else
- echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so.1.0" || \
- export LD_PRELOAD="/lib/libzerotierintercept.so.1.0 $LD_PRELOAD"
- fi
-
- if [ $# = 0 ]
- then
- ${SHELL:-/bin/sh}
- fi
-
- if [ $# -gt 0 ]
- then
- exec "$@"
- fi
- ;;
-esac
-
-#EOF
diff --git a/netcon/docker-test/zerotier-one b/netcon/docker-test/zerotier-one
deleted file mode 100755
index 95e82b3d..00000000
--- a/netcon/docker-test/zerotier-one
+++ /dev/null
Binary files differ
diff --git a/netcon/make-intercept.mk b/netcon/make-intercept.mk
deleted file mode 100644
index 71d6d4dc..00000000
--- a/netcon/make-intercept.mk
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# ZeroTier One - Network Virtualization Everywhere
-# Copyright (C) 2011-2015 ZeroTier, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# --
-#
-# ZeroTier may be used and distributed under the terms of the GPLv3, which
-# are available at: http://www.gnu.org/licenses/gpl-3.0.html
-#
-# If you would like to embed ZeroTier into a commercial application or
-# redistribute it in a modified binary form, please contact ZeroTier Networks
-# LLC. Start here: http://www.zerotier.com/
-#
-
-SHCC=gcc
-
-intercept_CFLAGS = -c -fPIC -g -O2 -Wall -std=c99 -DVERBOSE -DDEBUG_RPC -DCHECKS -D_GNU_SOURCE -DNETCON_INTERCEPT
-#LIB_NAME = intercept
-SHLIB_EXT=dylib
-SHLIB_MAJOR = 1
-SHLIB_MINOR = 8
-COMMON = Common
-OBJS= Intercept.o
-#SHLIB = ${LIB_NAME}.${SHLIB_EXT}.${SHLIB_MAJOR}.${SHLIB_MINOR}
-SHLDFLAGS = -g -O2 -Wall -I. -nostdlib -shared
-LIBS = -ldl -lc -lrt -lpthread
-
-lib:
- ${SHCC} $(intercept_CFLAGS) -I. Intercept.c -o Intercept.o
- ${SHCC} $(SHLDFLAGS) Intercept.o -o libzerotierintercept.so.1.0 $(LIBS)
-
-install:
- cp libzerotierintercept.so.1.0 /lib/libzerotierintercept.so.1.0
- ln -sf /lib/libzerotierintercept.so.1.0 /lib/libzerotierintercept
- /usr/bin/install -c zerotier-intercept /usr/bin
-
-uninstall:
- rm -r /lib/libzerotierintercept.so.1.0
- rm -r /lib/libzerotierintercept
- rm -r /usr/bin/zerotier-intercept
diff --git a/objects.mk b/objects.mk
index 8daec8b5..d11e2812 100644
--- a/objects.mk
+++ b/objects.mk
@@ -29,5 +29,4 @@ OBJS=\
osdep/Http.o \
osdep/OSUtils.o \
service/ClusterGeoIpService.o \
- service/ControlPlane.o \
- service/OneService.o
+ service/ControlPlane.o
diff --git a/one.cpp b/one.cpp
index 685034df..deb0a398 100644
--- a/one.cpp
+++ b/one.cpp
@@ -1096,10 +1096,12 @@ int main(int argc,char **argv)
}
#ifdef __UNIX_LIKE__
+#ifndef ZT_ONE_NO_ROOT_CHECK
if ((!skipRootCheck)&&(getuid() != 0)) {
fprintf(stderr,"%s: must be run as root (uid 0)"ZT_EOL_S,argv[0]);
return 1;
}
+#endif // !ZT_ONE_NO_ROOT_CHECK
if (runAsDaemon) {
long p = (long)fork();
if (p < 0) {
diff --git a/service/OneService.cpp b/service/OneService.cpp
index c3204b5d..ed60ed2d 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -92,37 +92,32 @@ class SqliteNetworkController;
#endif
// Include the right tap device driver for this platform -- add new platforms here
-#ifdef ZT_ENABLE_NETCON
+#ifdef ZT_SERVICE_NETCON
+// In network containers builds, use the virtual netcon endpoint instead of a tun/tap port driver
#include "../netcon/NetconEthernetTap.hpp"
namespace ZeroTier { typedef NetconEthernetTap EthernetTap; }
-#else
-#ifdef __APPLE__
+#else // not ZT_SERVICE_NETCON so pick a tap driver
+#ifdef __APPLE__
#include "../osdep/OSXEthernetTap.hpp"
namespace ZeroTier { typedef OSXEthernetTap EthernetTap; }
-
-#endif
+#endif // __APPLE__
#ifdef __LINUX__
-
#include "../osdep/LinuxEthernetTap.hpp"
namespace ZeroTier { typedef LinuxEthernetTap EthernetTap; }
-
-#endif
+#endif // __LINUX__
#ifdef __WINDOWS__
-
#include "../osdep/WindowsEthernetTap.hpp"
namespace ZeroTier { typedef WindowsEthernetTap EthernetTap; }
-
-#endif
+#endif // __WINDOWS__
#ifdef __FreeBSD__
-
#include "../osdep/BSDEthernetTap.hpp"
namespace ZeroTier { typedef BSDEthernetTap EthernetTap; }
+#endif // __FreeBSD__
-#endif
-#endif // ZT_ENABLE_NETCON
+#endif // ZT_SERVICE_NETCON
// Sanity limits for HTTP
#define ZT_MAX_HTTP_MESSAGE_SIZE (1024 * 1024 * 64)