summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-06-08 12:49:07 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-06-08 12:49:07 -0700
commit4da9d4e53a7fc0e0badf0c487cad531ba7662046 (patch)
tree80d6c0589eca7e7c7c3802665bcb2ac1f708e37d
parent0ca764968ae0c09510d055390a3cec252caecfae (diff)
downloadinfinitytier-4da9d4e53a7fc0e0badf0c487cad531ba7662046.tar.gz
infinitytier-4da9d4e53a7fc0e0badf0c487cad531ba7662046.zip
Fix build against Debian version of libhttp-parser -- its old but it will work.
-rw-r--r--debian/control4
-rwxr-xr-xdebian/rules5
-rw-r--r--ext/installfiles/linux/systemd/zerotier-one.service2
-rw-r--r--make-linux.mk5
-rw-r--r--osdep/Http.cpp15
-rw-r--r--service/ControlPlane.cpp4
-rw-r--r--service/OneService.cpp14
7 files changed, 45 insertions, 4 deletions
diff --git a/debian/control b/debian/control
index 05689c5a..365d6cbe 100644
--- a/debian/control
+++ b/debian/control
@@ -3,14 +3,14 @@ Maintainer: Adam Ierymenko <adam.ierymenko@zerotier.com>
Section: net
Priority: optional
Standards-Version: 3.9.6
-Build-Depends: debhelper (>= 9), nodejs (>= 0.10.0), libhttp-parser-dev (>= 2.1), liblz4-dev, npm (>= 1.4.0), libnatpmp-dev
+Build-Depends: debhelper (>= 9), nodejs (>= 0.10.0), libhttp-parser-dev (>= 2.1), liblz4-dev, npm (>= 1.4.0), libnatpmp-dev, dh-systemd
Vcs-Git: git://github.com/zerotier/ZeroTierOne
Vcs-Browser: https://github.com/zerotier/ZeroTierOne
Homepage: https://www.zerotier.com/
Package: zerotier-one
Architecture: any
-Depends: ${shlibs:Depends}, libhttp-parser2.1, liblz4-1, libnatpmp1
+Depends: ${shlibs:Depends}, ${misc:Depends}, libhttp-parser2.1, liblz4-1, libnatpmp1
Homepage: https://www.zerotier.com/
Description: ZeroTier network virtualization service
ZeroTier One lets you join ZeroTier virtual networks and
diff --git a/debian/rules b/debian/rules
index 6ccd039d..4422dc83 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,7 +4,10 @@ CFLAGS=-O3 -fstack-protector-strong
CXXFLAGS=-O3 -fstack-protector-strong
%:
- dh $@
+ dh $@ --with systemd
override_dh_auto_build:
make ZT_USE_MINIUPNPC=1 -j 2
+
+override_dh_systemd_start:
+ dh_systemd_start --restart-after-upgrade
diff --git a/ext/installfiles/linux/systemd/zerotier-one.service b/ext/installfiles/linux/systemd/zerotier-one.service
index c4a1c4d2..a0126b7f 100644
--- a/ext/installfiles/linux/systemd/zerotier-one.service
+++ b/ext/installfiles/linux/systemd/zerotier-one.service
@@ -3,7 +3,7 @@ Description=ZeroTier One
After=network.target
[Service]
-ExecStart=/var/lib/zerotier-one/zerotier-one
+ExecStart=/usr/sbin/zerotier-one
Restart=always
KillMode=process
diff --git a/make-linux.mk b/make-linux.mk
index 994c6c03..8355909f 100644
--- a/make-linux.mk
+++ b/make-linux.mk
@@ -46,6 +46,7 @@ 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),)
OBJS+=ext/json-parser/json.o
@@ -177,6 +178,9 @@ install: FORCE
rm -f $(DESTDIR)/usr/share/man/man1/zerotier-cli.1.gz
cat doc/zerotier-cli.1 | gzip -9 >$(DESTDIR)/usr/share/man/man1/zerotier-cli.1.gz
cat doc/zerotier-idtool.1 | gzip -9 >$(DESTDIR)/usr/share/man/man1/zerotier-idtool.1.gz
+ mkdir -p $(DESTDIR)/usr/lib/systemd/system
+ rm -f $(DESTDIR)/usr/lib/systemd/system/zerotier-one.service
+ cp -f ext/installfiles/linux/systemd/zerotier-one.service $(DESTDIR)/usr/lib/systemd/system
uninstall: FORCE
rm -f $(DESTDIR)/var/lib/zerotier-one/zerotier-one
@@ -192,6 +196,7 @@ uninstall: FORCE
rm -f $(DESTDIR)/usr/share/man/man8/zerotier-one.8.gz
rm -f $(DESTDIR)/usr/share/man/man1/zerotier-idtool.1.gz
rm -f $(DESTDIR)/usr/share/man/man1/zerotier-cli.1.gz
+ rm -f $(DESTDIR)/usr/lib/systemd/system/zerotier-one.service
debian: distclean
debuild -I -i -us -uc
diff --git a/osdep/Http.cpp b/osdep/Http.cpp
index 6e3135de..4fe298b3 100644
--- a/osdep/Http.cpp
+++ b/osdep/Http.cpp
@@ -25,7 +25,12 @@
#include "OSUtils.hpp"
#include "../node/Constants.hpp"
#include "../node/Utils.hpp"
+
+#ifdef ZT_USE_SYSTEM_HTTP_PARSER
+#include <http_parser.h>
+#else
#include "../ext/http-parser/http_parser.h"
+#endif
namespace ZeroTier {
@@ -33,7 +38,11 @@ namespace {
static int ShttpOnMessageBegin(http_parser *parser);
static int ShttpOnUrl(http_parser *parser,const char *ptr,size_t length);
+#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 2)
static int ShttpOnStatus(http_parser *parser,const char *ptr,size_t length);
+#else
+static int ShttpOnStatus(http_parser *parser);
+#endif
static int ShttpOnHeaderField(http_parser *parser,const char *ptr,size_t length);
static int ShttpOnValue(http_parser *parser,const char *ptr,size_t length);
static int ShttpOnHeadersComplete(http_parser *parser);
@@ -126,12 +135,18 @@ static int ShttpOnUrl(http_parser *parser,const char *ptr,size_t length)
{
return 0;
}
+#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 2)
static int ShttpOnStatus(http_parser *parser,const char *ptr,size_t length)
+#else
+static int ShttpOnStatus(http_parser *parser)
+#endif
{
+ /*
HttpPhyHandler *hh = reinterpret_cast<HttpPhyHandler *>(parser->data);
hh->messageSize += (unsigned long)length;
if (hh->messageSize > hh->maxResponseSize)
return -1;
+ */
return 0;
}
static int ShttpOnHeaderField(http_parser *parser,const char *ptr,size_t length)
diff --git a/service/ControlPlane.cpp b/service/ControlPlane.cpp
index 060f49e2..2006346f 100644
--- a/service/ControlPlane.cpp
+++ b/service/ControlPlane.cpp
@@ -22,7 +22,11 @@
#include "../version.h"
#include "../include/ZeroTierOne.h"
+#ifdef ZT_USE_SYSTEM_HTTP_PARSER
+#include <http_parser.h>
+#else
#include "../ext/http-parser/http_parser.h"
+#endif
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
#include "../controller/SqliteNetworkController.hpp"
diff --git a/service/OneService.cpp b/service/OneService.cpp
index 6f51430f..a5e49f36 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -30,7 +30,11 @@
#include "../version.h"
#include "../include/ZeroTierOne.h"
+#ifdef ZT_USE_SYSTEM_HTTP_PARSER
+#include <http_parser.h>
+#else
#include "../ext/http-parser/http_parser.h"
+#endif
#include "../node/Constants.hpp"
#include "../node/Mutex.hpp"
@@ -402,7 +406,11 @@ static void StapFrameHandler(void *uptr,uint64_t nwid,const MAC &from,const MAC
static int ShttpOnMessageBegin(http_parser *parser);
static int ShttpOnUrl(http_parser *parser,const char *ptr,size_t length);
+#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 2)
static int ShttpOnStatus(http_parser *parser,const char *ptr,size_t length);
+#else
+static int ShttpOnStatus(http_parser *parser);
+#endif
static int ShttpOnHeaderField(http_parser *parser,const char *ptr,size_t length);
static int ShttpOnValue(http_parser *parser,const char *ptr,size_t length);
static int ShttpOnHeadersComplete(http_parser *parser);
@@ -1621,13 +1629,19 @@ static int ShttpOnUrl(http_parser *parser,const char *ptr,size_t length)
tc->url.append(ptr,length);
return 0;
}
+#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 2)
static int ShttpOnStatus(http_parser *parser,const char *ptr,size_t length)
+#else
+static int ShttpOnStatus(http_parser *parser)
+#endif
{
+ /*
TcpConnection *tc = reinterpret_cast<TcpConnection *>(parser->data);
tc->messageSize += (unsigned long)length;
if (tc->messageSize > ZT_MAX_HTTP_MESSAGE_SIZE)
return -1;
tc->status.append(ptr,length);
+ */
return 0;
}
static int ShttpOnHeaderField(http_parser *parser,const char *ptr,size_t length)