diff --git a/Makefile.am b/Makefile.am index ff327a589..4190b9d13 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,7 +33,7 @@ doc_DATA = \ #------------------------------------------------------------------------------ lib_LTLIBRARIES = src/libbitcoin-network.la src_libbitcoin_network_la_CPPFLAGS = -I${srcdir}/include ${bitcoin_system_BUILD_CPPFLAGS} -src_libbitcoin_network_la_LIBADD = ${boost_regex_LIBS} ${bitcoin_system_LIBS} +src_libbitcoin_network_la_LIBADD = ${bitcoin_system_LIBS} src_libbitcoin_network_la_SOURCES = \ src/error.cpp \ src/memory.cpp \ @@ -122,7 +122,7 @@ TESTS = libbitcoin-network-test_runner.sh check_PROGRAMS = test/libbitcoin-network-test test_libbitcoin_network_test_CPPFLAGS = -I${srcdir}/include ${bitcoin_system_BUILD_CPPFLAGS} -test_libbitcoin_network_test_LDADD = src/libbitcoin-network.la ${boost_unit_test_framework_LIBS} ${boost_regex_LIBS} ${bitcoin_system_LIBS} +test_libbitcoin_network_test_LDADD = src/libbitcoin-network.la ${boost_unit_test_framework_LIBS} ${bitcoin_system_LIBS} test_libbitcoin_network_test_SOURCES = \ test/error.cpp \ test/main.cpp \ diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index 6d346dd84..d2d6afc2b 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -140,11 +140,9 @@ endif() # Find boost #------------------------------------------------------------------------------ -find_package( Boost 1.76.0 REQUIRED COMPONENTS - regex +find_package( Boost 1.86.0 REQUIRED COMPONENTS unit_test_framework ) -set( boost_regex_LIBS "-lboost_regex" ) set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) set( Boost_LIBRARY_DIR $,"${Boost_LIBRARY_DIR_RELEASE}","${Boost_LIBRARY_DIR_DEBUG}">) @@ -214,7 +212,6 @@ endif() # Define project common libraries. #------------------------------------------------------------------------------ link_libraries( - ${Boost_REGEX_LIBRARY} ${bitcoin_system_FOR_BUILD_LIBRARIES} ) # Define ${CANONICAL_LIB_NAME} project. @@ -327,7 +324,6 @@ endif() # ${CANONICAL_LIB_NAME} project specific libraries/linker flags. #------------------------------------------------------------------------------ target_link_libraries( ${CANONICAL_LIB_NAME} - ${Boost_REGEX_LIBRARY} ${bitcoin_system_FOR_BUILD_LIBRARIES} ) # Define libbitcoin-network-test project. diff --git a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.props b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.props index 23ea3527f..661a8a406 100644 --- a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.props +++ b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.props @@ -12,7 +12,6 @@ false - "$(TargetPath)" --log_level=warning --run_test=* --show_progress=no --build_info=yes diff --git a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj index abb6d0eb3..00cd4e710 100644 --- a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj @@ -220,14 +220,9 @@ - - - - - @@ -237,14 +232,9 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - diff --git a/builds/msvc/vs2022/libbitcoin-network-test/packages.config b/builds/msvc/vs2022/libbitcoin-network-test/packages.config index 874500c7d..b0ce983eb 100644 --- a/builds/msvc/vs2022/libbitcoin-network-test/packages.config +++ b/builds/msvc/vs2022/libbitcoin-network-test/packages.config @@ -7,14 +7,9 @@ --> - - - - - diff --git a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj index 02777bf7b..0300d0e51 100644 --- a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj @@ -330,14 +330,9 @@ - - - - - @@ -346,14 +341,9 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - diff --git a/builds/msvc/vs2022/libbitcoin-network/packages.config b/builds/msvc/vs2022/libbitcoin-network/packages.config index 6fba34de9..547331653 100644 --- a/builds/msvc/vs2022/libbitcoin-network/packages.config +++ b/builds/msvc/vs2022/libbitcoin-network/packages.config @@ -7,14 +7,9 @@ --> - - - - - diff --git a/builds/msvc/vs2022/libbitcoin-system.import.props b/builds/msvc/vs2022/libbitcoin-system.import.props index bb11eeb34..662fa27eb 100644 --- a/builds/msvc/vs2022/libbitcoin-system.import.props +++ b/builds/msvc/vs2022/libbitcoin-system.import.props @@ -50,6 +50,8 @@ WITH_ICU;WIN32_LEAN_AND_MEAN;NOMINMAX;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) + + BOOST_JSON_NO_LIB;BOOST_CONTAINER_NO_LIB;%(PreprocessorDefinitions) BC_STATIC;%(PreprocessorDefinitions) _CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions) diff --git a/configure.ac b/configure.ac index 7e90a19bc..c915e4a66 100644 --- a/configure.ac +++ b/configure.ac @@ -213,17 +213,17 @@ AS_CASE([${CC}], [*], # Check dependencies. #============================================================================== -# Require Boost of at least version 1.76.0 and output ${boost_CPPFLAGS/LDFLAGS}. +# Require Boost of at least version 1.86.0 and output ${boost_CPPFLAGS/LDFLAGS}. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*], - [AX_BOOST_BASE([1.76.0], + [AX_BOOST_BASE([1.86.0], [AC_SUBST([boost_CPPFLAGS], [${BOOST_CPPFLAGS}]) AC_SUBST([boost_ISYS_CPPFLAGS], [`echo ${BOOST_CPPFLAGS} | $SED s/^-I/-isystem/g | $SED s/' -I'/' -isystem'/g`]) AC_SUBST([boost_LDFLAGS], [${BOOST_LDFLAGS}]) AC_MSG_NOTICE([boost_CPPFLAGS : ${boost_CPPFLAGS}]) AC_MSG_NOTICE([boost_ISYS_CPPFLAGS : ${boost_ISYS_CPPFLAGS}]) AC_MSG_NOTICE([boost_LDFLAGS : ${boost_LDFLAGS}])], - [AC_MSG_ERROR([Boost 1.76.0 or later is required but was not found.])])]) + [AC_MSG_ERROR([Boost 1.86.0 or later is required but was not found.])])]) AS_CASE([${enable_isystem}],[yes], [AC_SUBST([boost_BUILD_CPPFLAGS], [${boost_ISYS_CPPFLAGS}])], @@ -231,10 +231,6 @@ AS_CASE([${enable_isystem}],[yes], AC_MSG_NOTICE([boost_BUILD_CPPFLAGS : ${boost_BUILD_CPPFLAGS}]) -AX_BOOST_REGEX -AC_SUBST([boost_regex_LIBS], [${BOOST_REGEX_LIB}]) -AC_MSG_NOTICE([boost_regex_LIBS : ${boost_regex_LIBS}]) - AS_CASE([${with_tests}], [yes], [AX_BOOST_UNIT_TEST_FRAMEWORK AC_SUBST([boost_unit_test_framework_LIBS], [${BOOST_UNIT_TEST_FRAMEWORK_LIB}]) diff --git a/include/bitcoin/network/boost.hpp b/include/bitcoin/network/boost.hpp index bdebd801a..dc34221e0 100644 --- a/include/bitcoin/network/boost.hpp +++ b/include/bitcoin/network/boost.hpp @@ -21,29 +21,14 @@ #include -// "By default, enable_current_exception and enable_error_info are integrated -// directly in the throw_exception function. Defining BOOST_EXCEPTION_DISABLE -// disables this integration." -// www.boost.org/doc/libs/1_78_0/libs/exception/doc/configuration_macros.html -// This does not prevent interfaces that are documented to throw from doing so. -// It only prevents boost from internally wrapping the exception object with -// another class (in boost/throw_exception.hpp). Nearly all instances of the -// internal boost exceptions affecting this library occur in streambuf and are -// caught and presumed discarded in std::istream (standards allow propagation). -// See more comments in streamers.hpp on streams that may throw exceptions. -// Must be set on the command line to ensure it is captured by all includes. -////#define BOOST_EXCEPTION_DISABLE - // Avoid namespace conflict between boost::placeholders and std::placeholders. // This arises when including , which declares std::placeholders. // www.boost.org/doc/libs/1_78_0/boost/bind.hpp #define BOOST_BIND_NO_PLACEHOLDERS -// Include boost in cpp files only from here, so placeholders exclusion works. -// Avoid use in header includes due to warning repetition (boost/format.hpp). +// Include boost only from here, so placeholders exclusion works. #include #include -#include #include #endif diff --git a/install-cmake.sh b/install-cmake.sh index cc56cd727..1bcb5cfd1 100755 --- a/install-cmake.sh +++ b/install-cmake.sh @@ -69,8 +69,8 @@ ICU_ARCHIVE="icu4c-55_2-src.tgz" # Boost archive. #------------------------------------------------------------------------------ -BOOST_URL="https://archives.boost.io/release/1.78.0/source/boost_1_78_0.tar.bz2" -BOOST_ARCHIVE="boost_1_78_0.tar.bz2" +BOOST_URL="https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2" +BOOST_ARCHIVE="boost_1_86_0.tar.bz2" # Define utility functions. @@ -1010,13 +1010,10 @@ ICU_OPTIONS=( # Define boost options. #------------------------------------------------------------------------------ BOOST_OPTIONS=( -"--with-chrono" \ "--with-iostreams" \ -"--with-json" \ "--with-locale" \ "--with-program_options" \ "--with-regex" \ -"--with-system" \ "--with-thread" \ "--with-test") diff --git a/install-cmakepresets.sh b/install-cmakepresets.sh index af83da4a5..8dbe28e19 100755 --- a/install-cmakepresets.sh +++ b/install-cmakepresets.sh @@ -1058,13 +1058,10 @@ ICU_OPTIONS=( # Define boost options. #------------------------------------------------------------------------------ BOOST_OPTIONS=( -"--with-chrono" \ "--with-iostreams" \ -"--with-json" \ "--with-locale" \ "--with-program_options" \ "--with-regex" \ -"--with-system" \ "--with-thread" \ "--with-test") diff --git a/install.sh b/install.sh index cbce9f2b3..5e1d86e66 100755 --- a/install.sh +++ b/install.sh @@ -69,8 +69,8 @@ ICU_ARCHIVE="icu4c-55_2-src.tgz" # Boost archive. #------------------------------------------------------------------------------ -BOOST_URL="https://archives.boost.io/release/1.78.0/source/boost_1_78_0.tar.bz2" -BOOST_ARCHIVE="boost_1_78_0.tar.bz2" +BOOST_URL="https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2" +BOOST_ARCHIVE="boost_1_86_0.tar.bz2" # Define utility functions. @@ -884,13 +884,10 @@ ICU_OPTIONS=( # Define boost options. #------------------------------------------------------------------------------ BOOST_OPTIONS=( -"--with-chrono" \ "--with-iostreams" \ -"--with-json" \ "--with-locale" \ "--with-program_options" \ "--with-regex" \ -"--with-system" \ "--with-thread" \ "--with-test") diff --git a/libbitcoin-network.pc.in b/libbitcoin-network.pc.in index 1a64159a1..1e6133fec 100644 --- a/libbitcoin-network.pc.in +++ b/libbitcoin-network.pc.in @@ -33,5 +33,5 @@ Cflags: -I${includedir} # Lib directory, lib and any required that do not publish pkg-config. #------------------------------------------------------------------------------ -Libs: -L${libdir} -lbitcoin-network @boost_regex_LIBS@ +Libs: -L${libdir} -lbitcoin-network diff --git a/src/config/utilities.cpp b/src/config/utilities.cpp index ff465890e..a81da80df 100644 --- a/src/config/utilities.cpp +++ b/src/config/utilities.cpp @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -27,7 +28,6 @@ namespace libbitcoin { namespace network { namespace config { -using namespace system; using namespace boost::asio; constexpr uint8_t maximum_cidr_ip4 = 32; @@ -75,48 +75,49 @@ inline bool make_address(asio::address& ip, const std::string& host) NOEXCEPT // regex parsers. // ---------------------------------------------------------------------------- -// C++11: use std::regex. -using namespace boost; // en.wikipedia.org/wiki/List_of_URI_schemes // Schemes of p2p network and our zeromq endpoints. #define SCHEME "(tcp|udp|http|https|inproc):\\/\\/" #define IPV4 "([0-9.]+)" -#define IPV6 "\\[([0-9a-f:]+)]" +#define IPV6 "\\[([0-9a-f:]+)\\]" #define HOST "([^:?/\\\\]+)" #define PORT ":([1-9][0-9]{0,4})" #define CIDR "\\/([1-9][0-9]{0,2})" -////#define IPV6E4 "\\[([0-9a-f:.]+)]" +// sregex_iterator doesn't provide `at()`. +BC_PUSH_WARNING(NO_ARRAY_INDEXING) BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) // Excludes ipv4 mapped/compat, unbracketed, and ports allowed by make_address. bool parse_host(asio::address& ip, const std::string& value) NOEXCEPT { - static const regex regular + static const std::regex regular { "^(" IPV4 "|" IPV6 ")$" }; - sregex_iterator token{ value.begin(), value.end(), regular }, end{}; + std::sregex_iterator token{ value.begin(), value.end(), regular }; + std::sregex_iterator end{}; return token != end - && make_address(ip, (*token)[1]); + && make_address(ip, (*token)[1].str()); } // Excludes ipv4 mapped/compat to ipv6. bool parse_authority(asio::address& ip, uint16_t& port, uint8_t& cidr, const std::string& value) NOEXCEPT { - static const regex regular + static const std::regex regular { "^(" IPV4 "|" IPV6 ")(" PORT ")?(" CIDR ")?$" }; - sregex_iterator token{ value.begin(), value.end(), regular }, end{}; + std::sregex_iterator token{ value.begin(), value.end(), regular }; + std::sregex_iterator end{}; return token != end - && make_address(ip, (*token)[1]) - && to_integer(port, (*token)[5]) - && to_integer(cidr, (*token)[7]) + && make_address(ip, (*token)[1].str()) + && to_integer(port, (*token)[5].str()) + && to_integer(cidr, (*token)[7].str()) && ((ip.is_v4() && cidr <= maximum_cidr_ip4) || (ip.is_v6() && cidr <= maximum_cidr_ip6)); } @@ -125,18 +126,20 @@ bool parse_authority(asio::address& ip, uint16_t& port, uint8_t& cidr, bool parse_endpoint(std::string& scheme, std::string& host, uint16_t& port, const std::string& value) NOEXCEPT { - static const regex regular + static const std::regex regular { "^(" SCHEME ")?(" IPV4 "|" IPV6 "|" HOST ")(" PORT ")?$" }; - sregex_iterator token{ value.begin(), value.end(), regular }, end{}; + std::sregex_iterator token{ value.begin(), value.end(), regular }; + std::sregex_iterator end{}; return token != end - && to_string(scheme, (*token)[2]) - && to_string(host, (*token)[3]) - && to_integer(port, (*token)[8]); + && to_string(scheme, (*token)[2].str()) + && to_string(host, (*token)[3].str()) + && to_integer(port, (*token)[8].str()); } +BC_POP_WARNING() BC_POP_WARNING() // asio/asio conversions. @@ -144,14 +147,17 @@ BC_POP_WARNING() inline bool is_embedded_v4(const asio::ipv6& ip6) NOEXCEPT { + BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) + // is_v4_compatible is deprecated, removed in 1.87, no replacement. return ip6.is_v4_mapped() || ip6.is_v4_compatible(); + BC_POP_WARNING() } static asio::ipv6 to_v6(const asio::ipv4& ip4) NOEXCEPT { try { - return asio::ipv6{ splice(ip_map_prefix, ip4.to_bytes()) }; + return asio::ipv6{ system::splice(ip_map_prefix, ip4.to_bytes()) }; } catch (const std::exception&) { @@ -168,6 +174,8 @@ asio::address denormalize(const asio::address& ip) NOEXCEPT try { const auto ip6 = ip.to_v6(); + + // to_v4 is deprecated, removed in 1.87, no replacement. if (is_embedded_v4(ip6)) return { ip6.to_v4() }; } catch (const std::exception&) @@ -185,7 +193,9 @@ inline std::string to_host(const asio::ipv6& ip6) NOEXCEPT { try { + BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) return is_embedded_v4(ip6) ? to_host(ip6.to_v4()) : ip6.to_string(); + BC_POP_WARNING() } catch (const std::exception&) { @@ -211,7 +221,9 @@ std::string to_host(const asio::address& ip) NOEXCEPT try { const auto host = denormalize(ip); + BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) return host.is_v4() ? to_host(host.to_v4()) : to_host(host.to_v6()); + BC_POP_WARNING() } catch (const std::exception&) {