diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a959bd5f..1dde5e3c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -628,8 +628,6 @@ target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME extens DESCRIPTION "Enables protocol extensions" DISABLED TORRENT_DISABLE_EXTENSIONS) target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME i2p DEFAULT ON DESCRIPTION "build with I2P support" DISABLED TORRENT_USE_I2P=0) -target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME ipv6 DEFAULT ON - DESCRIPTION "build with IPv6 support" DISABLED TORRENT_USE_IPV6=0) target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME logging DEFAULT ON DESCRIPTION "build with logging" DISABLED TORRENT_DISABLE_LOGGING) target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME mutable-torrents DEFAULT ON diff --git a/Jamfile b/Jamfile index d0828b7e4..6cc546748 100644 --- a/Jamfile +++ b/Jamfile @@ -417,9 +417,6 @@ rule openssl-include-path ( properties * ) feature openssl-lib : : free path ; feature openssl-include : : free path ; -feature ipv6 : on off : composite propagated link-incompatible ; -feature.compose off : TORRENT_USE_IPV6=0 ; - feature sanitize : off address memory undefined thread rtc : composite propagated link-incompatible ; # sanitize is a clang and GCC feature feature.compose undefined : -fsanitize=undefined -fsanitize-undefined-trap-on-error -fsanitize=undefined -fsanitize-undefined-trap-on-error ; @@ -538,12 +535,12 @@ variant test_debug : debug on multi on ; variant test_barebones : debug - : off off off off shared + : off off off shared off off on multi on ; variant test_arm : debug - : off off off off + : off off off off off on on ; diff --git a/docs/gen_reference_doc.py b/docs/gen_reference_doc.py index 84665c0b8..98168d7d1 100644 --- a/docs/gen_reference_doc.py +++ b/docs/gen_reference_doc.py @@ -626,7 +626,7 @@ def consume_comment(lno, lines): def trim_define(line): return line.replace('#ifndef', '').replace('#ifdef', '') \ .replace('#if', '').replace('defined', '') \ - .replace('TORRENT_USE_IPV6', '').replace('TORRENT_ABI_VERSION == 1', '') \ + .replace('TORRENT_ABI_VERSION == 1', '') \ .replace('||', '').replace('&&', '').replace('(', '').replace(')', '') \ .replace('!', '').replace('\\', '').strip() diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 6ef6ed6d6..b436f53fe 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -81,9 +81,7 @@ using lt::torrent_flags_t; using lt::seconds; using lt::operator""_sv; using lt::address_v4; -#if TORRENT_USE_IPV6 using lt::address_v6; -#endif using std::chrono::duration_cast; @@ -283,11 +281,9 @@ std::string print_endpoint(lt::tcp::endpoint const& ep) lt::error_code ec; char buf[200]; address const& addr = ep.address(); -#if TORRENT_USE_IPV6 if (addr.is_v6()) std::snprintf(buf, sizeof(buf), "[%s]:%d", addr.to_string(ec).c_str(), ep.port()); else -#endif std::snprintf(buf, sizeof(buf), "%s:%d", addr.to_string(ec).c_str(), ep.port()); return buf; } @@ -1260,10 +1256,8 @@ example alert_masks: pcf.add_rule(address_v4::from_string("0.0.0.0") , address_v4::from_string("255.255.255.255") , 1 << static_cast(lt::session::global_peer_class_id)); -#if TORRENT_USE_IPV6 pcf.add_rule(address_v6::from_string("::") , address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"), 1); -#endif ses.set_peer_class_filter(pcf); } diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index 81fae43cc..72c1a0eed 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -430,12 +430,10 @@ struct peer_conn char ep_str[200]; address const& addr = s.local_endpoint(e).address(); -#if TORRENT_USE_IPV6 if (addr.is_v6()) std::snprintf(ep_str, sizeof(ep_str), "[%s]:%d", addr.to_string(e).c_str() , s.local_endpoint(e).port()); else -#endif std::snprintf(ep_str, sizeof(ep_str), "%s:%d", addr.to_string(e).c_str() , s.local_endpoint(e).port()); std::printf("%s ep: %s sent: %d received: %d duration: %d ms up: %.1fMB/s down: %.1fMB/s\n" diff --git a/include/libtorrent/address.hpp b/include/libtorrent/address.hpp index b63abc611..939a46764 100644 --- a/include/libtorrent/address.hpp +++ b/include/libtorrent/address.hpp @@ -51,15 +51,11 @@ namespace libtorrent { #if defined TORRENT_BUILD_SIMULATOR using sim::asio::ip::address; using sim::asio::ip::address_v4; -#if TORRENT_USE_IPV6 using sim::asio::ip::address_v6; -#endif #else using boost::asio::ip::address; using boost::asio::ip::address_v4; -#if TORRENT_USE_IPV6 using boost::asio::ip::address_v6; -#endif #endif // SIMULATOR // the from_string member functions are deprecated starting @@ -67,19 +63,15 @@ namespace libtorrent { #if BOOST_VERSION >= 106600 && !defined TORRENT_BUILD_SIMULATOR using boost::asio::ip::make_address; using boost::asio::ip::make_address_v4; -#if TORRENT_USE_IPV6 using boost::asio::ip::make_address_v6; -#endif #else inline address make_address(string_view str, boost::system::error_code& ec) { return address::from_string(str.data(), ec); } inline address_v4 make_address_v4(string_view str, boost::system::error_code& ec) { return address_v4::from_string(str.data(), ec); } -#if TORRENT_USE_IPV6 inline address_v6 make_address_v6(string_view str, boost::system::error_code& ec) { return address_v6::from_string(str.data(), ec); } #endif -#endif } #endif diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 8f9df204f..c803db33a 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -70,10 +70,8 @@ namespace libtorrent { // cheap since the lists' size is limited using peers4_t = std::vector>; peers4_t m_peers; -#if TORRENT_USE_IPV6 using peers6_t = std::vector>; peers6_t m_peers6; -#endif bool was_introduced_by(tcp::endpoint const& ep); diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 2117327e9..a6c6acc7a 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -122,7 +122,6 @@ POSSIBILITY OF SUCH DAMAGE. // ==== AMIGA === #if defined __AMIGA__ || defined __amigaos__ || defined __AROS__ #define TORRENT_AMIGA -#define TORRENT_USE_IPV6 0 #define TORRENT_USE_IOSTREAM 0 // set this to 1 to disable all floating point operations // (disables some float-dependent APIs) @@ -322,7 +321,6 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_HAS_FALLOCATE 0 #define TORRENT_USE_IFCONF 1 #define TORRENT_USE_SYSCTL 1 -#define TORRENT_USE_IPV6 0 #define TORRENT_USE_WRITEV 0 #define TORRENT_USE_READV 0 @@ -468,10 +466,6 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_USE_IFADDRS 0 #endif -#ifndef TORRENT_USE_IPV6 -#define TORRENT_USE_IPV6 1 -#endif - // if preadv() exists, we assume pwritev() does as well #ifndef TORRENT_USE_PREADV #define TORRENT_USE_PREADV 0 @@ -615,14 +609,6 @@ constexpr std::size_t TORRENT_WRITE_HANDLER_MAX_SIZE = 342; #endif #endif // TORRENT_HAS_ARM_CRC32 -#if TORRENT_USE_IPV6 -#define TORRENT_IPV6_NAMESPACE inline namespace v6 { -#define TORRENT_IPV6_NAMESPACE_END } -#else -#define TORRENT_IPV6_NAMESPACE -#define TORRENT_IPV6_NAMESPACE_END -#endif - namespace libtorrent {} // create alias diff --git a/include/libtorrent/enum_net.hpp b/include/libtorrent/enum_net.hpp index b8f23f8b1..4b209bf0a 100644 --- a/include/libtorrent/enum_net.hpp +++ b/include/libtorrent/enum_net.hpp @@ -120,13 +120,11 @@ namespace libtorrent { address ip = make_address(device_name, ec); if (!ec) { -#if TORRENT_USE_IPV6 // this is to cover the case where "0.0.0.0" is considered any IPv4 or // IPv6 address. If we're asking to be bound to an IPv6 address and // providing 0.0.0.0 as the device, turn it into "::" if (ip == address_v4::any() && protocol == boost::asio::ip::tcp::v6()) ip = address_v6::any(); -#endif bind_ep.address(ip); // it appears to be an IP. Just bind to that address sock.bind(bind_ep, ec); diff --git a/include/libtorrent/fwd.hpp b/include/libtorrent/fwd.hpp index 95b3cfd62..2cd8805f9 100644 --- a/include/libtorrent/fwd.hpp +++ b/include/libtorrent/fwd.hpp @@ -188,9 +188,7 @@ class hasher; class hasher512; // include/libtorrent/ip_filter.hpp -TORRENT_IPV6_NAMESPACE struct ip_filter; -TORRENT_IPV6_NAMESPACE_END class port_filter; // include/libtorrent/kademlia/dht_settings.hpp @@ -256,10 +254,8 @@ struct storage_interface; struct storage_params; // include/libtorrent/torrent_handle.hpp -TORRENT_IPV6_NAMESPACE struct block_info; struct partial_piece_info; -TORRENT_IPV6_NAMESPACE_END struct torrent_handle; // include/libtorrent/torrent_info.hpp diff --git a/include/libtorrent/ip_filter.hpp b/include/libtorrent/ip_filter.hpp index 3f254f6c1..cce596a75 100644 --- a/include/libtorrent/ip_filter.hpp +++ b/include/libtorrent/ip_filter.hpp @@ -256,8 +256,6 @@ namespace detail { } -TORRENT_IPV6_NAMESPACE - // The ``ip_filter`` class is a set of rules that uniquely categorizes all // ip addresses as allowed or disallowed. The default constructor creates // a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for @@ -296,12 +294,8 @@ struct TORRENT_EXPORT ip_filter // the current filter. std::uint32_t access(address const& addr) const; -#if TORRENT_USE_IPV6 using filter_tuple_t = std::tuple> , std::vector>>; -#else - using filter_tuple_t = std::vector>; -#endif // This function will return the current state of the filter in the minimum number of // ranges possible. They are sorted from ranges in low addresses to high addresses. Each @@ -317,13 +311,9 @@ struct TORRENT_EXPORT ip_filter private: detail::filter_impl m_filter4; -#if TORRENT_USE_IPV6 detail::filter_impl m_filter6; -#endif }; -TORRENT_IPV6_NAMESPACE_END - // the port filter maps non-overlapping port ranges to flags. This // is primarily used to indicate whether a range of ports should // be connected to or not. The default is to have the full port diff --git a/include/libtorrent/ip_voter.hpp b/include/libtorrent/ip_voter.hpp index dbf3d1bd4..1260ea7fb 100644 --- a/include/libtorrent/ip_voter.hpp +++ b/include/libtorrent/ip_voter.hpp @@ -111,9 +111,7 @@ namespace libtorrent { struct TORRENT_EXTRA_EXPORT external_ip { external_ip() -#if TORRENT_USE_IPV6 : m_addresses{{address_v4(), address_v6()}, {address_v4(), address_v6()}} -#endif {} external_ip(address const& local4, address const& global4 diff --git a/include/libtorrent/kademlia/io.hpp b/include/libtorrent/kademlia/io.hpp index 3cd075582..4e1175877 100644 --- a/include/libtorrent/kademlia/io.hpp +++ b/include/libtorrent/kademlia/io.hpp @@ -47,17 +47,12 @@ namespace libtorrent { namespace dht { template node_endpoint read_node_endpoint(udp protocol, InIt&& in) { -#if !TORRENT_USE_IPV6 - TORRENT_UNUSED(protocol); -#endif node_endpoint ep; std::copy(in, in + 20, ep.id.begin()); in += 20; -#if TORRENT_USE_IPV6 if (protocol == udp::v6()) ep.ep = detail::read_v6_endpoint(in); else -#endif ep.ep = detail::read_v4_endpoint(in); return ep; } diff --git a/include/libtorrent/kademlia/observer.hpp b/include/libtorrent/kademlia/observer.hpp index 8afa450eb..bcfc5ed08 100644 --- a/include/libtorrent/kademlia/observer.hpp +++ b/include/libtorrent/kademlia/observer.hpp @@ -126,9 +126,7 @@ private: union addr_t { -#if TORRENT_USE_IPV6 address_v6::bytes_type v6; -#endif address_v4::bytes_type v4; } m_addr; diff --git a/include/libtorrent/kademlia/routing_table.hpp b/include/libtorrent/kademlia/routing_table.hpp index 56cf3caf6..e5d7f46d0 100644 --- a/include/libtorrent/kademlia/routing_table.hpp +++ b/include/libtorrent/kademlia/routing_table.hpp @@ -70,7 +70,6 @@ struct ipv4_hash } }; -#if TORRENT_USE_IPV6 struct ipv6_hash { using argument_type = address_v6::bytes_type; @@ -80,7 +79,6 @@ struct ipv6_hash return std::hash()(*reinterpret_cast(&ip[0])); } }; -#endif struct ip_set { @@ -91,26 +89,18 @@ struct ip_set void clear() { m_ip4s.clear(); -#if TORRENT_USE_IPV6 m_ip6s.clear(); -#endif } bool operator==(ip_set const& rh) { -#if TORRENT_USE_IPV6 return m_ip4s == rh.m_ip4s && m_ip6s == rh.m_ip6s; -#else - return m_ip4s == rh.m_ip4s; -#endif } // these must be multisets because there can be multiple routing table // entries for a single IP when restrict_routing_ips is set to false std::unordered_multiset m_ip4s; -#if TORRENT_USE_IPV6 std::unordered_multiset m_ip6s; -#endif }; // differences in the implementation from the description in diff --git a/include/libtorrent/kademlia/traversal_algorithm.hpp b/include/libtorrent/kademlia/traversal_algorithm.hpp index 5eb78fe76..6b4ce53e0 100644 --- a/include/libtorrent/kademlia/traversal_algorithm.hpp +++ b/include/libtorrent/kademlia/traversal_algorithm.hpp @@ -140,9 +140,7 @@ private: // the IP addresses of the nodes in m_results std::set m_peer4_prefixes; -#if TORRENT_USE_IPV6 std::set m_peer6_prefixes; -#endif #ifndef TORRENT_DISABLE_LOGGING void log_timeout(observer_ptr const& o, char const* prefix) const; #endif diff --git a/include/libtorrent/lsd.hpp b/include/libtorrent/lsd.hpp index 16fc38820..a1156016e 100644 --- a/include/libtorrent/lsd.hpp +++ b/include/libtorrent/lsd.hpp @@ -67,9 +67,7 @@ private: // the udp socket used to send and receive // multicast messages on broadcast_socket m_socket; -#if TORRENT_USE_IPV6 broadcast_socket m_socket6; -#endif #ifndef TORRENT_DISABLE_LOGGING bool should_log() const; void debug_log(char const* fmt, ...) const TORRENT_FORMAT(2, 3); @@ -87,9 +85,7 @@ private: int m_cookie; bool m_disabled; -#if TORRENT_USE_IPV6 bool m_disabled6; -#endif }; } diff --git a/include/libtorrent/peer.hpp b/include/libtorrent/peer.hpp index 21799a3ea..cd7613050 100644 --- a/include/libtorrent/peer.hpp +++ b/include/libtorrent/peer.hpp @@ -59,13 +59,11 @@ namespace libtorrent { std::uint16_t port; }; -#if TORRENT_USE_IPV6 struct ipv6_peer_entry { address_v6::bytes_type ip; std::uint16_t port; }; -#endif } diff --git a/include/libtorrent/socket_io.hpp b/include/libtorrent/socket_io.hpp index 20131df7e..1975e0dfa 100644 --- a/include/libtorrent/socket_io.hpp +++ b/include/libtorrent/socket_io.hpp @@ -60,31 +60,24 @@ namespace detail { template std::size_t address_size(Proto p) { - TORRENT_UNUSED(p); -#if TORRENT_USE_IPV6 if (p == Proto::v6()) return std::tuple_size::value; else -#endif return std::tuple_size::value; } template void write_address(address const& a, OutIt&& out) { -#if TORRENT_USE_IPV6 if (a.is_v4()) { -#endif write_uint32(a.to_v4().to_ulong(), out); -#if TORRENT_USE_IPV6 } else if (a.is_v6()) { for (auto b : a.to_v6().to_bytes()) write_uint8(b, out); } -#endif } template @@ -94,7 +87,6 @@ namespace detail { return address_v4(ip); } -#if TORRENT_USE_IPV6 template address read_v6_address(InIt&& in) { @@ -103,7 +95,6 @@ namespace detail { b = read_uint8(in); return address_v6(bytes); } -#endif template void write_endpoint(Endpoint const& e, OutIt&& out) @@ -120,7 +111,6 @@ namespace detail { return Endpoint(addr, port); } -#if TORRENT_USE_IPV6 template Endpoint read_v6_endpoint(InIt&& in) { @@ -128,7 +118,7 @@ namespace detail { std::uint16_t port = read_uint16(in); return Endpoint(addr, port); } -#endif + template std::vector read_endpoint_list(libtorrent::bdecode_node const& n) { @@ -142,10 +132,8 @@ namespace detail { char const* in = e.string_ptr(); if (e.string_length() == 6) ret.push_back(read_v4_endpoint(in)); -#if TORRENT_USE_IPV6 else if (e.string_length() == 18) ret.push_back(read_v6_endpoint(in)); -#endif } return ret; } diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 86cf0a922..618a319fe 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -82,8 +82,6 @@ namespace aux { using resume_data_flags_t = flags::bitfield_flag; using queue_position_t = aux::strong_typedef; -TORRENT_IPV6_NAMESPACE - // holds the state of a block in a piece. Who we requested // it from and how far along we are at downloading it. struct TORRENT_EXPORT block_info @@ -106,9 +104,7 @@ TORRENT_IPV6_NAMESPACE union addr_t { address_v4::bytes_type v4; -#if TORRENT_USE_IPV6 address_v6::bytes_type v6; -#endif } addr; std::uint16_t port; @@ -117,22 +113,18 @@ TORRENT_IPV6_NAMESPACE // The peer is the ip address of the peer this block was downloaded from. void set_peer(tcp::endpoint const& ep) { -#if TORRENT_USE_IPV6 is_v6_addr = is_v6(ep); if (is_v6_addr) addr.v6 = ep.address().to_v6().to_bytes(); else -#endif addr.v4 = ep.address().to_v4().to_bytes(); port = ep.port(); } tcp::endpoint peer() const { -#if TORRENT_USE_IPV6 if (is_v6_addr) return tcp::endpoint(address_v6(addr.v6), port); else -#endif return tcp::endpoint(address_v4(addr.v4), port); } @@ -150,10 +142,8 @@ TORRENT_IPV6_NAMESPACE // by more peers in parallel to speed things up. unsigned num_peers:14; private: -#if TORRENT_USE_IPV6 // the type of the addr union bool is_v6_addr:1; -#endif }; // This class holds information about pieces that have outstanding requests @@ -216,8 +206,6 @@ TORRENT_IPV6_NAMESPACE #endif }; -TORRENT_IPV6_NAMESPACE_END - // for std::hash (and to support using this type in unordered_map etc.) TORRENT_EXPORT std::size_t hash_value(torrent_handle const& h); diff --git a/include/libtorrent/torrent_peer.hpp b/include/libtorrent/torrent_peer.hpp index 0d15616e5..cdc7d930c 100644 --- a/include/libtorrent/torrent_peer.hpp +++ b/include/libtorrent/torrent_peer.hpp @@ -170,11 +170,9 @@ namespace libtorrent { bool pe_support:1; #endif -#if TORRENT_USE_IPV6 // this is true if the v6 union member in addr is // the one to use, false if it's the v4 one bool is_v6_addr:1; -#endif #if TORRENT_USE_I2P // set if the i2p_destination is in use in the addr union bool is_i2p_addr:1; @@ -230,7 +228,6 @@ namespace libtorrent { }; #endif -#if TORRENT_USE_IPV6 struct TORRENT_EXTRA_EXPORT ipv6_peer : torrent_peer { ipv6_peer(tcp::endpoint const& ip, bool connectable, peer_source_flags_t src); @@ -238,7 +235,6 @@ namespace libtorrent { const address_v6::bytes_type addr; }; -#endif struct peer_address_compare { diff --git a/include/libtorrent/torrent_peer_allocator.hpp b/include/libtorrent/torrent_peer_allocator.hpp index 30058e8ce..fbe7c03df 100644 --- a/include/libtorrent/torrent_peer_allocator.hpp +++ b/include/libtorrent/torrent_peer_allocator.hpp @@ -84,9 +84,7 @@ namespace libtorrent { // saves significant overhead boost::pool<> m_ipv4_peer_pool{sizeof(libtorrent::ipv4_peer), 500}; -#if TORRENT_USE_IPV6 boost::pool<> m_ipv6_peer_pool{sizeof(libtorrent::ipv6_peer), 500}; -#endif #if TORRENT_USE_I2P boost::pool<> m_i2p_peer_pool{sizeof(libtorrent::i2p_peer), 500}; #endif diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 2d98ecda3..01680dfee 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -143,9 +143,7 @@ namespace libtorrent { std::uint32_t key; int num_want; -#if TORRENT_USE_IPV6 std::vector ipv6; -#endif sha1_hash info_hash; peer_id pid; @@ -181,9 +179,7 @@ namespace libtorrent { // peers from the tracker, in various forms std::vector peers; std::vector peers4; -#if TORRENT_USE_IPV6 std::vector peers6; -#endif // our external IP address (if the tracker responded with ti, otherwise // INADDR_ANY) address external_ip; diff --git a/include/libtorrent/union_endpoint.hpp b/include/libtorrent/union_endpoint.hpp index b7fc7ab6e..a0f4cbba4 100644 --- a/include/libtorrent/union_endpoint.hpp +++ b/include/libtorrent/union_endpoint.hpp @@ -38,37 +38,27 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -TORRENT_IPV6_NAMESPACE - struct union_address { union_address() { *this = address(); } explicit union_address(address const& a) { *this = a; } union_address& operator=(address const& a) & { -#if TORRENT_USE_IPV6 v4 = a.is_v4(); if (v4) addr.v4 = a.to_v4().to_bytes(); else addr.v6 = a.to_v6().to_bytes(); -#else - addr.v4 = a.to_v4().to_bytes(); -#endif return *this; } bool operator==(union_address const& rh) const { -#if TORRENT_USE_IPV6 if (v4 != rh.v4) return false; if (v4) return addr.v4 == rh.addr.v4; else return addr.v6 == rh.addr.v6; -#else - return addr.v4 == rh.addr.v4; -#endif } bool operator!=(union_address const& rh) const @@ -78,24 +68,16 @@ TORRENT_IPV6_NAMESPACE operator address() const { -#if TORRENT_USE_IPV6 if (v4) return address(address_v4(addr.v4)); else return address(address_v6(addr.v6)); -#else - return address(address_v4(addr.v4)); -#endif } union addr_t { address_v4::bytes_type v4; -#if TORRENT_USE_IPV6 address_v6::bytes_type v6; -#endif } addr; -#if TORRENT_USE_IPV6 bool v4:1; -#endif }; struct union_endpoint @@ -126,7 +108,6 @@ TORRENT_IPV6_NAMESPACE union_address addr; std::uint16_t port; }; -TORRENT_IPV6_NAMESPACE_END } #endif diff --git a/src/alert.cpp b/src/alert.cpp index 709ff64c3..e9f1d604d 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -2116,27 +2116,21 @@ namespace { { if (is_v4(endp)) m_v4_num_peers++; -#if TORRENT_USE_IPV6 else m_v6_num_peers++; -#endif } m_v4_peers_idx = alloc.allocate(m_v4_num_peers * 6); m_v6_peers_idx = alloc.allocate(m_v6_num_peers * 18); char* v4_ptr = alloc.ptr(m_v4_peers_idx); -#if TORRENT_USE_IPV6 char* v6_ptr = alloc.ptr(m_v6_peers_idx); -#endif for (auto const& endp : peers) { if (is_v4(endp)) detail::write_endpoint(endp, v4_ptr); -#if TORRENT_USE_IPV6 else detail::write_endpoint(endp, v6_ptr); -#endif } } @@ -2169,11 +2163,9 @@ namespace { char const* v4_ptr = m_alloc.get().ptr(m_v4_peers_idx); for (int i = 0; i < m_v4_num_peers; i++) peers.push_back(detail::read_v4_endpoint(v4_ptr)); -#if TORRENT_USE_IPV6 char const* v6_ptr = m_alloc.get().ptr(m_v6_peers_idx); for (int i = 0; i < m_v6_num_peers; i++) peers.push_back(detail::read_v6_endpoint(v6_ptr)); -#endif return std::move(peers); } @@ -2349,19 +2341,15 @@ namespace { { if (is_v4(n.second)) v4_num_nodes++; -#if TORRENT_USE_IPV6 else v6_num_nodes++; -#endif } aux::allocation_slot const v4_nodes_idx = alloc.allocate(v4_num_nodes * (20 + 6)); aux::allocation_slot const v6_nodes_idx = alloc.allocate(v6_num_nodes * (20 + 18)); char* v4_ptr = alloc.ptr(v4_nodes_idx); -#if TORRENT_USE_IPV6 char* v6_ptr = alloc.ptr(v6_nodes_idx); -#endif for (auto const& n : nodes) { udp::endpoint const& endp = n.second; @@ -2370,13 +2358,11 @@ namespace { detail::write_string(n.first.to_string(), v4_ptr); detail::write_endpoint(endp, v4_ptr); } -#if TORRENT_USE_IPV6 else { detail::write_string(n.first.to_string(), v6_ptr); detail::write_endpoint(endp, v6_ptr); } -#endif } return nodes_slot{v4_num_nodes, v4_nodes_idx, v6_num_nodes, v6_nodes_idx}; @@ -2398,7 +2384,6 @@ namespace { v4_ptr += 20; nodes.emplace_back(ih, detail::read_v4_endpoint(v4_ptr)); } -#if TORRENT_USE_IPV6 char const* v6_ptr = alloc.ptr(v6_nodes_idx); for (int i = 0; i < v6_num_nodes; i++) { @@ -2407,9 +2392,6 @@ namespace { v6_ptr += 20; nodes.emplace_back(ih, detail::read_v6_endpoint(v6_ptr)); } -#else - TORRENT_UNUSED(v6_nodes_idx); -#endif return std::move(nodes); } diff --git a/src/broadcast_socket.cpp b/src/broadcast_socket.cpp index 8a7feb69f..35140ff84 100644 --- a/src/broadcast_socket.cpp +++ b/src/broadcast_socket.cpp @@ -56,7 +56,6 @@ namespace libtorrent { bool is_local(address const& a) { TORRENT_TRY { -#if TORRENT_USE_IPV6 if (a.is_v6()) { // NOTE: site local is deprecated but by @@ -73,7 +72,6 @@ namespace libtorrent { // fc00::/7, unique local address || (a6.to_bytes()[0] & 0xfe) == 0xfc; } -#endif address_v4 a4 = a.to_v4(); unsigned long ip = a4.to_ulong(); return ((ip & 0xff000000) == 0x0a000000 // 10.x.x.x @@ -86,54 +84,39 @@ namespace libtorrent { bool is_loopback(address const& addr) { -#if TORRENT_USE_IPV6 TORRENT_TRY { if (addr.is_v4()) return addr.to_v4() == address_v4::loopback(); else return addr.to_v6() == address_v6::loopback(); } TORRENT_CATCH(std::exception const&) { return false; } -#else - return addr.to_v4() == address_v4::loopback(); -#endif } bool is_any(address const& addr) { TORRENT_TRY { -#if TORRENT_USE_IPV6 if (addr.is_v4()) return addr.to_v4() == address_v4::any(); else if (addr.to_v6().is_v4_mapped()) return (addr.to_v6().to_v4() == address_v4::any()); else return addr.to_v6() == address_v6::any(); -#else - return addr.to_v4() == address_v4::any(); -#endif } TORRENT_CATCH(std::exception const&) { return false; } } bool is_teredo(address const& addr) { -#if TORRENT_USE_IPV6 TORRENT_TRY { if (!addr.is_v6()) return false; static const std::uint8_t teredo_prefix[] = {0x20, 0x01, 0, 0}; address_v6::bytes_type b = addr.to_v6().to_bytes(); return std::memcmp(b.data(), teredo_prefix, 4) == 0; } TORRENT_CATCH(std::exception const&) { return false; } -#else - TORRENT_UNUSED(addr); - return false; -#endif } bool supports_ipv6() { -#if !TORRENT_USE_IPV6 - return false; -#elif defined TORRENT_BUILD_SIMULATOR +#if defined TORRENT_BUILD_SIMULATOR return true; #elif defined TORRENT_WINDOWS TORRENT_TRY { @@ -155,11 +138,7 @@ namespace libtorrent { address ensure_v6(address const& a) { -#if TORRENT_USE_IPV6 return a == address_v4() ? address_v6() : a; -#else - return a; -#endif } broadcast_socket::broadcast_socket( @@ -178,11 +157,9 @@ namespace libtorrent { std::vector interfaces = enum_net_interfaces(ios, ec); -#if TORRENT_USE_IPV6 if (is_v6(m_multicast_endpoint)) open_multicast_socket(ios, address_v6::any(), loopback, ec); else -#endif open_multicast_socket(ios, address_v4::any(), loopback, ec); for (auto const& i : interfaces) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 266b1288c..f89e303a9 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -123,14 +123,11 @@ namespace { #ifndef TORRENT_DISABLE_EXTENSIONS bool ut_pex_peer_store::was_introduced_by(tcp::endpoint const &ep) { -#if TORRENT_USE_IPV6 if (is_v4(ep)) { -#endif peers4_t::value_type const v(ep.address().to_v4().to_bytes(), ep.port()); auto const i = std::lower_bound(m_peers.begin(), m_peers.end(), v); return i != m_peers.end() && *i == v; -#if TORRENT_USE_IPV6 } else { @@ -138,7 +135,6 @@ namespace { auto const i = std::lower_bound(m_peers6.begin(), m_peers6.end(), v); return i != m_peers6.end() && *i == v; } -#endif } #endif // TORRENT_DISABLE_EXTENSIONS @@ -1354,14 +1350,12 @@ namespace { // IPv4 address ep = detail::read_v4_endpoint(ptr); } -#if TORRENT_USE_IPV6 else if (addr_type == 1) { // IPv6 address if (int(recv_buffer.size()) < 2 + 18 + 2) return; ep = detail::read_v6_endpoint(ptr); } -#endif else { #ifndef TORRENT_DISABLE_LOGGING @@ -1750,7 +1744,6 @@ namespace { , address_v4(bytes) , aux::session_interface::source_peer, remote().address()); } -#if TORRENT_USE_IPV6 else if (myip.size() == std::tuple_size::value) { address_v6::bytes_type bytes; @@ -1765,7 +1758,6 @@ namespace { , ipv6_address , aux::session_interface::source_peer, remote().address()); } -#endif } // if we're finished and this peer is uploading only diff --git a/src/enum_net.cpp b/src/enum_net.cpp index f49f45d1e..28ff88000 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -127,14 +127,12 @@ namespace { return address_v4(b); } -#if TORRENT_USE_IPV6 address_v6 inaddr6_to_address(in6_addr const* ina6, int const len = 16) { boost::asio::ip::address_v6::bytes_type b = {}; if (len > 0) std::memcpy(b.data(), ina6, std::min(std::size_t(len), b.size())); return address_v6(b); } -#endif #if !TORRENT_USE_NETLINK int sockaddr_len(sockaddr const* sin) @@ -151,7 +149,6 @@ namespace { if (sin->sa_family == AF_INET || assume_family == AF_INET) return inaddr_to_address(&reinterpret_cast(sin)->sin_addr , sockaddr_len(sin) - int(offsetof(sockaddr, sa_data))); -#if TORRENT_USE_IPV6 else if (sin->sa_family == AF_INET6 || assume_family == AF_INET6) { auto saddr = reinterpret_cast(sin); @@ -160,7 +157,6 @@ namespace { ret.scope_id(saddr->sin6_scope_id); return ret; } -#endif return address(); } #endif @@ -168,9 +164,7 @@ namespace { bool valid_addr_family(int family) { return (family == AF_INET -#if TORRENT_USE_IPV6 || family == AF_INET6 -#endif ); } @@ -193,7 +187,6 @@ namespace { } return address_v4(b); } -#if TORRENT_USE_IPV6 else if (family == AF_INET6) { address_v6::bytes_type b; @@ -210,7 +203,6 @@ namespace { } return address_v6(b); } -#endif else { return address(); @@ -299,7 +291,6 @@ namespace { && rt_msg->rtm_table != RT_TABLE_LOCAL)) return false; -#if TORRENT_USE_IPV6 // make sure the defaults have the right address family // in case the attributes are not present if (rt_msg->rtm_family == AF_INET6) @@ -307,7 +298,6 @@ namespace { rt_info->gateway = address_v6(); rt_info->destination = address_v6(); } -#endif int if_index = 0; int rt_len = int(RTM_PAYLOAD(nl_hdr)); @@ -324,25 +314,21 @@ namespace { if_index = *reinterpret_cast(RTA_DATA(rt_attr)); break; case RTA_GATEWAY: -#if TORRENT_USE_IPV6 if (rt_msg->rtm_family == AF_INET6) { rt_info->gateway = inaddr6_to_address(reinterpret_cast(RTA_DATA(rt_attr))); } else -#endif { rt_info->gateway = inaddr_to_address(reinterpret_cast(RTA_DATA(rt_attr))); } break; case RTA_DST: -#if TORRENT_USE_IPV6 if (rt_msg->rtm_family == AF_INET6) { rt_info->destination = inaddr6_to_address(reinterpret_cast(RTA_DATA(rt_attr))); } else -#endif { rt_info->destination = inaddr_to_address(reinterpret_cast(RTA_DATA(rt_attr))); } @@ -353,14 +339,12 @@ namespace { #pragma clang diagnostic pop #endif -#if TORRENT_USE_IPV6 if (rt_info->gateway.is_v6() && rt_info->gateway.to_v6().is_link_local()) { address_v6 gateway6 = rt_info->gateway.to_v6(); gateway6.scope_id(std::uint32_t(if_index)); rt_info->gateway = gateway6; } -#endif ifreq req = {}; ::if_indextoname(std::uint32_t(if_index), req.ifr_name); @@ -381,7 +365,6 @@ namespace { ip_info->preferred = (addr_msg->ifa_flags & (IFA_F_DADFAILED | IFA_F_DEPRECATED | IFA_F_TENTATIVE)) == 0; -#if TORRENT_USE_IPV6 if (addr_msg->ifa_family == AF_INET6) { TORRENT_ASSERT(addr_msg->ifa_prefixlen <= 128); @@ -403,7 +386,6 @@ namespace { } } else -#endif { TORRENT_ASSERT(addr_msg->ifa_prefixlen <= 32); if (addr_msg->ifa_prefixlen != 0) @@ -432,7 +414,6 @@ namespace { break; BOOST_FALLTHROUGH; case IFA_LOCAL: -#if TORRENT_USE_IPV6 if (addr_msg->ifa_family == AF_INET6) { address_v6 addr = inaddr6_to_address(reinterpret_cast(RTA_DATA(rt_attr))); @@ -441,7 +422,6 @@ namespace { ip_info->interface_address = addr; } else -#endif { ip_info->interface_address = inaddr_to_address(reinterpret_cast(RTA_DATA(rt_attr))); } @@ -535,7 +515,6 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl if (a1.is_v4() != a2.is_v4()) return false; if (a1.is_v4() != mask.is_v4()) return false; -#if TORRENT_USE_IPV6 if (a1.is_v6()) { address_v6::bytes_type b1 = a1.to_v6().to_bytes(); @@ -546,9 +525,8 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl b1[i] &= m[i]; b2[i] &= m[i]; } - return std::memcmp(b1.data(), b2.data(), b1.size()) == 0; + return b1 == b2; } -#endif return (a1.to_v4().to_ulong() & mask.to_v4().to_ulong()) == (a2.to_v4().to_ulong() & mask.to_v4().to_ulong()); } @@ -703,14 +681,12 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl std::strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE - 1); if (ioctl(s, SIOCGIFNETMASK, &req) < 0) { -#if TORRENT_USE_IPV6 if (iface.interface_address.is_v6()) { // this is expected to fail (at least on MacOS X) iface.netmask = address_v6::any(); } else -#endif { ec = error_code(errno, system_category()); ::close(s); @@ -1142,7 +1118,6 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl { ip_route r; r.gateway = sockaddr_to_address((const sockaddr*)&routes->Table[i].NextHop); -#if TORRENT_USE_IPV6 // The scope_id in NextHop is always zero because that would make // things too easy apparently if (r.gateway.is_v6() && r.gateway.to_v6().is_link_local()) @@ -1151,7 +1126,6 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl gateway6.scope_id(routes->Table[i].InterfaceIndex); r.gateway = gateway6; } -#endif r.destination = sockaddr_to_address( (const sockaddr*)&routes->Table[i].DestinationPrefix.Prefix); r.netmask = build_netmask(routes->Table[i].DestinationPrefix.PrefixLength diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index d597bcba8..3f527e813 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -172,7 +172,6 @@ namespace libtorrent { } } -#if TORRENT_USE_IPV6 if (!tracker_req().ipv6.empty() && !i2p) { for (auto const& v6 : tracker_req().ipv6) @@ -184,7 +183,6 @@ namespace libtorrent { url += escape_string(ip); } } -#endif if (!tracker_req().outgoing_socket) { @@ -540,7 +538,6 @@ namespace libtorrent { peers_ent.clear(); } -#if TORRENT_USE_IPV6 bdecode_node ipv6_peers = e.dict_find_string("peers6"); if (ipv6_peers) { @@ -561,9 +558,6 @@ namespace libtorrent { { ipv6_peers.clear(); } -#else - bdecode_node ipv6_peers; -#endif /* // if we didn't receive any peers. We don't care if we're stopping anyway if (peers_ent == 0 && ipv6_peers == 0 @@ -579,10 +573,8 @@ namespace libtorrent { char const* p = ip_ent.string_ptr(); if (ip_ent.string_length() == std::tuple_size::value) resp.external_ip = detail::read_v4_address(p); -#if TORRENT_USE_IPV6 else if (ip_ent.string_length() == std::tuple_size::value) resp.external_ip = detail::read_v6_address(p); -#endif } return resp; diff --git a/src/ip_filter.cpp b/src/ip_filter.cpp index 8b50f23f9..d28cb7299 100644 --- a/src/ip_filter.cpp +++ b/src/ip_filter.cpp @@ -41,13 +41,11 @@ namespace libtorrent { TORRENT_ASSERT(last.is_v4()); m_filter4.add_rule(first.to_v4().to_bytes(), last.to_v4().to_bytes(), flags); } -#if TORRENT_USE_IPV6 else if (first.is_v6()) { TORRENT_ASSERT(last.is_v6()); m_filter6.add_rule(first.to_v6().to_bytes(), last.to_v6().to_bytes(), flags); } -#endif else TORRENT_ASSERT_FAIL(); } @@ -56,22 +54,14 @@ namespace libtorrent { { if (addr.is_v4()) return m_filter4.access(addr.to_v4().to_bytes()); -#if TORRENT_USE_IPV6 TORRENT_ASSERT(addr.is_v6()); return m_filter6.access(addr.to_v6().to_bytes()); -#else - return 0; -#endif } ip_filter::filter_tuple_t ip_filter::export_filter() const { -#if TORRENT_USE_IPV6 return std::make_tuple(m_filter4.export_filter() , m_filter6.export_filter()); -#else - return m_filter4.export_filter(); -#endif } void port_filter::add_rule(std::uint16_t first, std::uint16_t last, std::uint32_t flags) diff --git a/src/ip_voter.cpp b/src/ip_voter.cpp index 357c7fc51..23f6ad8a0 100644 --- a/src/ip_voter.cpp +++ b/src/ip_voter.cpp @@ -177,10 +177,8 @@ namespace libtorrent { , address const& local6, address const& global6) : m_addresses{{global4, ensure_v6(global6)}, {local4, ensure_v6(local6)}} { -#if TORRENT_USE_IPV6 TORRENT_ASSERT(m_addresses[0][1].is_v6()); TORRENT_ASSERT(m_addresses[1][1].is_v6()); -#endif TORRENT_ASSERT(m_addresses[0][0].is_v4()); TORRENT_ASSERT(m_addresses[1][0].is_v4()); } @@ -188,9 +186,7 @@ namespace libtorrent { address external_ip::external_address(address const& ip) const { address ext = m_addresses[is_local(ip)][ip.is_v6()]; -#if TORRENT_USE_IPV6 if (ip.is_v6() && ext == address_v4()) return address_v6(); -#endif return ext; } } diff --git a/src/kademlia/dht_state.cpp b/src/kademlia/dht_state.cpp index 1cca95f82..111db00d2 100644 --- a/src/kademlia/dht_state.cpp +++ b/src/kademlia/dht_state.cpp @@ -61,10 +61,8 @@ namespace libtorrent { namespace dht { address addr; if (nid.string_length() == 24) addr = detail::read_v4_address(in); -#if TORRENT_USE_IPV6 else if (nid.string_length() == 36) addr = detail::read_v6_address(in); -#endif else continue; ret.emplace_back(addr, id); @@ -110,10 +108,8 @@ namespace { if (bdecode_node const nodes = e.dict_find_list("nodes")) ret.nodes = detail::read_endpoint_list(nodes); -#if TORRENT_USE_IPV6 if (bdecode_node const nodes = e.dict_find_list("nodes6")) ret.nodes6 = detail::read_endpoint_list(nodes); -#endif return ret; } @@ -130,10 +126,8 @@ namespace { } entry const nodes = save_nodes(state.nodes); if (!nodes.list().empty()) ret["nodes"] = nodes; -#if TORRENT_USE_IPV6 entry const nodes6 = save_nodes(state.nodes6); if (!nodes6.list().empty()) ret["nodes6"] = nodes6; -#endif return ret; } }} diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index ca1a9313d..66da30465 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -119,13 +119,11 @@ namespace libtorrent { namespace dht { if (s.is_ssl()) return; address const local_address = s.get_local_endpoint().address(); -#if TORRENT_USE_IPV6 // don't try to start dht nodes on non-global IPv6 addresses // with IPv4 the interface might be behind NAT so we can't skip them based on the scope of the local address // and we might not have the external address yet if (local_address.is_v6() && is_local(local_address)) return; -#endif auto stored_nid = std::find_if(m_state.nids.begin(), m_state.nids.end() , [&](node_ids_t::value_type const& nid) { return nid.first == local_address; }); node_id const nid = stored_nid != m_state.nids.end() ? stored_nid->second : node_id(); @@ -160,12 +158,10 @@ namespace libtorrent { namespace dht { { if (s.is_ssl()) return; -#if TORRENT_USE_IPV6 address local_address = s.get_local_endpoint().address(); // since we don't start nodes on local IPv6 interfaces we don't need to remove them either if (local_address.is_v6() && is_local(local_address)) return; -#endif TORRENT_ASSERT(m_nodes.count(s) == 1); m_nodes.erase(s); } @@ -181,11 +177,9 @@ namespace libtorrent { namespace dht { n.second.connection_timer.expires_from_now(seconds(1), ec); n.second.connection_timer.async_wait( std::bind(&dht_tracker::connection_timeout, self(), n.first, _1)); -#if TORRENT_USE_IPV6 if (is_v6(n.first.get_local_endpoint())) n.second.dht.bootstrap(concat(m_state.nodes6, m_state.nodes), f); else -#endif n.second.dht.bootstrap(concat(m_state.nodes, m_state.nodes6), f); } @@ -626,18 +620,12 @@ namespace libtorrent { namespace dht { void dht_tracker::add_node(udp::endpoint const& node) { -#if !TORRENT_USE_IPV6 - TORRENT_ASSERT(is_v4(node)); -#endif for (auto& n : m_nodes) n.second.dht.add_node(node); } void dht_tracker::add_router_node(udp::endpoint const& node) { -#if !TORRENT_USE_IPV6 - TORRENT_ASSERT(is_v4(node)); -#endif for (auto& n : m_nodes) n.second.dht.add_router_node(node); } diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index 32d678f51..c039372da 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -223,10 +223,6 @@ void node::bootstrap(std::vector const& nodes for (auto const& n : nodes) { -#if !TORRENT_USE_IPV6 - if (is_v6(n)) continue; -#endif - #ifndef TORRENT_DISABLE_LOGGING ++count; #endif @@ -282,7 +278,6 @@ void node::incoming(aux::listen_socket_handle const& s, msg const& m) ext_ip = r.dict_find_string("ip"); } -#if TORRENT_USE_IPV6 if (ext_ip && ext_ip.string_length() >= 16) { // this node claims we use the wrong node-ID! @@ -291,9 +286,8 @@ void node::incoming(aux::listen_socket_handle const& s, msg const& m) if (m_observer != nullptr) m_observer->set_external_address(m_sock, address_v6(b) , m.addr.address()); - } else -#endif - if (ext_ip && ext_ip.string_length() >= 4) + } + else if (ext_ip && ext_ip.string_length() >= 4) { address_v4::bytes_type b{}; std::memcpy(&b[0], ext_ip.string_ptr(), 4); diff --git a/src/kademlia/node_id.cpp b/src/kademlia/node_id.cpp index 10344dbb7..dfd394c5c 100644 --- a/src/kademlia/node_id.cpp +++ b/src/kademlia/node_id.cpp @@ -85,14 +85,11 @@ node_id generate_id_impl(address const& ip_, std::uint32_t r) std::uint8_t* ip = nullptr; static const std::uint8_t v4mask[] = { 0x03, 0x0f, 0x3f, 0xff }; -#if TORRENT_USE_IPV6 static const std::uint8_t v6mask[] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; -#endif std::uint8_t const* mask = nullptr; int num_octets = 0; address_v4::bytes_type b4{}; -#if TORRENT_USE_IPV6 address_v6::bytes_type b6{}; if (ip_.is_v6()) { @@ -102,7 +99,6 @@ node_id generate_id_impl(address const& ip_, std::uint32_t r) mask = v6mask; } else -#endif { b4 = ip_.to_v4().to_bytes(); ip = b4.data(); diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 5ae448886..578bc2bb9 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -78,31 +78,25 @@ namespace { void ip_set::insert(address const& addr) { -#if TORRENT_USE_IPV6 if (addr.is_v6()) m_ip6s.insert(addr.to_v6().to_bytes()); else -#endif m_ip4s.insert(addr.to_v4().to_bytes()); } bool ip_set::exists(address const& addr) const { -#if TORRENT_USE_IPV6 if (addr.is_v6()) return m_ip6s.find(addr.to_v6().to_bytes()) != m_ip6s.end(); else -#endif return m_ip4s.find(addr.to_v4().to_bytes()) != m_ip4s.end(); } void ip_set::erase(address const& addr) { -#if TORRENT_USE_IPV6 if (addr.is_v6()) erase_one(m_ip6s, addr.to_v6().to_bytes()); else -#endif erase_one(m_ip4s, addr.to_v4().to_bytes()); } @@ -315,7 +309,6 @@ bool compare_ip_cidr(address const& lhs, address const& rhs) { TORRENT_ASSERT(lhs.is_v4() == rhs.is_v4()); -#if TORRENT_USE_IPV6 if (lhs.is_v6()) { // if IPv6 addresses is in the same /64, they're too close and we won't @@ -331,7 +324,6 @@ bool compare_ip_cidr(address const& lhs, address const& rhs) return mask == 0; } else -#endif { // if IPv4 addresses is in the same /24, they're too close and we won't // trust the second one @@ -1021,9 +1013,6 @@ void routing_table::node_failed(node_id const& nid, udp::endpoint const& ep) void routing_table::add_router_node(udp::endpoint const& router) { -#if !TORRENT_USE_IPV6 - TORRENT_ASSERT(is_v4(router)); -#endif m_router_nodes.insert(router); } diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index 4079e3c4a..17e8bd583 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -83,14 +83,12 @@ void observer::set_target(udp::endpoint const& ep) m_sent = clock_type::now(); m_port = ep.port(); -#if TORRENT_USE_IPV6 if (is_v6(ep)) { flags |= flag_ipv6_address; m_addr.v6 = ep.address().to_v6().to_bytes(); } else -#endif { flags &= ~flag_ipv6_address; m_addr.v4 = ep.address().to_v4().to_bytes(); @@ -99,11 +97,9 @@ void observer::set_target(udp::endpoint const& ep) address observer::target_addr() const { -#if TORRENT_USE_IPV6 if (flags & flag_ipv6_address) return address_v6(m_addr.v6); else -#endif return address_v4(m_addr.v4); } diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index 85fe23c3e..8fdf27495 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -182,7 +182,6 @@ void traversal_algorithm::add_entry(node_id const& id if (m_node.settings().restrict_search_ips && !(flags & observer::flag_initial)) { -#if TORRENT_USE_IPV6 if (o->target_addr().is_v6()) { address_v6::bytes_type addr_bytes = o->target_addr().to_v6().to_bytes(); @@ -193,7 +192,6 @@ void traversal_algorithm::add_entry(node_id const& id goto add_result; } else -#endif { // mask the lower octet std::uint32_t const prefix4 diff --git a/src/lsd.cpp b/src/lsd.cpp index d009099fc..818a4aaa8 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -69,15 +69,11 @@ static error_code dummy; lsd::lsd(io_service& ios, aux::lsd_callback& cb) : m_callback(cb) , m_socket(udp::endpoint(make_address_v4("239.192.152.143", dummy), 6771)) -#if TORRENT_USE_IPV6 , m_socket6(udp::endpoint(make_address_v6("ff15::efc0:988f", dummy), 6771)) -#endif , m_broadcast_timer(ios) , m_cookie((random(0x7fffffff) ^ std::uintptr_t(this)) & 0x7fffffff) , m_disabled(false) -#if TORRENT_USE_IPV6 , m_disabled6(false) -#endif { } @@ -107,10 +103,8 @@ void lsd::start(error_code& ec) , m_broadcast_timer.get_io_service(), ec); if (ec) return; -#if TORRENT_USE_IPV6 m_socket6.open(std::bind(&lsd::on_announce, self(), _1, _2) , m_broadcast_timer.get_io_service(), ec); -#endif } lsd::~lsd() = default; @@ -123,11 +117,7 @@ void lsd::announce(sha1_hash const& ih, int listen_port, bool broadcast) void lsd::announce_impl(sha1_hash const& ih, int const listen_port , bool const broadcast, int retry_count) { -#if TORRENT_USE_IPV6 if (m_disabled && m_disabled6) return; -#else - if (m_disabled) return; -#endif char msg[200]; @@ -154,7 +144,6 @@ void lsd::announce_impl(sha1_hash const& ih, int const listen_port } } -#if TORRENT_USE_IPV6 if (!m_disabled6) { int const msg_len = render_lsd_packet(msg, sizeof(msg), listen_port, aux::to_hex(ih).c_str() @@ -172,16 +161,11 @@ void lsd::announce_impl(sha1_hash const& ih, int const listen_port #endif } } -#endif ++retry_count; if (retry_count >= 3) return; -#if TORRENT_USE_IPV6 if (m_disabled && m_disabled6) return; -#else - if (m_disabled) return; -#endif ADD_OUTSTANDING_ASYNC("lsd::resend_announce"); m_broadcast_timer.expires_from_now(seconds(2 * retry_count), ec); @@ -292,15 +276,11 @@ void lsd::on_announce(udp::endpoint const& from, span buf) void lsd::close() { m_socket.close(); -#if TORRENT_USE_IPV6 m_socket6.close(); -#endif error_code ec; m_broadcast_timer.cancel(ec); m_disabled = true; -#if TORRENT_USE_IPV6 m_disabled6 = true; -#endif } } // libtorrent namespace diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 982557af5..2d2ceee14 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -504,9 +504,6 @@ void natpmp::send_map_request(port_mapping_t const i) else if (m_version == version_pcp) { // PCP requires the use of IPv6 addresses even for IPv4 messages - // reference asio's address_v6 class directly so that we can use it - // even if TORRENT_USE_IPV6 is false - using boost::asio::ip::address_v6; write_uint8(m_version, out); write_uint8(opcode_map, out); write_uint16(0, out); // reserved @@ -763,14 +760,12 @@ void natpmp::on_reply(error_code const& e if (version == version_natpmp) lifetime = aux::numeric_cast(read_uint32(in)); address external_addr; -#if TORRENT_USE_IPV6 if (version == version_pcp) { external_addr = read_v6_address(in); if (external_addr.to_v6().is_v4_mapped()) external_addr = external_addr.to_v6().to_v4(); } -#endif if (version == version_natpmp) { diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 530abefe9..b2076983d 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -340,7 +340,7 @@ namespace libtorrent { } #endif } -#if TORRENT_USE_IPV6 && defined IPV6_TCLASS +#if defined IPV6_TCLASS else if (is_v6(m_remote) && m_settings.get_int(settings_pack::peer_tos) != 0) { m_socket->set_option(traffic_class(char(m_settings.get_int(settings_pack::peer_tos))), ec); @@ -649,13 +649,11 @@ namespace libtorrent { address_v4::bytes_type bytes = addr.to_v4().to_bytes(); x.assign(reinterpret_cast(bytes.data()), bytes.size()); } -#if TORRENT_USE_IPV6 else { address_v6::bytes_type bytes = addr.to_v6().to_bytes(); x.assign(reinterpret_cast(bytes.data()), bytes.size()); } -#endif x.append(t->torrent_file().info_hash().data(), 20); sha1_hash hash = hasher(x).final(); @@ -6131,7 +6129,7 @@ namespace libtorrent { } #endif } -#if TORRENT_USE_IPV6 && defined IPV6_TCLASS +#if defined IPV6_TCLASS else if (is_v6(m_remote) && m_settings.get_int(settings_pack::peer_tos) != 0) { error_code err; diff --git a/src/peer_list.cpp b/src/peer_list.cpp index 698fed592..9493b3fb9 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -734,21 +734,15 @@ namespace libtorrent { ); } -#if TORRENT_USE_IPV6 bool const is_v6 = lt::is_v6(c.remote()); -#else - bool const is_v6 = false; -#endif torrent_peer* p = m_peer_allocator.allocate_peer_entry( is_v6 ? torrent_peer_allocator_interface::ipv6_peer_type : torrent_peer_allocator_interface::ipv4_peer_type); if (p == nullptr) return false; -#if TORRENT_USE_IPV6 if (is_v6) new (p) ipv6_peer(c.remote(), false, {}); else -#endif new (p) ipv4_peer(c.remote(), false, {}); iter = m_peers.insert(iter, p); @@ -1043,13 +1037,11 @@ namespace libtorrent { if (remote_address == address() || remote.port() == 0) return nullptr; -#if TORRENT_USE_IPV6 // don't allow link-local IPv6 addresses since they // can't be used like normal addresses, they require an interface // and will just cause connect() to fail with EINVAL if (remote_address.is_v6() && remote_address.to_v6().is_link_local()) return nullptr; -#endif iterator iter; torrent_peer* p = nullptr; @@ -1075,21 +1067,15 @@ namespace libtorrent { // we don't have any info about this peer. // add a new entry -#if TORRENT_USE_IPV6 bool const is_v6 = remote_address.is_v6(); -#else - bool const is_v6 = false; -#endif p = m_peer_allocator.allocate_peer_entry( is_v6 ? torrent_peer_allocator_interface::ipv6_peer_type : torrent_peer_allocator_interface::ipv4_peer_type); if (p == nullptr) return nullptr; -#if TORRENT_USE_IPV6 if (is_v6) new (p) ipv6_peer(remote, true, src); else -#endif new (p) ipv4_peer(remote, true, src); try diff --git a/src/read_resume_data.cpp b/src/read_resume_data.cpp index d2ae424a4..45dd779ae 100644 --- a/src/read_resume_data.cpp +++ b/src/read_resume_data.cpp @@ -292,9 +292,7 @@ namespace { } } -#if TORRENT_USE_IPV6 int const v6_size = 18; -#endif int const v4_size = 6; using namespace libtorrent::detail; // for read_*_endpoint() if (bdecode_node const peers_entry = rd.dict_find_string("peers")) @@ -304,14 +302,12 @@ namespace { ret.peers.push_back(read_v4_endpoint(ptr)); } -#if TORRENT_USE_IPV6 if (bdecode_node const peers_entry = rd.dict_find_string("peers6")) { char const* ptr = peers_entry.string_ptr(); for (int i = v6_size - 1; i < peers_entry.string_length(); i += v6_size) ret.peers.push_back(read_v6_endpoint(ptr)); } -#endif if (bdecode_node const peers_entry = rd.dict_find_string("banned_peers")) { @@ -320,14 +316,12 @@ namespace { ret.banned_peers.push_back(read_v4_endpoint(ptr)); } -#if TORRENT_USE_IPV6 if (bdecode_node const peers_entry = rd.dict_find_string("banned_peers6")) { char const* ptr = peers_entry.string_ptr(); for (int i = v6_size - 1; i < peers_entry.string_length(); i += v6_size) ret.banned_peers.push_back(read_v6_endpoint(ptr)); } -#endif // parse unfinished pieces if (bdecode_node const unfinished_entry = rd.dict_find_list("unfinished")) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 51b710238..0216477b7 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -301,7 +301,6 @@ namespace aux { {"127.0.0.0", "127.255.255.255", lfilter}, }; -#if TORRENT_USE_IPV6 static const class_mapping v6_classes[] = { // everything @@ -313,7 +312,6 @@ namespace aux { // loop-back {"::1", "::1", lfilter}, }; -#endif class_mapping const* p = v4_classes; int len = sizeof(v4_classes) / sizeof(v4_classes[0]); @@ -326,7 +324,6 @@ namespace aux { if (ec) continue; m_peer_class_filter.add_rule(begin, end, p[i].filter); } -#if TORRENT_USE_IPV6 p = v6_classes; len = sizeof(v6_classes) / sizeof(v6_classes[0]); if (!unlimited_local) len = 1; @@ -338,7 +335,6 @@ namespace aux { if (ec) continue; m_peer_class_filter.add_rule(begin, end, p[i].filter); } -#endif } #if defined TORRENT_USE_OPENSSL && OPENSSL_VERSION_NUMBER >= 0x90812f @@ -1398,7 +1394,6 @@ namespace aux { } #endif // TORRENT_WINDOWS -#if TORRENT_USE_IPV6 if (is_v6(bind_ep)) { error_code err; // ignore errors here @@ -1423,7 +1418,6 @@ namespace aux { #endif // TORRENT_DISABLE_LOGGING #endif // TORRENT_WINDOWS } -#endif // TORRENT_USE_IPV6 if (!lep.device.empty()) { @@ -1716,10 +1710,7 @@ namespace aux { address const adr = make_address(device.c_str(), err); if (!err) { -#if !TORRENT_USE_IPV6 - if (adr.is_v4()) -#endif - eps.emplace_back(adr, port, std::string(), ssl, incoming); + eps.emplace_back(adr, port, std::string(), ssl, incoming); } else { @@ -1811,13 +1802,11 @@ namespace aux { interface_to_endpoints(device, port, ssl, incoming, eps); } -#if TORRENT_USE_IPV6 std::vector const ifs = enum_net_interfaces(m_io_service, ec); if (!ec) { expand_unspecified_address(ifs, eps); } -#endif // if no listen interfaces are specified, create sockets to use // any interface @@ -1825,10 +1814,8 @@ namespace aux { { eps.emplace_back(address_v4(), 0, "", transport::plaintext , duplex::only_outgoing); -#if TORRENT_USE_IPV6 eps.emplace_back(address_v6(), 0, "", transport::plaintext , duplex::only_outgoing); -#endif } auto remove_iter = partition_listen_sockets(eps, m_listen_sockets); @@ -1984,14 +1971,10 @@ namespace aux { if (eps.empty()) { eps.emplace_back(address_v4(), 0, "", transport::plaintext); -#if TORRENT_USE_IPV6 eps.emplace_back(address_v6(), 0, "", transport::plaintext); -#endif #ifdef TORRENT_USE_OPENSSL eps.emplace_back(address_v4(), 0, "", transport::ssl); -#if TORRENT_USE_IPV6 eps.emplace_back(address_v6(), 0, "", transport::ssl); -#endif #endif } @@ -2111,13 +2094,11 @@ namespace aux { if (map_handle != port_mapping_t{-1}) m.delete_mapping(map_handle); map_handle = port_mapping_t{-1}; -#if TORRENT_USE_IPV6 address const addr = ep.address(); // with IPv4 the interface might be behind NAT so we can't skip them // based on the scope of the local address if (addr.is_v6() && is_local(addr)) return; -#endif // only update this mapping if we actually have a socket listening if (ep != EndpointType()) @@ -3575,10 +3556,6 @@ namespace aux { void session_impl::add_dht_node(udp::endpoint const& n) { TORRENT_ASSERT(is_single_thread()); -#if !TORRENT_USE_IPV6 - if (!is_v4(n)) return; -#endif - if (m_dht) m_dht->add_node(n); else m_dht_nodes.push_back(n); } @@ -5063,11 +5040,9 @@ namespace aux { // to the same protocol family as the target endpoint if (is_any(bind_ep.address())) { -#if TORRENT_USE_IPV6 if (remote_address.is_v6()) bind_ep.address(address_v6::any()); else -#endif bind_ep.address(address_v4::any()); } @@ -5942,9 +5917,6 @@ namespace aux { for (auto const& addr : addresses) { -#if !TORRENT_USE_IPV6 - if (!addr.is_v4()) continue; -#endif // router nodes should be added before the DHT is started (and bootstrapped) udp::endpoint ep(addr, std::uint16_t(port)); if (m_dht) m_dht->add_router_node(ep); @@ -6241,7 +6213,7 @@ namespace aux { template void set_tos(Socket& s, int v, error_code& ec) { -#if TORRENT_USE_IPV6 && defined IPV6_TCLASS +#if defined IPV6_TCLASS if (is_v6(s.local_endpoint(ec))) s.set_option(traffic_class(char(v)), ec); else if (!ec) @@ -7162,12 +7134,10 @@ namespace aux { { debug_log(" %s:%d", print_address(address_v4(p.ip)).c_str(), p.port); } -#if TORRENT_USE_IPV6 for (auto const& p : resp.peers6) { debug_log(" [%s]:%d", print_address(address_v6(p.ip)).c_str(), p.port); } -#endif } void tracker_logger::tracker_request_error(tracker_request const& diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 414ca52f2..77ff746c8 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -118,11 +118,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0; DEPRECATED_SET_STR(mmap_cache, nullptr, nullptr), SET(handshake_client_version, nullptr, nullptr), SET(outgoing_interfaces, "", &session_impl::update_outgoing_interfaces), -#if !TORRENT_USE_IPV6 - SET(listen_interfaces, "0.0.0.0:6881", &session_impl::update_listen_interfaces), -#else SET(listen_interfaces, "0.0.0.0:6881,[::]:6881", &session_impl::update_listen_interfaces), -#endif SET(proxy_hostname, "", &session_impl::update_proxy), SET(proxy_username, "", &session_impl::update_proxy), SET(proxy_password, "", &session_impl::update_proxy), diff --git a/src/socket_io.cpp b/src/socket_io.cpp index c89aadd62..14715fbff 100644 --- a/src/socket_io.cpp +++ b/src/socket_io.cpp @@ -68,11 +68,9 @@ namespace libtorrent { { error_code ec; char buf[200]; -#if TORRENT_USE_IPV6 if (addr.is_v6()) std::snprintf(buf, sizeof(buf), "[%s]:%d", addr.to_string(ec).c_str(), port); else -#endif std::snprintf(buf, sizeof(buf), "%s:%d", addr.to_string(ec).c_str(), port); return buf; } @@ -120,11 +118,7 @@ namespace libtorrent { } // shave off the ':' port = port.substr(1); -#if TORRENT_USE_IPV6 ret.address(make_address_v6(addr.to_string(), ec)); -#else - ec = boost::asio::error::address_family_not_supported; -#endif if (ec) return ret; } else @@ -159,14 +153,12 @@ namespace libtorrent { sha1_hash hash_address(address const& ip) { -#if TORRENT_USE_IPV6 if (ip.is_v6()) { address_v6::bytes_type b = ip.to_v6().to_bytes(); return hasher(reinterpret_cast(b.data()), int(b.size())).final(); } else -#endif { address_v4::bytes_type b = ip.to_v4().to_bytes(); return hasher(reinterpret_cast(b.data()), int(b.size())).final(); diff --git a/src/string_util.cpp b/src/string_util.cpp index 870c48651..9c2bfaa5d 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -177,7 +177,6 @@ namespace libtorrent { { if (!ret.empty()) ret += ','; -#if TORRENT_USE_IPV6 error_code ec; make_address_v6(i.device, ec); if (!ec) @@ -188,7 +187,6 @@ namespace libtorrent { ret += ']'; } else -#endif { ret += i.device; } @@ -220,14 +218,8 @@ namespace libtorrent { listen_interface_t iface; iface.ssl = false; -#if !TORRENT_USE_IPV6 - bool ipv6 = false; -#endif if (in[start] == '[') { -#if !TORRENT_USE_IPV6 - ipv6 = true; -#endif ++start; // IPv6 address while (start < in.size() && in[start] != ']') @@ -285,14 +277,7 @@ namespace libtorrent { while (start < in.size() && in[start] != ',') ++start; - if (iface.port >= 0 -#if !TORRENT_USE_IPV6 - && ipv6 == false -#endif - ) - { - out.push_back(iface); - } + if (iface.port >= 0) out.push_back(iface); // skip the comma if (start < in.size() && in[start] == ',') diff --git a/src/torrent.cpp b/src/torrent.cpp index 4583916d3..bf2d949e5 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2776,7 +2776,6 @@ bool is_downloading_state(int const st) req.event = e; -#if TORRENT_USE_IPV6 // since sending our IPv6 address to the tracker may be sensitive. Only // do that if we're not in anonymous mode and if it's a private torrent if (!settings().get_bool(settings_pack::anonymous_mode) @@ -2792,7 +2791,6 @@ bool is_downloading_state(int const st) req.ipv6.push_back(s.get_local_endpoint().address().to_v6()); }); } -#endif // if we are aborting. we don't want any new peers req.num_want = (req.event == tracker_request::stopped) @@ -3215,13 +3213,11 @@ bool is_downloading_state(int const st) need_update |= bool(add_peer(a, peer_info::tracker) != nullptr); } -#if TORRENT_USE_IPV6 for (auto const& i : resp.peers6) { tcp::endpoint a(address_v6(i.ip), i.port); need_update |= bool(add_peer(a, peer_info::tracker) != nullptr); } -#endif if (need_update) state_updated(); update_want_peers(); @@ -3232,9 +3228,7 @@ bool is_downloading_state(int const st) { m_ses.alerts().emplace_alert( get_handle(), local_endpoint, int(resp.peers.size() + resp.peers4.size()) -#if TORRENT_USE_IPV6 + int(resp.peers6.size()) -#endif , r.url); } @@ -10068,18 +10062,6 @@ bool is_downloading_state(int const st) { TORRENT_ASSERT(is_single_thread()); -#if !TORRENT_USE_IPV6 - if (!is_v4(adr)) - { -#ifndef TORRENT_DISABLE_LOGGING - error_code ec; - debug_log("add_peer() %s unsupported address family" - , adr.address().to_string(ec).c_str()); -#endif - return nullptr; - } -#endif - #ifndef TORRENT_DISABLE_DHT if (source != peer_info::resume_data) { diff --git a/src/torrent_peer.cpp b/src/torrent_peer.cpp index e206aa15b..5d0cc12fd 100644 --- a/src/torrent_peer.cpp +++ b/src/torrent_peer.cpp @@ -88,7 +88,6 @@ namespace libtorrent { detail::write_uint16(e2.port(), ptr); ret = crc32c_32(p); } -#if TORRENT_USE_IPV6 else if (is_v6(e1)) { static const std::uint8_t v6mask[][8] = { @@ -109,7 +108,6 @@ namespace libtorrent { memcpy(&addrbuf[2], b2.data(), 16); ret = crc32c(addrbuf, 4); } -#endif else { static const std::uint8_t v4mask[][4] = { @@ -158,9 +156,7 @@ namespace libtorrent { // retry with encryption , pe_support(false) #endif -#if TORRENT_USE_IPV6 , is_v6_addr(false) -#endif #if TORRENT_USE_I2P , is_i2p_addr(false) #endif @@ -228,9 +224,7 @@ namespace libtorrent { : torrent_peer(ep.port(), c, src) , addr(ep.address().to_v4()) { -#if TORRENT_USE_IPV6 is_v6_addr = false; -#endif #if TORRENT_USE_I2P is_i2p_addr = false; #endif @@ -245,14 +239,11 @@ namespace libtorrent { : torrent_peer(0, connectable, src) , destination(dest) { -#if TORRENT_USE_IPV6 is_v6_addr = false; -#endif is_i2p_addr = true; } #endif // TORRENT_USE_I2P -#if TORRENT_USE_IPV6 ipv6_peer::ipv6_peer(tcp::endpoint const& ep, bool c , peer_source_flags_t const src) : torrent_peer(ep.port(), c, src) @@ -266,8 +257,6 @@ namespace libtorrent { ipv6_peer::ipv6_peer(ipv6_peer const&) = default; -#endif // TORRENT_USE_IPV6 - #if TORRENT_USE_I2P string_view torrent_peer::dest() const { @@ -279,12 +268,10 @@ namespace libtorrent { libtorrent::address torrent_peer::address() const { -#if TORRENT_USE_IPV6 if (is_v6_addr) return libtorrent::address_v6( static_cast(this)->addr); else -#endif #if TORRENT_USE_I2P if (is_i2p_addr) return libtorrent::address(); else diff --git a/src/torrent_peer_allocator.cpp b/src/torrent_peer_allocator.cpp index 65216ebd9..5917a28e7 100644 --- a/src/torrent_peer_allocator.cpp +++ b/src/torrent_peer_allocator.cpp @@ -52,7 +52,6 @@ namespace libtorrent { ++m_live_allocations; ++m_total_allocations; break; -#if TORRENT_USE_IPV6 case torrent_peer_allocator_interface::ipv6_peer_type: p = static_cast(m_ipv6_peer_pool.malloc()); if (p == nullptr) return nullptr; @@ -62,7 +61,6 @@ namespace libtorrent { ++m_live_allocations; ++m_total_allocations; break; -#endif #if TORRENT_USE_I2P case torrent_peer_allocator_interface::i2p_peer_type: p = static_cast(m_i2p_peer_pool.malloc()); @@ -82,7 +80,6 @@ namespace libtorrent { { TORRENT_ASSERT(m_in_use); TORRENT_ASSERT(p->in_use); -#if TORRENT_USE_IPV6 if (p->is_v6_addr) { TORRENT_ASSERT(m_ipv6_peer_pool.is_from(static_cast(p))); @@ -94,7 +91,6 @@ namespace libtorrent { --m_live_allocations; return; } -#endif #if TORRENT_USE_I2P if (p->is_i2p_addr) { diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index be035f8e7..ee74b28dc 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -389,13 +389,11 @@ bool udp_socket::unwrap(udp::endpoint& from, span& buf) // IPv4 from = read_v4_endpoint(p); } -#if TORRENT_USE_IPV6 else if (atyp == 4) { // IPv6 from = read_v6_endpoint(p); } -#endif else { int const len = read_uint8(p); @@ -443,7 +441,6 @@ void udp_socket::open(udp const& protocol, error_code& ec) m_socket.open(protocol, ec); if (ec) return; -#if TORRENT_USE_IPV6 if (protocol == udp::v6()) { error_code err; @@ -454,7 +451,6 @@ void udp_socket::open(udp const& protocol, error_code& ec) m_socket.set_option(v6_protection_level(PROTECTION_LEVEL_UNRESTRICTED), err); #endif // TORRENT_WINDOWS } -#endif // this is best-effort. ignore errors #ifdef TORRENT_WINDOWS diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index 1ce470d58..d03281182 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -209,16 +209,12 @@ namespace libtorrent { // we're listening on. To make sure the tracker get our // correct listening address. bool is_v4 = bind_address.is_v4(); -#if TORRENT_USE_IPV6 auto scope = is_v4 ? 0 : bind_address.to_v6().scope_id(); -#endif for (auto const& addr : addresses) { if (addr.is_v4() != is_v4) continue; -#if TORRENT_USE_IPV6 if (addr.is_v6() && addr.to_v6().scope_id() != scope) continue; -#endif m_endpoints.emplace_back(addr, std::uint16_t(port)); } @@ -624,11 +620,7 @@ namespace libtorrent { resp.incomplete = aux::read_int32(buf); resp.complete = aux::read_int32(buf); - std::size_t const ip_stride = -#if TORRENT_USE_IPV6 - is_v6(m_target) ? 18 : -#endif - 6; + std::size_t const ip_stride = is_v6(m_target) ? 18 : 6; std::size_t const num_peers = buf.size() / ip_stride; if (buf.size() % ip_stride != 0) @@ -651,7 +643,6 @@ namespace libtorrent { return true; } -#if TORRENT_USE_IPV6 if (is_v6(m_target)) { resp.peers6.reserve(num_peers); @@ -665,7 +656,6 @@ namespace libtorrent { } } else -#endif { resp.peers4.reserve(num_peers); for (std::size_t i = 0; i < num_peers; ++i) diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 70559b3b0..9a081171b 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -113,14 +113,12 @@ namespace libtorrent { namespace { std::back_insert_iterator pla_out(pla); std::back_insert_iterator pld_out(pld); std::back_insert_iterator plf_out(plf); -#if TORRENT_USE_IPV6 std::string& pla6 = pex["added6"].string(); std::string& pld6 = pex["dropped6"].string(); std::string& plf6 = pex["added6.f"].string(); std::back_insert_iterator pla6_out(pla6); std::back_insert_iterator pld6_out(pld6); std::back_insert_iterator plf6_out(plf6); -#endif std::set dropped; m_old_peers.swap(dropped); @@ -179,13 +177,11 @@ namespace libtorrent { namespace { detail::write_endpoint(remote, pla_out); detail::write_uint8(static_cast(flags), plf_out); } -#if TORRENT_USE_IPV6 else { detail::write_endpoint(remote, pla6_out); detail::write_uint8(static_cast(flags), plf6_out); } -#endif ++num_added; ++m_peers_in_message; } @@ -201,10 +197,8 @@ namespace libtorrent { namespace { { if (is_v4(i)) detail::write_endpoint(i, pld_out); -#if TORRENT_USE_IPV6 else detail::write_endpoint(i, pld6_out); -#endif ++m_peers_in_message; } @@ -352,8 +346,6 @@ namespace libtorrent { namespace { } } -#if TORRENT_USE_IPV6 - bdecode_node p6 = pex_msg.dict_find("dropped6"); #ifndef TORRENT_DISABLE_LOGGING if (p6) num_dropped += p6.string_length() / 18; @@ -403,7 +395,6 @@ namespace libtorrent { namespace { peers_added = true; } } -#endif #ifndef TORRENT_DISABLE_LOGGING m_pc.peer_log(peer_log_alert::incoming_message, "PEX", "dropped: %d added: %d" , num_dropped, num_added); @@ -524,13 +515,11 @@ namespace libtorrent { namespace { std::back_insert_iterator pla_out(pla); std::back_insert_iterator plf_out(plf); -#if TORRENT_USE_IPV6 pex["dropped6"].string(); std::string& pla6 = pex["added6"].string(); std::string& plf6 = pex["added6.f"].string(); std::back_insert_iterator pla6_out(pla6); std::back_insert_iterator plf6_out(plf6); -#endif int num_added = 0; for (auto const peer : m_torrent) @@ -578,13 +567,11 @@ namespace libtorrent { namespace { detail::write_endpoint(remote, pla_out); detail::write_uint8(flags, plf_out); } -#if TORRENT_USE_IPV6 else { detail::write_endpoint(remote, pla6_out); detail::write_uint8(flags, plf6_out); } -#endif ++num_added; } std::vector pex_msg; diff --git a/src/write_resume_data.cpp b/src/write_resume_data.cpp index 59cc5c0e5..538329102 100644 --- a/src/write_resume_data.cpp +++ b/src/write_resume_data.cpp @@ -190,16 +190,12 @@ namespace libtorrent { if (!atp.peers.empty()) { std::back_insert_iterator ptr(ret["peers"].string()); -#if TORRENT_USE_IPV6 std::back_insert_iterator ptr6(ret["peers6"].string()); -#endif for (auto const& p : atp.peers) { -#if TORRENT_USE_IPV6 if (is_v6(p)) write_endpoint(p, ptr6); else -#endif write_endpoint(p, ptr); } } @@ -207,16 +203,12 @@ namespace libtorrent { if (!atp.banned_peers.empty()) { std::back_insert_iterator ptr(ret["banned_peers"].string()); -#if TORRENT_USE_IPV6 std::back_insert_iterator ptr6(ret["banned_peers6"].string()); -#endif for (auto const& p : atp.banned_peers) { -#if TORRENT_USE_IPV6 if (is_v6(p)) write_endpoint(p, ptr6); else -#endif write_endpoint(p, ptr); } } diff --git a/test/bittorrent_peer.cpp b/test/bittorrent_peer.cpp index d6581fa93..cd44df386 100644 --- a/test/bittorrent_peer.cpp +++ b/test/bittorrent_peer.cpp @@ -272,12 +272,10 @@ void peer_conn::close(char const* fmt, error_code const& ec) char ep_str[200]; address const& addr = s.local_endpoint(e).address(); -#if TORRENT_USE_IPV6 if (addr.is_v6()) std::snprintf(ep_str, sizeof(ep_str), "[%s]:%d", addr.to_string(e).c_str() , s.local_endpoint(e).port()); else -#endif std::snprintf(ep_str, sizeof(ep_str), "%s:%d", addr.to_string(e).c_str() , s.local_endpoint(e).port()); std::printf("%s ep: %s sent: %d received: %d duration: %d ms up: %.1fMB/s down: %.1fMB/s\n" diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 6b9a6c389..f020a6918 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -126,7 +126,6 @@ sha1_hash to_hash(char const* s) return ret; } -#if TORRENT_USE_IPV6 address rand_v6() { address_v6::bytes_type bytes; @@ -134,7 +133,6 @@ address rand_v6() bytes[static_cast(i)] = std::uint8_t(lt::random(0xff)); return address_v6(bytes); } -#endif static std::uint16_t g_port = 0; @@ -1025,7 +1023,6 @@ lt::address_v4 addr4(char const* ip) return ret; } -#if TORRENT_USE_IPV6 lt::address_v6 addr6(char const* ip) { lt::error_code ec; @@ -1033,4 +1030,3 @@ lt::address_v6 addr6(char const* ip) TEST_CHECK(!ec); return ret; } -#endif diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index ed637a888..f7a95b8b7 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -52,9 +52,7 @@ EXPORT void report_failure(char const* err, char const* file, int line); EXPORT void init_rand_address(); EXPORT lt::address rand_v4(); -#if TORRENT_USE_IPV6 EXPORT lt::address rand_v6(); -#endif EXPORT lt::tcp::endpoint rand_tcp_ep(lt::address(&rand_addr)() = rand_v4); EXPORT lt::udp::endpoint rand_udp_ep(lt::address(&rand_addr)() = rand_v4); @@ -121,8 +119,6 @@ EXPORT lt::tcp::endpoint ep(char const* ip, int port); EXPORT lt::udp::endpoint uep(char const* ip, int port); EXPORT lt::address addr(char const* ip); EXPORT lt::address_v4 addr4(char const* ip); -#if TORRENT_USE_IPV6 EXPORT lt::address_v6 addr6(char const* ip); -#endif #endif diff --git a/test/test_alert_types.cpp b/test/test_alert_types.cpp index 782517784..9d2c2db4a 100644 --- a/test/test_alert_types.cpp +++ b/test/test_alert_types.cpp @@ -194,13 +194,8 @@ TORRENT_TEST(dht_get_peers_reply_alert) tcp::endpoint const ep1 = rand_tcp_ep(rand_v4); tcp::endpoint const ep2 = rand_tcp_ep(rand_v4); tcp::endpoint const ep3 = rand_tcp_ep(rand_v4); -#if TORRENT_USE_IPV6 tcp::endpoint const ep4 = rand_tcp_ep(rand_v6); tcp::endpoint const ep5 = rand_tcp_ep(rand_v6); -#else - tcp::endpoint const ep4 = rand_tcp_ep(rand_v4); - tcp::endpoint const ep5 = rand_tcp_ep(rand_v4); -#endif std::vector v = {ep1, ep2, ep3, ep4, ep5}; mgr.emplace_alert(ih, v); @@ -232,13 +227,8 @@ TORRENT_TEST(dht_live_nodes_alert) udp::endpoint const ep1 = rand_udp_ep(rand_v4); udp::endpoint const ep2 = rand_udp_ep(rand_v4); udp::endpoint const ep3 = rand_udp_ep(rand_v4); -#if TORRENT_USE_IPV6 udp::endpoint const ep4 = rand_udp_ep(rand_v6); udp::endpoint const ep5 = rand_udp_ep(rand_v6); -#else - udp::endpoint const ep4 = rand_udp_ep(rand_v4); - udp::endpoint const ep5 = rand_udp_ep(rand_v4); -#endif std::vector> v; v.emplace_back(h1, ep1); v.emplace_back(h2, ep2); @@ -306,13 +296,8 @@ TORRENT_TEST(dht_sample_infohashes_alert) udp::endpoint const nep1 = rand_udp_ep(rand_v4); udp::endpoint const nep2 = rand_udp_ep(rand_v4); udp::endpoint const nep3 = rand_udp_ep(rand_v4); -#if TORRENT_USE_IPV6 udp::endpoint const nep4 = rand_udp_ep(rand_v6); udp::endpoint const nep5 = rand_udp_ep(rand_v6); -#else - udp::endpoint const nep4 = rand_udp_ep(rand_v4); - udp::endpoint const nep5 = rand_udp_ep(rand_v4); -#endif std::vector> nv; nv.emplace_back(nh1, nep1); nv.emplace_back(nh2, nep2); diff --git a/test/test_dht.cpp b/test/test_dht.cpp index e171914e3..5f87970c2 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -143,7 +143,6 @@ std::shared_ptr dummy_listen_socket4() return ret; } -#if TORRENT_USE_IPV6 std::shared_ptr dummy_listen_socket6() { auto ret = std::make_shared(); @@ -152,7 +151,6 @@ std::shared_ptr dummy_listen_socket6() , aux::session_interface::source_dht, rand_v6()); return ret; } -#endif node* get_foreign_node_stub(node_id const&, std::string const&) { @@ -1038,13 +1036,11 @@ TORRENT_TEST(scrape_v4) test_scrape(rand_v4); } -#if TORRENT_USE_IPV6 TORRENT_TEST(scrape_v6) { if (supports_ipv6()) test_scrape(rand_v6); } -#endif namespace { @@ -1148,13 +1144,11 @@ TORRENT_TEST(id_enforcement_v4) test_id_enforcement(rand_v4); } -#if TORRENT_USE_IPV6 TORRENT_TEST(id_enforcement_v6) { if (supports_ipv6()) test_id_enforcement(rand_v6); } -#endif TORRENT_TEST(bloom_filter) { @@ -1578,13 +1572,11 @@ TORRENT_TEST(put_v4) test_put(rand_v4); } -#if TORRENT_USE_IPV6 TORRENT_TEST(put_v6) { if (supports_ipv6()) test_put(rand_v6); } -#endif namespace { @@ -1608,14 +1600,12 @@ void test_routing_table(address(&rand_addr)()) address node_addr; address node_near_addr; -#if TORRENT_USE_IPV6 if (is_v6(t.source)) { node_addr = addr6("2001:1111:1111:1111:1111:1111:1111:1111"); node_near_addr = addr6("2001:1111:1111:1111:eeee:eeee:eeee:eeee"); } else -#endif { node_addr = addr4("4.4.4.4"); node_near_addr = addr4("4.4.4.5"); @@ -1802,13 +1792,11 @@ TORRENT_TEST(routing_table_v4) test_routing_table(rand_v4); } -#if TORRENT_USE_IPV6 TORRENT_TEST(routing_table_v6) { if (supports_ipv6()) test_routing_table(rand_v6); } -#endif namespace { @@ -1907,15 +1895,12 @@ TORRENT_TEST(bootstrap_v4) test_bootstrap(rand_v4); } -#if TORRENT_USE_IPV6 TORRENT_TEST(bootstrap_v6) { if (supports_ipv6()) test_bootstrap(rand_v6); } -#endif -#if TORRENT_USE_IPV6 namespace { void test_bootstrap_want(address(&rand_addr)()) @@ -1986,7 +1971,6 @@ TORRENT_TEST(bootstrap_want_v6) { test_bootstrap_want(rand_v6); } -#endif namespace { @@ -2070,13 +2054,11 @@ TORRENT_TEST(short_nodes_v4) test_short_nodes(rand_v4); } -#if TORRENT_USE_IPV6 TORRENT_TEST(short_nodes_v6) { if (supports_ipv6()) test_short_nodes(rand_v6); } -#endif namespace { @@ -2208,13 +2190,11 @@ TORRENT_TEST(get_peers_v4) test_get_peers(rand_v4); } -#if TORRENT_USE_IPV6 TORRENT_TEST(get_peers_v6) { if (supports_ipv6()) test_get_peers(rand_v6); } -#endif namespace { @@ -2316,7 +2296,6 @@ TORRENT_TEST(mutable_get_salt_v4) test_mutable_get(rand_v4, true); } -#if TORRENT_USE_IPV6 TORRENT_TEST(mutable_get_v6) { if (supports_ipv6()) @@ -2328,7 +2307,6 @@ TORRENT_TEST(mutable_get_salt_v6) if (supports_ipv6()) test_mutable_get(rand_v6, true); } -#endif TORRENT_TEST(immutable_get) { @@ -2681,7 +2659,6 @@ TORRENT_TEST(traversal_done) g_put_count = 0; } -#if TORRENT_USE_IPV6 TORRENT_TEST(dht_dual_stack) { // TODO: 3 use dht_test_setup class to simplify the node setup @@ -2820,7 +2797,6 @@ TORRENT_TEST(dht_dual_stack) TEST_ERROR(error_string); } } -#endif TORRENT_TEST(multi_home) { @@ -3657,7 +3633,6 @@ TORRENT_TEST(compare_ip_cidr) addr4(std::get<0>(t)), addr4(std::get<1>(t))), std::get<2>(t)); } -#if TORRENT_USE_IPV6 std::vector const v6tests = { tst{"::1", "::ffff:ffff:ffff:ffff", true}, tst{"::2:0000:0000:0000:0000", "::1:ffff:ffff:ffff:ffff", false}, @@ -3676,7 +3651,6 @@ TORRENT_TEST(compare_ip_cidr) TEST_EQUAL(compare_ip_cidr( addr6(std::get<0>(t)), addr6(std::get<1>(t))), std::get<2>(t)); } -#endif } TORRENT_TEST(dht_state) diff --git a/test/test_dht_storage.cpp b/test/test_dht_storage.cpp index a7c71a9c0..f5481f203 100644 --- a/test/test_dht_storage.cpp +++ b/test/test_dht_storage.cpp @@ -123,7 +123,6 @@ TORRENT_TEST(announce_peer) TEST_CHECK(!peers.find_key("values")); } -#if TORRENT_USE_IPV6 TORRENT_TEST(dual_stack) { dht::dht_settings sett = test_settings(); @@ -149,7 +148,6 @@ TORRENT_TEST(dual_stack) s->get_peers(n1, false, false, address_v6(), peers6); TEST_EQUAL(peers6["values"].list().size(), 2); } -#endif TORRENT_TEST(put_items) { diff --git a/test/test_enum_net.cpp b/test/test_enum_net.cpp index b91f2209c..e2989fbff 100644 --- a/test/test_enum_net.cpp +++ b/test/test_enum_net.cpp @@ -54,13 +54,11 @@ TORRENT_TEST(is_loopback) error_code ec; TEST_CHECK(is_loopback(address::from_string("127.0.0.1", ec))); TEST_CHECK(!ec); -#if TORRENT_USE_IPV6 if (supports_ipv6()) { TEST_CHECK(is_loopback(address::from_string("::1", ec))); TEST_CHECK(!ec); } -#endif } TORRENT_TEST(is_any) @@ -69,13 +67,11 @@ TORRENT_TEST(is_any) error_code ec; TEST_CHECK(!is_any(address::from_string("31.53.21.64", ec))); TEST_CHECK(!ec); -#if TORRENT_USE_IPV6 if (supports_ipv6()) { TEST_CHECK(is_any(address_v6::any())); TEST_CHECK(!ec); } -#endif } TORRENT_TEST(match_addr_mask) @@ -105,8 +101,6 @@ TORRENT_TEST(is_ip_address) TEST_EQUAL(is_ip_address("1.2.3.4"), true); TEST_EQUAL(is_ip_address("a.b.c.d"), false); TEST_EQUAL(is_ip_address("a:b:b:c"), false); -#if TORRENT_USE_IPV6 TEST_EQUAL(is_ip_address("::1"), true); TEST_EQUAL(is_ip_address("2001:db8:85a3:0:0:8a2e:370:7334"), true); -#endif } diff --git a/test/test_ip_filter.cpp b/test/test_ip_filter.cpp index 815c6c94d..6801a9bd9 100644 --- a/test/test_ip_filter.cpp +++ b/test/test_ip_filter.cpp @@ -90,11 +90,7 @@ TORRENT_TEST(session_get_ip_filter) { session ses(settings()); ip_filter const& ipf = ses.get_ip_filter(); -#if TORRENT_USE_IPV6 TEST_EQUAL(std::get<0>(ipf.export_filter()).size(), 1); -#else - TEST_EQUAL(ipf.export_filter().size(), 1); -#endif } TORRENT_TEST(ip_filter) @@ -115,11 +111,7 @@ TORRENT_TEST(ip_filter) f.add_rule(addr("1.0.0.0"), addr("2.0.0.0"), ip_filter::blocked); f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked); -#if TORRENT_USE_IPV6 range = std::get<0>(f.export_filter()); -#else - range = f.export_filter(); -#endif test_rules_invariant(range, f); TEST_CHECK(range.size() == 3); @@ -134,11 +126,7 @@ TORRENT_TEST(ip_filter) f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked); f.add_rule(addr("1.0.0.0"), addr("2.0.0.0"), ip_filter::blocked); -#if TORRENT_USE_IPV6 range = std::get<0>(f.export_filter()); -#else - range = f.export_filter(); -#endif test_rules_invariant(range, f); TEST_CHECK(range.size() == 3); @@ -154,11 +142,7 @@ TORRENT_TEST(ip_filter) f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked); f.add_rule(addr("1.0.0.0"), addr("2.4.0.0"), ip_filter::blocked); -#if TORRENT_USE_IPV6 range = std::get<0>(f.export_filter()); -#else - range = f.export_filter(); -#endif test_rules_invariant(range, f); TEST_CHECK(range.size() == 3); @@ -174,11 +158,7 @@ TORRENT_TEST(ip_filter) f.add_rule(addr("1.0.0.0"), addr("2.4.0.0"), ip_filter::blocked); f.add_rule(addr("2.0.0.1"), addr("3.0.0.0"), ip_filter::blocked); -#if TORRENT_USE_IPV6 range = std::get<0>(f.export_filter()); -#else - range = f.export_filter(); -#endif test_rules_invariant(range, f); TEST_CHECK(range.size() == 3); @@ -198,11 +178,7 @@ TORRENT_TEST(ip_filter) f.add_rule(addr("1.0.1.0"), addr("9.0.0.0"), ip_filter::blocked); -#if TORRENT_USE_IPV6 range = std::get<0>(f.export_filter()); -#else - range = f.export_filter(); -#endif test_rules_invariant(range, f); TEST_CHECK(range.size() == 3); @@ -228,11 +204,7 @@ TORRENT_TEST(ip_filter) f.add_rule(addr("0.0.1.0"), addr("7.0.4.0"), ip_filter::blocked); -#if TORRENT_USE_IPV6 range = std::get<0>(f.export_filter()); -#else - range = f.export_filter(); -#endif test_rules_invariant(range, f); TEST_CHECK(range.size() == 3); @@ -249,8 +221,6 @@ TORRENT_TEST(ip_filter) // **** test IPv6 **** -#if TORRENT_USE_IPV6 - ip_range expected2[] = { {addr6("::0"), addr6("0:ffff:ffff:ffff:ffff:ffff:ffff:ffff"), 0} @@ -270,7 +240,6 @@ TORRENT_TEST(ip_filter) TEST_EQUAL(rangev6.size(), 3); TEST_CHECK(std::equal(rangev6.begin(), rangev6.end(), expected2, &compare)); } -#endif port_filter pf; diff --git a/test/test_ip_voter.cpp b/test/test_ip_voter.cpp index 4f22154ea..a18334fb1 100644 --- a/test/test_ip_voter.cpp +++ b/test/test_ip_voter.cpp @@ -195,7 +195,6 @@ TORRENT_TEST(ip_voter_2) address malicious2; address real_external2; address malicious_external2; -#if TORRENT_USE_IPV6 if (supports_ipv6()) { malicious2 = address_v6::from_string("2f90::", ec); @@ -205,25 +204,19 @@ TORRENT_TEST(ip_voter_2) malicious_external2 = address_v6::from_string("2f70::", ec); TEST_CHECK(!ec); } -#endif for (int i = 0; i < 50; ++i) { ipv2.cast_vote(real_external1, aux::session_interface::source_dht, rand_v4()); ipv2.cast_vote(malicious_external, aux::session_interface::source_dht, malicious); -#if TORRENT_USE_IPV6 if (supports_ipv6()) { ipv6.cast_vote(real_external2, aux::session_interface::source_dht, rand_v6()); ipv6.cast_vote(malicious_external2, aux::session_interface::source_dht, malicious2); } -#endif } TEST_CHECK(ipv2.external_address() == real_external1); -#if TORRENT_USE_IPV6 if (supports_ipv6()) TEST_CHECK(ipv6.external_address() == real_external2); -#endif - } diff --git a/test/test_magnet.cpp b/test/test_magnet.cpp index 6945a6bf9..a407725cc 100644 --- a/test/test_magnet.cpp +++ b/test/test_magnet.cpp @@ -307,14 +307,9 @@ TORRENT_TEST(parse_peer) { add_torrent_params p = parse_magnet_uri("magnet:?xt=urn:btih:cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" "&dn=foo&x.pe=127.0.0.1:43&x.pe=&x.pe=:100&x.pe=[::1]:45"); -#if TORRENT_USE_IPV6 TEST_EQUAL(p.peers.size(), 2); TEST_EQUAL(p.peers[0], ep("127.0.0.1", 43)); TEST_EQUAL(p.peers[1], ep("::1", 45)); -#else - TEST_EQUAL(p.peers.size(), 1); - TEST_EQUAL(p.peers[0], ep("127.0.0.1", 43)); -#endif } #ifndef TORRENT_DISABLE_DHT diff --git a/test/test_peer_classes.cpp b/test/test_peer_classes.cpp index 90477705d..f2ae517ba 100644 --- a/test/test_peer_classes.cpp +++ b/test/test_peer_classes.cpp @@ -131,12 +131,8 @@ TORRENT_TEST(session_peer_class_filter) , 1 << static_cast(my_class)); ses.set_peer_class_filter(f); -#if TORRENT_USE_IPV6 TEST_CHECK(std::get<0>(ses.get_peer_class_filter().export_filter()) == std::get<0>(f.export_filter())); -#else - TEST_CHECK(ses.get_peer_class_filter().export_filter() == f.export_filter()); -#endif } TORRENT_TEST(session_peer_class_type_filter) diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index f645599ea..6c0c6636c 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -122,10 +122,8 @@ TORRENT_TEST(address_endpoint_io) TEST_EQUAL(print_endpoint(ep("127.0.0.1", 23)), "127.0.0.1:23"); TEST_EQUAL(print_address(addr4("241.124.23.5")), "241.124.23.5"); -#if TORRENT_USE_IPV6 TEST_EQUAL(print_endpoint(ep("ff::1", 1214)), "[ff::1]:1214"); TEST_EQUAL(print_address(addr6("2001:ff::1")), "2001:ff::1"); -#endif // test address_to_bytes TEST_EQUAL(address_to_bytes(addr4("10.11.12.13")), "\x0a\x0b\x0c\x0d"); diff --git a/test/test_session_params.cpp b/test/test_session_params.cpp index ce231eeb0..6c00d9f32 100644 --- a/test/test_session_params.cpp +++ b/test/test_session_params.cpp @@ -113,10 +113,8 @@ TORRENT_TEST(dht_state) s.nids.emplace_back(addr4("0.0.0.0"), to_hash("0000000000000000000000000000000000000001")); s.nodes.push_back(uep("1.1.1.1", 1)); s.nodes.push_back(uep("2.2.2.2", 2)); -#if TORRENT_USE_IPV6 // not important that IPv6 is disabled here s.nids.emplace_back(addr6("::"), to_hash("0000000000000000000000000000000000000002")); -#endif session_params params(p); params.dht_settings = sett; @@ -141,11 +139,9 @@ TORRENT_TEST(dht_state) // not a chance the nid will be the fake initial ones TEST_CHECK(params1.dht_state.nids[0].second != s.nids[0].second); -#if TORRENT_USE_IPV6 // the host machine may not have IPv6 support in which case there will only be one entry if (params1.dht_state.nids.size() > 1) TEST_CHECK(params1.dht_state.nids[1].second != s.nids[1].second); -#endif } #endif diff --git a/test/test_socket_io.cpp b/test/test_socket_io.cpp index aac0b747b..0e5e9763e 100644 --- a/test/test_socket_io.cpp +++ b/test/test_socket_io.cpp @@ -67,7 +67,6 @@ TORRENT_TEST(read_v4_address) TEST_EQUAL(ep4, uep("16.5.128.1", 1337)); } -#if TORRENT_USE_IPV6 TORRENT_TEST(read_v6_endpoint) { std::string buf; @@ -85,7 +84,6 @@ TORRENT_TEST(read_v6_endpoint) udp::endpoint ep6 = read_v6_endpoint(buf.begin()); TEST_EQUAL(ep6, uep("1000::ffff", 1337)); } -#endif TORRENT_TEST(read_endpoint_list) { @@ -97,12 +95,8 @@ TORRENT_TEST(read_endpoint_list) TEST_CHECK(!ec); std::vector list = read_endpoint_list(e); -#if TORRENT_USE_IPV6 TEST_EQUAL(list.size(), 2); TEST_EQUAL(list[1], uep("1000::ffff", 1337)); -#else - TEST_EQUAL(list.size(), 1); -#endif TEST_EQUAL(list[0], uep("16.5.128.1", 1337)); } @@ -171,7 +165,6 @@ TORRENT_TEST(parse_valid_ip4_endpoint) ec.clear(); } -#if TORRENT_USE_IPV6 TORRENT_TEST(parse_invalid_ipv6_endpoint) { error_code ec; @@ -221,5 +214,4 @@ TORRENT_TEST(parse_valid_ipv6_endpoint) TEST_CHECK(!ec); ec.clear(); } -#endif diff --git a/test/test_string.cpp b/test/test_string.cpp index 73fc47d00..ab820138d 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -388,26 +388,15 @@ TORRENT_TEST(parse_list) TEST_EQUAL(list[5], "foobar"); TEST_EQUAL(list[6], "[::1]"); -#if TORRENT_USE_IPV6 test_parse_interface(" a:4,b:35, c : 1000s, d: 351 ,e \t:42,foobar:1337s\n\r,[2001::1]:6881" , {{"a", 4, false}, {"b", 35, false}, {"c", 1000, true}, {"d", 351, false} , {"e", 42, false}, {"foobar", 1337, true}, {"2001::1", 6881, false}} , "a:4,b:35,c:1000s,d:351,e:42,foobar:1337s,[2001::1]:6881"); -#else - test_parse_interface(" a:4,b:35, c : 1000s, d: 351 ,e \t:42,foobar:1337s\n\r,[2001::1]:6881" - , {{"a", 4, false}, {"b", 35, false}, {"c", 1000, true}, {"d", 351, false} - , {"e", 42, false}, {"foobar", 1337, true}} - , "a:4,b:35,c:1000s,d:351,e:42,foobar:1337s"); -#endif // IPv6 address -#if TORRENT_USE_IPV6 test_parse_interface("[2001:ffff::1]:6882s" , {{"2001:ffff::1", 6882, true}} , "[2001:ffff::1]:6882s"); -#else - test_parse_interface("[2001:ffff::1]:6882s", {}, ""); -#endif // IPv4 address test_parse_interface("127.0.0.1:6882" diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index 04ecddf19..0e8004b63 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -252,7 +252,6 @@ TORRENT_TEST(parse_external_ip) TEST_EQUAL(resp.external_ip, addr4("1.2.3.4")); } -#if TORRENT_USE_IPV6 TORRENT_TEST(parse_external_ip6) { char const response[] = "d5:peers0:11:external ip" @@ -265,7 +264,6 @@ TORRENT_TEST(parse_external_ip6) TEST_EQUAL(resp.peers.size(), 0); TEST_EQUAL(resp.external_ip, addr6("f102:0304::ffff")); } -#endif namespace { peer_entry extract_peer(char const* peer_field, error_code expected_ec, bool expected_ret) @@ -416,7 +414,6 @@ TORRENT_TEST(udp_tracker_v4) test_udp_tracker("127.0.0.1", address_v4::any(), ep("1.3.3.7", 1337)); } -#if TORRENT_USE_IPV6 TORRENT_TEST(udp_tracker_v6) { if (supports_ipv6()) @@ -424,7 +421,6 @@ TORRENT_TEST(udp_tracker_v6) test_udp_tracker("[::1]", address_v6::any(), ep("::1.3.3.7", 1337)); } } -#endif TORRENT_TEST(http_peers) { @@ -483,9 +479,7 @@ TORRENT_TEST(http_peers) std::set expected_peers; expected_peers.insert(ep("65.65.65.65", 16962)); expected_peers.insert(ep("67.67.67.67", 17476)); -#if TORRENT_USE_IPV6 expected_peers.insert(ep("4545:4545:4545:4545:4545:4545:4545:4545", 17990)); -#endif for (auto const& ip : ra->params.peers) { TEST_EQUAL(expected_peers.count(ip), 1); diff --git a/test/udp_tracker.cpp b/test/udp_tracker.cpp index 517cabbbb..e0a1d11c6 100644 --- a/test/udp_tracker.cpp +++ b/test/udp_tracker.cpp @@ -133,7 +133,6 @@ struct udp_tracker detail::write_uint32(1, ptr); // incomplete detail::write_uint32(1, ptr); // complete // 1 peers -#if TORRENT_USE_IPV6 if (is_v6(*from)) { detail::write_uint32(0, ptr); @@ -146,7 +145,6 @@ struct udp_tracker detail::write_uint16(1337, ptr); } else -#endif { detail::write_uint8(1, ptr); detail::write_uint8(3, ptr); diff --git a/tools/gen_fwd.py b/tools/gen_fwd.py index 2fa7372b6..942967f60 100644 --- a/tools/gen_fwd.py +++ b/tools/gen_fwd.py @@ -67,8 +67,8 @@ def print_classes(out, classes, keyword): # also ignore any header in the aux_ directory, those are private classes = [l for l in classes if l[0].endswith('.hpp') and not l[0].endswith('/fwd.hpp') and '/aux_/' not in l[0]] - namespaces = ['TORRENT_VERSION_NAMESPACE_2', 'TORRENT_IPV6_NAMESPACE', - 'TORRENT_VERSION_NAMESPACE_2_END', 'TORRENT_IPV6_NAMESPACE_END'] + namespaces = ['TORRENT_VERSION_NAMESPACE_2', + 'TORRENT_VERSION_NAMESPACE_2_END'] # only include classes with the right kind of export classes = [