Browse Source

Remove UPnP support. fixes #2500

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
pull/4/head
Daira Hopwood 7 years ago
parent
commit
506a21850a
  1. 4
      .travis.yml
  2. 3
      COPYING
  3. 51
      configure.ac
  4. 4
      contrib/debian/copyright
  5. 5
      depends/Makefile
  6. 1
      depends/README.md
  7. 4
      depends/config.site.in
  8. 32
      depends/packages/miniupnpc.mk
  9. 2
      depends/packages/packages.mk
  10. 42
      depends/patches/miniupnpc/fix-solaris-compilation.patch
  11. 22
      depends/patches/miniupnpc/patch-strlen-patch.patch
  12. 23
      depends/patches/miniupnpc/strlen-before-memcmp.patch
  13. 2
      doc/man/zcash-cli.1
  14. 2
      doc/man/zcash-tx.1
  15. 6
      doc/man/zcashd.1
  16. 3
      src/Makefile.am
  17. 2
      src/Makefile.gtest.include
  18. 2
      src/Makefile.test.include
  19. 15
      src/init.cpp
  20. 136
      src/net.cpp
  21. 9
      src/net.h
  22. 2
      src/util.cpp

4
.travis.yml

@ -29,7 +29,7 @@ matrix:
fast_finish: true fast_finish: true
include: include:
- compiler: ": ARM" - compiler: ": ARM"
env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="NO_QT=1" GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="" GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
- compiler: ": Win32" - compiler: ": Win32"
env: HOST=i686-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2" env: HOST=i686-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2"
- compiler: ": 32-bit + dash" - compiler: ": 32-bit + dash"
@ -37,7 +37,7 @@ matrix:
- compiler: ": Win64" - compiler: ": Win64"
env: HOST=x86_64-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2" env: HOST=x86_64-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2"
- compiler: ": bitcoind" - compiler: ": bitcoind"
env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc python-zmq" PPA="ppa:chris-lea/zeromq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER" env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc python-zmq" PPA="ppa:chris-lea/zeromq" DEP_OPTS="DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
- compiler: ": No wallet" - compiler: ": No wallet"
env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
- compiler: ": Cross-Mac" - compiler: ": Cross-Mac"

3
COPYING

