Merge cd535f1135
into 0c7d59efa6
This commit is contained in:
commit
2ae4527231
6 changed files with 291 additions and 0 deletions
24
zerotier/Config.in
Normal file
24
zerotier/Config.in
Normal file
|
@ -0,0 +1,24 @@
|
|||
menu "Configuration"
|
||||
depends on PACKAGE_zerotier
|
||||
|
||||
config ZEROTIER_ENABLE_DEBUG
|
||||
bool "Build in debug mode"
|
||||
depends on PACKAGE_zerotier
|
||||
default n
|
||||
|
||||
config ZEROTIER_USE_MINIUPNPC
|
||||
bool "Build with MiniUPnPc"
|
||||
depends on PACKAGE_zerotier
|
||||
default n
|
||||
|
||||
config ZEROTIER_ENABLE_NETWORK_CONTROLLER
|
||||
bool "Build with network controller"
|
||||
depends on PACKAGE_zerotier
|
||||
default n
|
||||
|
||||
config ZEROTIER_ENABLE_SELFTEST
|
||||
bool "Build a self test program"
|
||||
depends on PACKAGE_zerotier
|
||||
default n
|
||||
|
||||
endmenu
|
89
zerotier/Makefile
Normal file
89
zerotier/Makefile
Normal file
|
@ -0,0 +1,89 @@
|
|||
#
|
||||
# Copyright (C) 2016 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=zerotier
|
||||
PKG_VERSION:=1.1.14
|
||||
PKG_REV:=ae491c277e6f35d1acbdcbf700e2b834957295ae
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=git://github.com/zerotier/ZeroTierOne.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
|
||||
PKG_BUILD_DEPENDS:=uclibcxx
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/zerotier
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libpthread +kmod-tun +ip
|
||||
TITLE:=Create flat virtual Ethernet networks of almost unlimited size
|
||||
URL:=https://www.zerotier.com
|
||||
SUBMENU:=VPN
|
||||
MAINTAINER:=Moritz Warning <moritzwarning@web.de>
|
||||
endef
|
||||
|
||||
define Package/zerotier/description
|
||||
ZeroTier creates a global provider-independent virtual private cloud network.
|
||||
endef
|
||||
|
||||
define Package/zerotier/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_ZEROTIER_ENABLE_NETWORK_CONTROLLER),y)
|
||||
MAKE_FLAGS += ZT_ENABLE_NETWORK_CONTROLLER=1
|
||||
DEPENDS+=+sqlite
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ZEROTIER_USE_MINIUPNPC),y)
|
||||
MAKE_FLAGS += ZT_USE_MINIUPNPC=1
|
||||
DEPENDS+=+libminiupnpc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ZEROTIER_ENABLE_DEBUG),y)
|
||||
TARGET_CXXFLAGS += -DZT_TRACE -ggdb3
|
||||
endif
|
||||
|
||||
MAKE_FLAGS += \
|
||||
LDFLAGS+=" -L$(STAGING_DIR)/usr/lib/uClibc++ -pthread " \
|
||||
LDLIBS+=" -fno-builtin -nodefaultlibs -Wl,-Bstatic -luClibc++ -Wl,-Bdynamic -lpthread -lm -lc -lsupc++ -lc -lgcc -lgcc_eh -lgcc_s -lpthread -lm " \
|
||||
CXXFLAGS+=" -fno-builtin -nostdinc++ -I$(STAGING_DIR)/usr/include/uClibc++ -DGCC_HASCLASSVISIBILITY -Wall -fPIE -fvisibility=hidden "
|
||||
|
||||
define Build/Compile
|
||||
$(call Build/Compile/Default,one)
|
||||
ifeq ($(CONFIG_ZEROTIER_ENABLE_SELFTEST),y)
|
||||
$(call Build/Compile/Default,selftest)
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/zerotier/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zerotier-one $(1)/usr/bin/
|
||||
$(LN) zerotier-one $(1)/usr/bin/zerotier-cli
|
||||
$(LN) zerotier-one $(1)/usr/bin//zerotier-idtool
|
||||
|
||||
ifeq ($(CONFIG_ZEROTIER_ENABLE_SELFTEST),y)
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/zerotier-selftest $(1)/usr/bin/
|
||||
endif
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) files/zerotier.init $(1)/etc/init.d/zerotier
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) files/zerotier.config $(1)/etc/config/zerotier
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,zerotier))
|
||||
|
7
zerotier/files/zerotier.config
Normal file
7
zerotier/files/zerotier.config
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
config zerotier sample_config
|
||||
option enabled 1
|
||||
option interface 'wan' # restart ZT when wan status changed
|
||||
#option port '9993'
|
||||
option secret 'generate' # generate secret on first start
|
||||
list join '8056c2e21c000001' # a public network called Earth
|
71
zerotier/files/zerotier.init
Normal file
71
zerotier/files/zerotier.init
Normal file
|
@ -0,0 +1,71 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=90
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
LIST_SEP="
|
||||
"
|
||||
ZT_COMMAND=/usr/bin/zerotier-one
|
||||
|
||||
section_enabled() {
|
||||
config_get_bool enabled "$1" 'enabled' 0
|
||||
[ $enabled -gt 0 ]
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local cfg="$1"
|
||||
local port secret interface
|
||||
local ARGS=""
|
||||
|
||||
section_enabled "$cfg" || return 1
|
||||
|
||||
mkdir -p /var/lib/zerotier-one/networks.d/
|
||||
|
||||
config_get_bool port $cfg 'port'
|
||||
config_get secret $cfg 'secret'
|
||||
config_get interface $cfg 'interface'
|
||||
|
||||
if [ -n "$port" ]; then
|
||||
ARGS="$ARGS -p$port"
|
||||
fi
|
||||
|
||||
if [ "$secret" = "generate" ]; then
|
||||
echo "Generate secret - please wait..."
|
||||
local tmp="/tmp/zt.$cfg.secret"
|
||||
zerotier-idtool generate "$tmp" > /dev/null
|
||||
secret="$(cat $tmp)"
|
||||
rm "$tmp"
|
||||
|
||||
uci set zerotier.$cfg.secret="$secret"
|
||||
uci commit zerotier
|
||||
fi
|
||||
|
||||
if [ -n "$secret" ]; then
|
||||
echo "$secret" > /var/lib/zerotier-one/identity.secret
|
||||
#make sure there is not previous dentity.public
|
||||
rm -f /var/lib/zerotier-one/identity.public
|
||||
fi
|
||||
|
||||
add_join() {
|
||||
#an (empty) config file will cause ZT to join a network
|
||||
touch /var/lib/zerotier-one/networks.d/$1.conf
|
||||
}
|
||||
|
||||
config_list_foreach $cfg 'join' add_join
|
||||
|
||||
procd_open_instance
|
||||
procd_add_reload_interface_trigger "$interface"
|
||||
procd_set_param command $ZT_COMMAND $ARGS
|
||||
procd_set_param nice -10
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger zerotier
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load 'zerotier'
|
||||
config_foreach start_instance 'zerotier'
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
From 830250759cd4c14ca2ae5ddf24f0a0427f258622 Mon Sep 17 00:00:00 2001
|
||||
From: Adam Ierymenko <adam.ierymenko@gmail.com>
|
||||
Date: Tue, 26 Jul 2016 16:36:20 -0700
|
||||
Subject: [PATCH 1/2] Fix for running under MUSL libc (e.g. Alpine Linux)
|
||||
|
||||
---
|
||||
osdep/Thread.hpp | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/osdep/Thread.hpp b/osdep/Thread.hpp
|
||||
index 7fb38d8..4f90dc0 100644
|
||||
--- a/osdep/Thread.hpp
|
||||
+++ b/osdep/Thread.hpp
|
||||
@@ -125,6 +125,10 @@ public:
|
||||
throw()
|
||||
{
|
||||
memset(&_tid,0,sizeof(_tid));
|
||||
+ pthread_attr_init(&_tattr);
|
||||
+#ifdef __LINUX__
|
||||
+ pthread_attr_setstacksize(&_tattr,8388608); // for MUSL libc and others, has no effect in normal glibc environments
|
||||
+#endif
|
||||
_started = false;
|
||||
}
|
||||
|
||||
@@ -157,7 +161,7 @@ public:
|
||||
{
|
||||
Thread t;
|
||||
t._started = true;
|
||||
- if (pthread_create(&t._tid,(const pthread_attr_t *)0,&___zt_threadMain<C>,instance))
|
||||
+ if (pthread_create(&t._tid,&t._tattr,&___zt_threadMain<C>,instance))
|
||||
throw std::runtime_error("pthread_create() failed, unable to create thread");
|
||||
return t;
|
||||
}
|
||||
@@ -184,6 +188,7 @@ public:
|
||||
|
||||
private:
|
||||
pthread_t _tid;
|
||||
+ pthread_attr_t _tattr;
|
||||
volatile bool _started;
|
||||
};
|
||||
|
||||
--
|
||||
2.9.0
|
||||
|
56
zerotier/patches/0002-fix-build.patch
Normal file
56
zerotier/patches/0002-fix-build.patch
Normal file
|
@ -0,0 +1,56 @@
|
|||
From 333bbabc6dfad0553fb63d560ab6442a50cc9e52 Mon Sep 17 00:00:00 2001
|
||||
From: Moritz Warning <moritzwarning@web.de>
|
||||
Date: Fri, 22 Jul 2016 23:27:31 +0200
|
||||
Subject: [PATCH 2/2] fix build
|
||||
|
||||
---
|
||||
make-linux.mk | 30 +++++++++++++++---------------
|
||||
1 file changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/make-linux.mk b/make-linux.mk
|
||||
index acc22a6..819e95f 100644
|
||||
--- a/make-linux.mk
|
||||
+++ b/make-linux.mk
|
||||
@@ -39,24 +39,24 @@ include objects.mk
|
||||
|
||||
# On Linux we auto-detect the presence of some libraries and if present we
|
||||
# link against the system version. This works with our package build images.
|
||||
-ifeq ($(wildcard /usr/include/lz4.h),)
|
||||
+#ifeq ($(wildcard /usr/include/lz4.h),)
|
||||
OBJS+=ext/lz4/lz4.o
|
||||
-else
|
||||
- LDLIBS+=-llz4
|
||||
- DEFS+=-DZT_USE_SYSTEM_LZ4
|
||||
-endif
|
||||
-ifeq ($(wildcard /usr/include/http_parser.h),)
|
||||
+#else
|
||||
+# LDLIBS+=-llz4
|
||||
+# DEFS+=-DZT_USE_SYSTEM_LZ4 -DLOL
|
||||
+#endif
|
||||
+#ifeq ($(wildcard /usr/include/http_parser.h),)
|
||||
OBJS+=ext/http-parser/http_parser.o
|
||||
-else
|
||||
- LDLIBS+=-lhttp_parser
|
||||
- DEFS+=-DZT_USE_SYSTEM_HTTP_PARSER
|
||||
-endif
|
||||
-ifeq ($(wildcard /usr/include/json-parser/json.h),)
|
||||
+#else
|
||||
+# LDLIBS+=-lhttp_parser
|
||||
+# DEFS+=-DZT_USE_SYSTEM_HTTP_PARSER
|
||||
+#endif
|
||||
+#ifeq ($(wildcard /usr/include/json-parser/json.h),)
|
||||
OBJS+=ext/json-parser/json.o
|
||||
-else
|
||||
- LDLIBS+=-ljsonparser
|
||||
- DEFS+=-DZT_USE_SYSTEM_JSON_PARSER
|
||||
-endif
|
||||
+#else
|
||||
+# LDLIBS+=-ljsonparser
|
||||
+# DEFS+=-DZT_USE_SYSTEM_JSON_PARSER
|
||||
+#endif
|
||||
|
||||
ifeq ($(ZT_USE_MINIUPNPC),1)
|
||||
OBJS+=osdep/PortMapper.o
|
||||
--
|
||||
2.9.0
|
||||
|
Loading…
Reference in a new issue