mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-18 20:47:53 +00:00
Merge of netcon with edge and unification of make processes.
This commit is contained in:
parent
ac8918992b
commit
425d311ce8
1
.gitignore
vendored
1
.gitignore
vendored
@ -54,6 +54,7 @@ Thumbs.db
|
||||
*.rpm
|
||||
*.autosave
|
||||
*.tmp
|
||||
.depend
|
||||
node_modules
|
||||
cluster-geo/cluster-geo/config.js
|
||||
cluster-geo/cluster-geo/cache.*
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Binary file not shown.
@ -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
|
Binary file not shown.
@ -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
|
@ -29,5 +29,4 @@ OBJS=\
|
||||
osdep/Http.o \
|
||||
osdep/OSUtils.o \
|
||||
service/ClusterGeoIpService.o \
|
||||
service/ControlPlane.o \
|
||||
service/OneService.o
|
||||
service/ControlPlane.o
|
||||
|
2
one.cpp
2
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) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user