@ -28,8 +28,7 @@ open-source licenses. For further details see 'contrib/debian/copyright'.
This product includes software developed by the OpenSSL Project for use in the This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit (https://www.openssl.org/). This product includes cryptographic OpenSSL Toolkit (https://www.openssl.org/). This product includes cryptographic
software written by Eric Young (eay@cryptsoft.com), software written by Eric Young (eay@cryptsoft.com).
and UPnP software written by Thomas Bernard.
Although almost all of the Zcash code is licensed under "permissive" open source Although almost all of the Zcash code is licensed under "permissive" open source

51
configure.ac

@ -94,18 +94,6 @@ AC_ARG_ENABLE([rust],
[enable_rust=$enableval], [enable_rust=$enableval],
[enable_rust=yes]) [enable_rust=yes])
AC_ARG_WITH([miniupnpc],
[AS_HELP_STRING([--with-miniupnpc],
[enable UPNP (default is yes if libminiupnpc is found)])],
[use_upnp=$withval],
[use_upnp=auto])
AC_ARG_ENABLE([upnp-default],
[AS_HELP_STRING([--enable-upnp-default],
[if UPNP is enabled, turn it on at startup (default is no)])],
[use_upnp_default=$enableval],
[use_upnp_default=no])
AC_ARG_ENABLE([proton], AC_ARG_ENABLE([proton],
[AS_HELP_STRING([--disable-proton], [AS_HELP_STRING([--disable-proton],
[disable Proton (AMQP messaging)])], [disable Proton (AMQP messaging)])],
@ -557,15 +545,6 @@ else
AC_DEFINE(ENABLE_PROTON, 0, [Define to 1 to enable Proton functions]) AC_DEFINE(ENABLE_PROTON, 0, [Define to 1 to enable Proton functions])
fi fi
dnl Check for libminiupnpc (optional)
if test x$use_upnp != xno; then
AC_CHECK_HEADERS(
[miniupnpc/miniwget.h miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h miniupnpc/upnperrors.h],
[AC_CHECK_LIB([miniupnpc], [main],[MINIUPNPC_LIBS=-lminiupnpc], [have_miniupnpc=no])],
[have_miniupnpc=no]
)
fi
if test x$build_bitcoin_utils$build_bitcoind$use_tests = xnonono; then if test x$build_bitcoin_utils$build_bitcoind$use_tests = xnonono; then
use_boost=no use_boost=no
else else
@ -877,33 +856,6 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi fi
dnl enable upnp support
AC_MSG_CHECKING([whether to build with support for UPnP])
if test x$have_miniupnpc = xno; then
if test x$use_upnp = xyes; then
AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc")
fi
AC_MSG_RESULT(no)
else
if test x$use_upnp != xno; then
AC_MSG_RESULT(yes)
AC_MSG_CHECKING([whether to build with UPnP enabled by default])
use_upnp=yes
upnp_setting=0
if test x$use_upnp_default != xno; then
use_upnp_default=yes
upnp_setting=1
fi
AC_MSG_RESULT($use_upnp_default)
AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[UPnP support not compiled if undefined, otherwise value (0 or 1) determines default state])
if test x$TARGET_OS = xwindows; then
MINIUPNPC_CPPFLAGS="-DSTATICLIB -DMINIUPNP_STATICLIB"
fi
else
AC_MSG_RESULT(no)
fi
fi
AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"]) AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])
AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"]) AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"])
@ -956,12 +908,9 @@ AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
AC_SUBST(RELDFLAGS) AC_SUBST(RELDFLAGS)
AC_SUBST(LIBTOOL_APP_LDFLAGS) AC_SUBST(LIBTOOL_APP_LDFLAGS)
AC_SUBST(USE_UPNP)
AC_SUBST(BOOST_LIBS) AC_SUBST(BOOST_LIBS)
AC_SUBST(TESTDEFS) AC_SUBST(TESTDEFS)
AC_SUBST(LEVELDB_TARGET_FLAGS) AC_SUBST(LEVELDB_TARGET_FLAGS)
AC_SUBST(MINIUPNPC_CPPFLAGS)
AC_SUBST(MINIUPNPC_LIBS)
AC_SUBST(GMP_LIBS) AC_SUBST(GMP_LIBS)
AC_SUBST(GMPXX_LIBS) AC_SUBST(GMPXX_LIBS)
AC_SUBST(LIBSNARK_LIBS) AC_SUBST(LIBSNARK_LIBS)

4
contrib/debian/copyright

@ -38,10 +38,6 @@ Files: depends/sources/openssl-*.tar.gz
Copyright: 1998-2016 The OpenSSL Project and 1995-1998 Eric Young Copyright: 1998-2016 The OpenSSL Project and 1995-1998 Eric Young
License: OpenSSL+SSLeay License: OpenSSL+SSLeay
Files: depends/sources/miniupnpc-*.tar.gz
Copyright: 2005-2016 Thomas BERNARD
License: BSD-3clause
Files: depends/sources/zeromq-*.tar.gz Files: depends/sources/zeromq-*.tar.gz
Copyright: Copyright:
1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.

5
depends/Makefile

