Browse Source

Fix build against Debian version of libhttp-parser -- its old but it will work.

Adam Ierymenko 9 years ago
parent
commit
4da9d4e53a

+ 2 - 2
debian/control

@@ -3,14 +3,14 @@ Maintainer: Adam Ierymenko <[email protected]>
 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

+ 4 - 1
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

+ 1 - 1
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
 

+ 5 - 0
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

+ 15 - 0
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)

+ 4 - 0
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"

+ 14 - 0
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)