Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4088 from ethereum/upnp
Browse files Browse the repository at this point in the history
Disable builds with UPnP by default
  • Loading branch information
chfast authored May 24, 2017
2 parents 6df20b8 + 6203e4d commit b428693
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 30 deletions.
8 changes: 7 additions & 1 deletion cmake/EthOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ macro(configure_project)
eth_default_option(FATDB ON)
eth_default_option(ROCKSDB OFF)
eth_default_option(PARANOID OFF)
eth_default_option(MINIUPNPC ON)
eth_default_option(MINIUPNPC OFF)
eth_default_option(FASTCTEST OFF)

if(MINIUPNPC)
message(WARNING
"Security vulnerabilities have been discovered in miniupnpc library."
"This build option is for testing only. Do not use it in public networks")
endif()

# components
eth_default_option(TESTS ON)
eth_default_option(TOOLS ON)
Expand Down
1 change: 0 additions & 1 deletion cmake/scripts/install_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ endfunction(download_and_install)
download_and_install("curl-7.4.2")
download_and_install("leveldb-1.2")
download_and_install("microhttpd-0.9.2")
download_and_install("miniupnpc-1.9")
7 changes: 2 additions & 5 deletions libp2p/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
aux_source_directory(. SRC_LIST)

file(GLOB HEADERS "*.h")
file(GLOB SOURCES "*.cpp")

add_library(p2p ${SRC_LIST} ${HEADERS})

find_package(Dev)
add_library(p2p ${SOURCES} ${HEADERS})

target_link_libraries(p2p devcrypto devcore)
target_include_directories(p2p PRIVATE ..)
Expand Down
20 changes: 6 additions & 14 deletions libp2p/UPnP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,18 @@
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file UPnP.cpp
* @authors:
* Gav Wood <[email protected]>
* Lefteris Karapetsas <[email protected]>
* @date 2014, 2015
*/
/// @file
/// UPnP port forwarding support.

#include "UPnP.h"

#include <stdio.h>
#include <string.h>
#if ETH_MINIUPNPC
#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#endif
#include <libdevcore/Exceptions.h>
#include <libdevcore/Common.h>
#include <libdevcore/CommonIO.h>
#include <libdevcore/Log.h>
using namespace std;
Expand Down Expand Up @@ -81,8 +75,8 @@ UPnP::UPnP()
#endif
if (descXML)
{
parserootdesc (descXML, descXMLsize, m_data.get());
free (descXML); descXML = 0;
parserootdesc(descXML, descXMLsize, m_data.get());
free(descXML);
#if MINIUPNPC_API_VERSION >= 9
GetUPNPUrls (m_urls.get(), m_data.get(), dev->descURL, 0);
#else
Expand Down Expand Up @@ -113,9 +107,8 @@ string UPnP::externalIP()
char addr[16];
if (!UPNP_GetExternalIPAddress(m_urls->controlURL, m_data->first.servicetype, addr))
return addr;
else
#endif
return "0.0.0.0";
return "0.0.0.0";
}

int UPnP::addRedirect(char const* _addr, int _port)
Expand All @@ -137,7 +130,7 @@ int UPnP::addRedirect(char const* _addr, int _port)
return _port;

// Failed - now try (random external, port internal) and cycle up to 10 times.
srand(time(NULL));
srand(static_cast<unsigned int>(time(nullptr)));
for (unsigned i = 0; i < 10; ++i)
{
_port = rand() % (32768 - 1024) + 1024;
Expand Down Expand Up @@ -181,7 +174,6 @@ void UPnP::removeRedirect(int _port)
(void)_port;
#if ETH_MINIUPNPC
char port_str[16];
// int t;
printf("TB : upnp_rem_redir (%d)\n", _port);
if (m_urls->controlURL[0] == '\0')
{
Expand Down
8 changes: 2 additions & 6 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ Darwin)
brew install \
leveldb \
libmicrohttpd \
miniupnpc \
$TRAVIS_PACKAGES

;;
Expand Down Expand Up @@ -142,8 +141,7 @@ Linux)
gcc \
libtool \
leveldb \
libmicrohttpd \
miniupnpc
libmicrohttpd

elif [ -f "/etc/os-release" ]; then

Expand All @@ -159,8 +157,7 @@ Linux)
libcurl4-openssl-dev \
libgmp-dev \
libleveldb-dev \
libmicrohttpd-dev \
libminiupnpc-dev
libmicrohttpd-dev
;;

Fedora)
Expand Down Expand Up @@ -202,7 +199,6 @@ Linux)
libgmp-dev \
libleveldb-dev \
libmicrohttpd-dev \
libminiupnpc-dev \
$TRAVIS_PACKAGES
;;

Expand Down
7 changes: 4 additions & 3 deletions scripts/tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ if "%TESTS%"=="On" (
IF errorlevel 1 GOTO ON-ERROR-CONDITION

REM Run the tests for the JIT
echo Testing EVMJIT
testeth.exe -t VMTests,StateTests -- --vm jit --testpath %APPVEYOR_BUILD_FOLDER%\test\jsontests
IF errorlevel 1 GOTO ON-ERROR-CONDITION
REM echo Testing EVMJIT
REM testeth.exe -t VMTests,StateTests -- --vm jit --testpath %APPVEYOR_BUILD_FOLDER%\test\jsontests
REM IF errorlevel 1 GOTO ON-ERROR-CONDITION

cd ..\..\..

)
Expand Down

0 comments on commit b428693

Please sign in to comment.