@ -4,7 +4,6 @@ SOURCES_PATH ?= $(BASEDIR)/sources
BASE_CACHE ?= $(BASEDIR)/built BASE_CACHE ?= $(BASEDIR)/built
SDK_PATH ?= $(BASEDIR)/SDKs SDK_PATH ?= $(BASEDIR)/SDKs
NO_WALLET ?= NO_WALLET ?=
NO_UPNP ?=
PRIORITY_DOWNLOAD_PATH ?= https://z.cash/depends-sources PRIORITY_DOWNLOAD_PATH ?= https://z.cash/depends-sources
BUILD ?= $(shell ./config.guess) BUILD ?= $(shell ./config.guess)
@ -74,10 +73,9 @@ include packages/packages.mk
rust_packages_$(NO_RUST) = $(rust_packages) rust_packages_$(NO_RUST) = $(rust_packages)
wallet_packages_$(NO_WALLET) = $(wallet_packages) wallet_packages_$(NO_WALLET) = $(wallet_packages)
upnp_packages_$(NO_UPNP) = $(upnp_packages)
proton_packages_$(NO_PROTON) = $(proton_packages) proton_packages_$(NO_PROTON) = $(proton_packages)
packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages_) $(proton_packages_) $(wallet_packages_) $(upnp_packages_) packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages_) $(proton_packages_) $(wallet_packages_)
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
all_packages = $(packages) $(native_packages) all_packages = $(packages) $(native_packages)
@ -114,7 +112,6 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
-e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \
-e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \
-e 's|@no_wallet@|$(NO_WALLET)|' \ -e 's|@no_wallet@|$(NO_WALLET)|' \
-e 's|@no_upnp@|$(NO_UPNP)|' \
-e 's|@debug@|$(DEBUG)|' \ -e 's|@debug@|$(DEBUG)|' \
$< > $@ $< > $@
$(AT)touch $@ $(AT)touch $@

1
depends/README.md

@ -35,7 +35,6 @@ The following can be set when running make: make FOO=bar
SDK_PATH: Path where sdk's can be found (used by OSX) SDK_PATH: Path where sdk's can be found (used by OSX)
PRIORITY_DOWNLOAD_PATH: Try fetching source files from here before using their own URLs PRIORITY_DOWNLOAD_PATH: Try fetching source files from here before using their own URLs
NO_WALLET: Don't download/build/cache libs needed to enable the wallet NO_WALLET: Don't download/build/cache libs needed to enable the wallet
NO_UPNP: Don't download/build/cache packages needed for enabling upnp
DEBUG: disable some optimizations and enable more runtime checking DEBUG: disable some optimizations and enable more runtime checking
If some packages are not built, for example `make NO_WALLET=1`, the appropriate If some packages are not built, for example `make NO_WALLET=1`, the appropriate

4
depends/config.site.in

@ -17,10 +17,6 @@ if test -z $enable_wallet && test -n "@no_wallet@"; then
enable_wallet=no enable_wallet=no
fi fi
if test -z $with_miniupnpc && test -n "@no_upnp@"; then
with_miniupnpc=no
fi
if test x@host_os@ = xdarwin; then if test x@host_os@ = xdarwin; then
BREW=no BREW=no
PORT=no PORT=no

32
depends/packages/miniupnpc.mk

@ -1,32 +0,0 @@
package=miniupnpc
$(package)_version=2.0
$(package)_download_path=http://miniupnp.free.fr/files
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=d434ceb8986efbe199c5ca53f90ed53eab290b1e6d0530b717eb6fa49d61f93b
$(package)_patches=fix-solaris-compilation.patch strlen-before-memcmp.patch patch-strlen-patch.patch
define $(package)_set_vars
$(package)_build_opts=CC="$($(package)_cc)"
$(package)_build_opts_darwin=OS=Darwin
$(package)_build_opts_mingw32=-f Makefile.mingw
$(package)_build_env+=CFLAGS="$($(package)_cflags) $($(package)_cppflags)" AR="$($(package)_ar)"
endef
define $(package)_preprocess_cmds
mkdir dll && \
sed -e 's|MINIUPNPC_VERSION_STRING \"version\"|MINIUPNPC_VERSION_STRING \"$($(package)_version)\"|' -e 's|OS/version|$(host)|' miniupnpcstrings.h.in > miniupnpcstrings.h && \
sed -i.old "s|miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings|miniupnpcstrings.h: miniupnpcstrings.h.in|" Makefile.mingw && \
patch -p2 < $($(package)_patch_dir)/fix-solaris-compilation.patch && \
patch -p2 < $($(package)_patch_dir)/strlen-before-memcmp.patch && \
patch -p2 < $($(package)_patch_dir)/patch-strlen-patch.patch
endef
define $(package)_build_cmds
$(MAKE) libminiupnpc.a $($(package)_build_opts)
endef
define $(package)_stage_cmds
mkdir -p $($(package)_staging_prefix_dir)/include/miniupnpc $($(package)_staging_prefix_dir)/lib &&\
install *.h $($(package)_staging_prefix_dir)/include/miniupnpc &&\
install libminiupnpc.a $($(package)_staging_prefix_dir)/lib
endef

