From b39cc55d374457f66606096904af9fe7ea6562f6 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Wed, 15 Nov 2017 12:48:48 +0300 Subject: [PATCH] Add support of IPv6 disabling --- CMakeLists.txt | 5 +++++ configure.ac | 10 ++++++++++ other/travis/autotools-script | 12 ++++++++++++ other/travis/toxcore-script | 13 +++++++++++++ 4 files changed, 40 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f94555fe..79f07e9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,11 @@ else() add_dllflag("-Wl,-z,defs") endif() +option(USE_IPV6 "Use IPv6 in tests" ON) +if(NOT USE_IPV6) + add_definitions(-DUSE_IPV6=0) +endif() + option(BUILD_TOXAV "Whether to build the tox AV library" ON) include(Dependencies) diff --git a/configure.ac b/configure.ac index 38e3dd82..1ff861cd 100644 --- a/configure.ac +++ b/configure.ac @@ -193,6 +193,16 @@ AC_ARG_ENABLE([[epoll]], [enable_epoll='auto'] ) +AC_ARG_ENABLE([[ipv6]], + [AS_HELP_STRING([[--disable-ipv6[=ARG]]], [use ipv4 in tests (yes, no, auto) [auto]])], + [use_ipv6=${enableval}], + [use_ipv6='auto'] + ) + +if test "$use_ipv6" != "yes"; then + AC_DEFINE([USE_IPV6],[0],[define to 0 to force ipv4]) +fi + AX_HAVE_EPOLL if test "$enable_epoll" != "no"; then if test "${ax_cv_have_epoll}" = "yes"; then diff --git a/other/travis/autotools-script b/other/travis/autotools-script index d97b15b3..d47dc717 100755 --- a/other/travis/autotools-script +++ b/other/travis/autotools-script @@ -1,5 +1,16 @@ #!/bin/sh +if perl -e ' + use Socket qw(PF_INET6 SOCK_STREAM pack_sockaddr_in6 IN6ADDR_LOOPBACK); + + socket(S, PF_INET6, SOCK_STREAM, 0) || exit 1; + bind(S, pack_sockaddr_in6(0, IN6ADDR_LOOPBACK)) || exit 1; +'; then + IPV6_FLAG="--enable-ipv6" +else + IPV6_FLAG="--disable-ipv6" +fi + # Build toxcore with some custom flags here. Note that this does *not* run the # tests, so any flags passed here are irrelevant to testing. This only checks # that we can build toxcore with the specified flags. Tests run with default @@ -12,6 +23,7 @@ --enable-daemon \ --enable-logging \ --enable-ntox \ + $IPV6_FLAG \ --with-log-level=TRACE # We use make instead of RUN $MAKE here, because the autotools build will only diff --git a/other/travis/toxcore-script b/other/travis/toxcore-script index 4f5a58ea..df1462de 100755 --- a/other/travis/toxcore-script +++ b/other/travis/toxcore-script @@ -22,6 +22,18 @@ for i in `seq 0 7`; do RUN rm -rf $BUILD_DIR done +if perl -e ' + use Socket qw(PF_INET6 SOCK_STREAM pack_sockaddr_in6 IN6ADDR_LOOPBACK); + + socket(S, PF_INET6, SOCK_STREAM, 0) || exit 1; + bind(S, pack_sockaddr_in6(0, IN6ADDR_LOOPBACK)) || exit 1; +'; then + USE_IPV6=yes +else + USE_IPV6=no +fi + + # Build toxcore and run tests. RUN $CMAKE \ -B$BUILD_DIR \ @@ -32,6 +44,7 @@ RUN $CMAKE \ -DSTRICT_ABI=ON \ -DTEST_TIMEOUT_SECONDS=120 \ -DTRACE=ON \ + -DUSE_IPV6=$USE_IPV6 \ $CMAKE_EXTRA_FLAGS export CTEST_OUTPUT_ON_FAILURE=1