From d2f72f50cc6e63c0906fc4553dcc2a2b3ca2c42c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 19 Nov 2012 04:58:46 +0000 Subject: [PATCH] merged IPV6_V6ONLY fix from RC_0_16 --- include/libtorrent/socket.hpp | 2 ++ src/session_impl.cpp | 2 ++ src/udp_socket.cpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index 1a5d28e1e..f1952a0d3 100644 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -98,6 +98,7 @@ namespace libtorrent #endif #if TORRENT_USE_IPV6 +#ifdef IPV6_V6ONLY struct v6only { v6only(bool enable): m_value(enable) {} @@ -112,6 +113,7 @@ namespace libtorrent int m_value; }; #endif +#endif #ifdef TORRENT_WINDOWS diff --git a/src/session_impl.cpp b/src/session_impl.cpp index a9a9ee927..dc2a5efe1 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2133,7 +2133,9 @@ namespace aux { if (ep.protocol() == tcp::v6()) { error_code err; // ignore errors here +#ifdef IPV6_V6ONLY s->sock->set_option(v6only(v6_only), err); +#endif #ifdef TORRENT_WINDOWS #ifndef PROTECTION_LEVEL_UNRESTRICTED diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index a481173c8..ee71173a6 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -683,8 +683,10 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec) #if TORRENT_USE_IPV6 else { +#ifdef IPV6_V6ONLY m_ipv6_sock.set_option(v6only(true), ec); if (ec) return; +#endif m_ipv6_sock.bind(ep, ec); if (ec) return; udp::socket::non_blocking_io ioc(true); @@ -726,7 +728,9 @@ void udp_socket::bind(int port) m_ipv6_sock.open(udp::v6(), ec); if (!ec) { +#ifdef IPV6_V6ONLY m_ipv6_sock.set_option(v6only(true), ec); +#endif m_ipv6_sock.bind(udp::endpoint(address_v6::any(), port), ec); setup_read(&m_ipv6_sock);