2
depends/packages/packages.mk

@ -5,5 +5,3 @@ packages := boost openssl libevent zeromq $(zcash_packages) googletest googlemoc
native_packages := native_ccache native_packages := native_ccache
wallet_packages=bdb wallet_packages=bdb
upnp_packages=miniupnpc

42
depends/patches/miniupnpc/fix-solaris-compilation.patch

@ -1,42 +0,0 @@
From 71ce1d6dfa5424f8fe8633e23494c7638ea2c79e Mon Sep 17 00:00:00 2001
From: Thomas Bernard <miniupnp@free.fr>
Date: Thu, 10 Nov 2016 21:55:33 +0100
Subject: [PATCH] fix for Solaris 11 compilation
see #216
---
miniupnpc/Makefile | 2 ++
miniupnpc/minissdpc.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/miniupnpc/Makefile b/miniupnpc/Makefile
index 5c23000..72cdc0f 100644
--- a/miniupnpc/Makefile
+++ b/miniupnpc/Makefile
@@ -43,10 +43,12 @@ CFLAGS += -D_NETBSD_SOURCE
endif
ifneq ($(OS), FreeBSD)
ifneq ($(OS), Darwin)
+ifneq ($(OS), SunOS)
#CFLAGS += -D_POSIX_C_SOURCE=200112L
CFLAGS += -D_XOPEN_SOURCE=600
endif
endif
+endif
#CFLAGS += -ansi
# -DNO_GETADDRINFO
INSTALL = install
diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c
index f200f07..263160e 100644
--- a/miniupnpc/minissdpc.c
+++ b/miniupnpc/minissdpc.c
@@ -73,6 +73,9 @@ struct sockaddr_un {
#if !defined(HAS_IP_MREQN) && !defined(_WIN32)
#include <sys/ioctl.h>
+#if defined(__sun)
+#include <sys/sockio.h>
+#endif
#endif
#if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN)

22
depends/patches/miniupnpc/patch-strlen-patch.patch

@ -1,22 +0,0 @@
From 0aa7c46227acd8ddb135c577674ad454bf2fba86 Mon Sep 17 00:00:00 2001
From: Thomas Bernard <miniupnp@free.fr>
Date: Fri, 11 Nov 2016 17:53:21 +0100
Subject: [PATCH] remove unsigned/signed comparison
---
miniupnpc/portlistingparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/miniupnpc/portlistingparse.c b/miniupnpc/portlistingparse.c
index 1bed763..07f3f87 100644
--- a/miniupnpc/portlistingparse.c
+++ b/miniupnpc/portlistingparse.c
@@ -55,7 +55,7 @@ startelt(void * d, const char * name, int l)
pdata->curelt = PortMappingEltNone;
for(i = 0; elements[i].str; i++)
{
- if(strlen(elements[i].str) == l && memcmp(name, elements[i].str, l) == 0)
+ if(strlen(elements[i].str) == (size_t)l && memcmp(name, elements[i].str, l) == 0)
{
pdata->curelt = elements[i].code;
break;

23
depends/patches/miniupnpc/strlen-before-memcmp.patch

@ -1,23 +0,0 @@
From ec1c49bb0cd5e448e6f0adee7de3a831c4869bdd Mon Sep 17 00:00:00 2001
From: Thomas Bernard <miniupnp@free.fr>
Date: Fri, 11 Nov 2016 17:24:39 +0100
Subject: [PATCH] check strlen before memcmp
1st try to fix #220
---
miniupnpc/portlistingparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/miniupnpc/portlistingparse.c b/miniupnpc/portlistingparse.c
index 0e09278..1bed763 100644
--- a/miniupnpc/portlistingparse.c
+++ b/miniupnpc/portlistingparse.c
@@ -55,7 +55,7 @@ startelt(void * d, const char * name, int l)
pdata->curelt = PortMappingEltNone;
for(i = 0; elements[i].str; i++)
{
- if(memcmp(name, elements[i].str, l) == 0)
+ if(strlen(elements[i].str) == l && memcmp(name, elements[i].str, l) == 0)
{
pdata->curelt = elements[i].code;
break;

2
doc/man/zcash-cli.1

@ -80,4 +80,4 @@ or <http://www.opensource.org/licenses/mit-license.php>.
This product includes software developed by the OpenSSL Project for use in the This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written
by Eric Young and UPnP software written by Thomas Bernard. by Eric Young.

2
doc/man/zcash-tx.1

@ -98,4 +98,4 @@ or <http://www.opensource.org/licenses/mit-license.php>.
This product includes software developed by the OpenSSL Project for use in the This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written
by Eric Young and UPnP software written by Thomas Bernard. by Eric Young.

6
doc/man/zcashd.1

@ -217,10 +217,6 @@ Tor control port to use if onion listening enabled (default:
.IP .IP
Tor control port password (default: empty) Tor control port password (default: empty)
.HP .HP
\fB\-upnp\fR
.IP
Use UPnP to map the listening port (default: 0)
.HP
\fB\-whitebind=\fR<addr> \fB\-whitebind=\fR<addr>
.IP .IP
Bind to given address and whitelist peers connecting to it. Use Bind to given address and whitelist peers connecting to it. Use
@ -478,4 +474,4 @@ or <http://www.opensource.org/licenses/mit-license.php>.
This product includes software developed by the OpenSSL Project for use in the This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written
by Eric Young and UPnP software written by Thomas Bernard. by Eric Young.

3
src/Makefile.am

@ -203,7 +203,7 @@ obj/build.h: FORCE
libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
# server: zcashd # server: zcashd
libbitcoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) libbitcoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
libbitcoin_server_a_SOURCES = \ libbitcoin_server_a_SOURCES = \
sendalert.cpp \ sendalert.cpp \
addrman.cpp \ addrman.cpp \
@ -411,7 +411,6 @@ zcashd_LDADD += \
$(BDB_LIBS) \ $(BDB_LIBS) \
$(SSL_LIBS) \ $(SSL_LIBS) \
$(CRYPTO_LIBS) \ $(CRYPTO_LIBS) \
$(MINIUPNPC_LIBS) \
$(EVENT_PTHREADS_LIBS) \ $(EVENT_PTHREADS_LIBS) \
$(EVENT_LIBS) \ $(EVENT_LIBS) \
$(LIBZCASH) \ $(LIBZCASH) \

2
src/Makefile.gtest.include

@ -54,7 +54,7 @@ if ENABLE_WALLET
zcash_gtest_LDADD += $(LIBBITCOIN_WALLET) zcash_gtest_LDADD += $(LIBBITCOIN_WALLET)
endif endif
zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS)
if ENABLE_PROTON if ENABLE_PROTON
zcash_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) zcash_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS)

2
src/Makefile.test.include

@ -106,7 +106,7 @@ if ENABLE_WALLET
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET) test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
endif endif
test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS)
test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
if ENABLE_ZMQ if ENABLE_ZMQ

15
src/init.cpp

@ -393,13 +393,6 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-timeout=<n>", strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT)); strUsage += HelpMessageOpt("-timeout=<n>", strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT));
strUsage += HelpMessageOpt("-torcontrol=<ip>:<port>", strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL)); strUsage += HelpMessageOpt("-torcontrol=<ip>:<port>", strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL));
strUsage += HelpMessageOpt("-torpassword=<pass>", _("Tor control port password (default: empty)")); strUsage += HelpMessageOpt("-torpassword=<pass>", _("Tor control port password (default: empty)"));
#ifdef USE_UPNP
#if USE_UPNP
strUsage += HelpMessageOpt("-upnp", _("Use UPnP to map the listening port (default: 1 when listening and no -proxy)"));
#else
strUsage += HelpMessageOpt("-upnp", strprintf(_("Use UPnP to map the listening port (default: %u)"), 0));
#endif
#endif
strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6")); strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
strUsage += HelpMessageOpt("-whitelist=<netmask>", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") + strUsage += HelpMessageOpt("-whitelist=<netmask>", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") +
" " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway")); " " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway"));
@ -829,19 +822,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// to protect privacy, do not listen by default if a default proxy server is specified // to protect privacy, do not listen by default if a default proxy server is specified
if (SoftSetBoolArg("-listen", false)) if (SoftSetBoolArg("-listen", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__); LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
// to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1
// to listen locally, so don't rely on this happening through -listen below.
if (SoftSetBoolArg("-upnp", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
// to protect privacy, do not discover addresses by default // to protect privacy, do not discover addresses by default
if (SoftSetBoolArg("-discover", false)) if (SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__); LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
} }
if (!GetBoolArg("-listen", DEFAULT_LISTEN)) { if (!GetBoolArg("-listen", DEFAULT_LISTEN)) {
// do not map ports or try to retrieve public IP when not listening (pointless) // do not try to retrieve public IP when not listening (pointless)
if (SoftSetBoolArg("-upnp", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
if (SoftSetBoolArg("-discover", false)) if (SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__); LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
if (SoftSetBoolArg("-listenonion", false)) if (SoftSetBoolArg("-listenonion", false))

136
src/net.cpp

@ -23,13 +23,6 @@
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#ifdef USE_UPNP
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/miniwget.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>
#endif
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
@ -1215,131 +1208,6 @@ void ThreadSocketHandler()
} }
#ifdef USE_UPNP
void ThreadMapPort()
{
std::string port = strprintf("%u", GetListenPort());
const char * multicastif = 0;
const char * minissdpdpath = 0;
struct UPNPDev * devlist = 0;
char lanaddr[64];
#ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0);
#elif MINIUPNPC_API_VERSION < 14
/* miniupnpc 1.6 */
int error = 0;
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error);
#else
/* miniupnpc 1.9.20150730 */
int error = 0;
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error);
#endif
struct UPNPUrls urls;
struct IGDdatas data;
int r;
r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
if (r == 1)
{
if (fDiscover) {
char externalIPAddress[40];
r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress);
if(r != UPNPCOMMAND_SUCCESS)
LogPrintf("UPnP: GetExternalIPAddress() returned %d\n", r);
else
{
if(externalIPAddress[0])
{
LogPrintf("UPnP: ExternalIPAddress = %s\n", externalIPAddress);
AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP);
}
else
LogPrintf("UPnP: GetExternalIPAddress failed.\n");
}
}
string strDesc = "Bitcoin " + FormatFullVersion();
try {
while (true) {
#ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0);
#else
/* miniupnpc 1.6 */
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0");
#endif
if(r!=UPNPCOMMAND_SUCCESS)
LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
port, port, lanaddr, r, strupnperror(r));
else
LogPrintf("UPnP Port Mapping successful.\n");;
MilliSleep(20*60*1000); // Refresh every 20 minutes
}
}
catch (const boost::thread_interrupted&)
{
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r);
freeUPNPDevlist(devlist); devlist = 0;
FreeUPNPUrls(&urls);
throw;
}
} else {
LogPrintf("No valid UPnP IGDs found\n");
freeUPNPDevlist(devlist); devlist = 0;
if (r != 0)
FreeUPNPUrls(&urls);
}
}
void MapPort(bool fUseUPnP)
{
static boost::thread* upnp_thread = NULL;
if (fUseUPnP)
{
if (upnp_thread) {
upnp_thread->interrupt();
upnp_thread->join();
delete upnp_thread;
}
upnp_thread = new boost::thread(boost::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort));
}
else if (upnp_thread) {
upnp_thread->interrupt();
upnp_thread->join();
delete upnp_thread;
upnp_thread = NULL;
}
}
#else
void MapPort(bool)
{
// Intentionally left blank.
}
#endif
void ThreadDNSAddressSeed() void ThreadDNSAddressSeed()
{ {
// goal: only query DNS seeds if address need is acute // goal: only query DNS seeds if address need is acute
@ -1879,9 +1747,6 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
else else
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "dnsseed", &ThreadDNSAddressSeed)); threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "dnsseed", &ThreadDNSAddressSeed));
// Map ports with UPnP
MapPort(GetBoolArg("-upnp", DEFAULT_UPNP));
// Send and receive from sockets, accept connections // Send and receive from sockets, accept connections
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler)); threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler));
@ -1901,7 +1766,6 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
bool StopNode() bool StopNode()
{ {
LogPrintf("StopNode()\n"); LogPrintf("StopNode()\n");
MapPort(false);
if (semOutbound) if (semOutbound)
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++) for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post(); semOutbound->post();

9
src/net.h

@ -51,12 +51,6 @@ static const unsigned int MAX_ADDR_TO_SEND = 1000;
static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024; static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024;
/** -listen default */ /** -listen default */
static const bool DEFAULT_LISTEN = true; static const bool DEFAULT_LISTEN = true;
/** -upnp default */
#ifdef USE_UPNP
static const bool DEFAULT_UPNP = USE_UPNP;
#else
static const bool DEFAULT_UPNP = false;
#endif
/** The maximum number of entries in mapAskFor */ /** The maximum number of entries in mapAskFor */
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ; static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
/** The maximum number of entries in setAskFor (larger due to getdata latency)*/ /** The maximum number of entries in setAskFor (larger due to getdata latency)*/
@ -75,7 +69,6 @@ CNode* FindNode(const std::string& addrName);
CNode* FindNode(const CService& ip); CNode* FindNode(const CService& ip);
CNode* ConnectNode(CAddress addrConnect, const char *pszDest = NULL); CNode* ConnectNode(CAddress addrConnect, const char *pszDest = NULL);
bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false); bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);
void MapPort(bool fUseUPnP);
unsigned short GetListenPort(); unsigned short GetListenPort();
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false); bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler); void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler);
@ -118,7 +111,7 @@ enum
LOCAL_NONE, // unknown LOCAL_NONE, // unknown
LOCAL_IF, // address a local interface listens on LOCAL_IF, // address a local interface listens on
LOCAL_BIND, // address explicit bound to LOCAL_BIND, // address explicit bound to
LOCAL_UPNP, // address reported by UPnP LOCAL_UPNP, // unused (was: address reported by UPnP)
LOCAL_MANUAL, // address explicitly specified (-externalip=) LOCAL_MANUAL, // address explicitly specified (-externalip=)
LOCAL_MAX LOCAL_MAX

2
src/util.cpp

@ -905,7 +905,7 @@ std::string LicenseInfo()
"\n" + "\n" +
FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or <http://www.opensource.org/licenses/mit-license.php>.")) + "\n" + FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or <http://www.opensource.org/licenses/mit-license.php>.")) + "\n" +
"\n" + "\n" +
FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard.")) + FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written by Eric Young.")) +
"\n"; "\n";
} }

Loading…
Cancel
Save