Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git c/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/lsd.hpp w/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/lsd.hpp
- index 2e10a35..57f010b 100644
- --- c/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/lsd.hpp
- +++ w/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/lsd.hpp
- @@ -76,6 +76,9 @@ 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
- // used to resend udp packets in case
- // they time out
- @@ -92,6 +95,9 @@ private:
- int m_cookie;
- bool m_disabled;
- +#if TORRENT_USE_IPV6
- + bool m_disabled6;
- +#endif
- #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
- FILE* m_log;
- #endif
- diff --git c/0.16.16/src/libtorrent-rasterbar-0.16.16/src/broadcast_socket.cpp w/0.16.16/src/libtorrent-rasterbar-0.16.16/src/broadcast_socket.cpp
- index 7902ebd..9710f1e 100644
- --- c/0.16.16/src/libtorrent-rasterbar-0.16.16/src/broadcast_socket.cpp
- +++ w/0.16.16/src/libtorrent-rasterbar-0.16.16/src/broadcast_socket.cpp
- @@ -204,7 +204,7 @@ namespace libtorrent
- - common_bits(b1.data(), b2.data(), b1.size());
- #if TORRENT_USE_IPV6
- }
- -
- +
- address_v6::bytes_type b1;
- address_v6::bytes_type b2;
- if (a1.is_v4()) b1 = address_v6::v4_mapped(a1.to_v4()).to_bytes();
- @@ -239,7 +239,7 @@ namespace libtorrent
- else
- #endif
- open_multicast_socket(ios, address_v4::any(), loopback, ec);
- -
- +
- for (std::vector<ip_interface>::const_iterator i = interfaces.begin()
- , end(interfaces.end()); i != end; ++i)
- {
- @@ -249,6 +249,19 @@ namespace libtorrent
- if (!loopback && is_loopback(i->interface_address)) continue;
- ec = error_code();
- +#if TORRENT_USE_IPV6
- + if (i->interface_address.is_v6() &&
- + i->interface_address.to_v6().is_link_local()) {
- + address_v6 addr6 = i->interface_address.to_v6();
- + addr6.scope_id(if_nametoindex(i->name));
- + open_multicast_socket(ios, addr6, loopback, ec);
- +
- + address_v4 const& mask = i->netmask.is_v4() ?
- + i->netmask.to_v4() : address_v4();
- + open_unicast_socket(ios, addr6, mask);
- + continue;
- + }
- +#endif
- open_multicast_socket(ios, i->interface_address, loopback, ec);
- #ifdef TORRENT_DEBUG
- // fprintf(stderr, "broadcast socket [ if: %s group: %s mask: %s ] %s\n"
- diff --git c/0.16.16/src/libtorrent-rasterbar-0.16.16/src/lsd.cpp w/0.16.16/src/libtorrent-rasterbar-0.16.16/src/lsd.cpp
- index d78dd2e..547f21c 100644
- --- c/0.16.16/src/libtorrent-rasterbar-0.16.16/src/lsd.cpp
- +++ w/0.16.16/src/libtorrent-rasterbar-0.16.16/src/lsd.cpp
- @@ -72,10 +72,15 @@ lsd::lsd(io_service& ios, address const& listen_interface
- : m_callback(cb)
- , m_socket(udp::endpoint(address_v4::from_string("239.192.152.143", ec), 6771)
- , boost::bind(&lsd::on_announce, self(), _1, _2, _3))
- +#if TORRENT_USE_IPV6
- + , m_socket6(udp::endpoint(address_v6::from_string("ff15::efc0:988f", ec), 6771)
- + , boost::bind(&lsd::on_announce, self(), _1, _2, _3))
- +#endif
- , m_broadcast_timer(ios)
- , m_retry_count(1)
- , m_cookie(random())
- , m_disabled(false)
- + , m_disabled6(false)
- {
- #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
- m_log = fopen("lsd.log", "w+");
- @@ -96,6 +101,19 @@ lsd::lsd(io_service& ios, address const& listen_interface
- , ec.value(), ec.message().c_str());
- }
- #endif
- +
- +#if TORRENT_USE_IPV6
- + m_socket6.open(ios, ec);
- +#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
- + if (ec)
- + {
- + if (m_log) fprintf(m_log, "FAILED TO OPEN SOCKET6: (%d) %s\n"
- + , ec.value(), ec.message().c_str());
- + }
- +#endif
- +#endif
- +
- +
- }
- lsd::~lsd()
- @@ -107,14 +125,19 @@ lsd::~lsd()
- void lsd::announce(sha1_hash const& ih, int listen_port, bool broadcast)
- {
- - if (m_disabled) return;
- +#if TORRENT_USE_IPV6
- + if (m_disabled && m_disabled6)
- +#else
- + if (m_disabled)
- +#endif
- + return;
- char ih_hex[41];
- to_hex((char const*)&ih[0], 20, ih_hex);
- char msg[200];
- int msg_len = snprintf(msg, sizeof(msg),
- "BT-SEARCH * HTTP/1.1\r\n"
- - "Host: 239.192.152.143:6771\r\n"
- + "Host: [ff15::efc0:988f]:6771\r\n"
- "Port: %d\r\n"
- "Infohash: %s\r\n"
- "cookie: %x\r\n"
- @@ -140,9 +163,31 @@ void lsd::announce(sha1_hash const& ih, int listen_port, bool broadcast)
- }
- #endif
- - return;
- }
- +#if TORRENT_USE_IPV6
- + m_socket6.send(msg, msg_len, ec, broadcast ? broadcast_socket::broadcast : 0);
- + if (ec)
- + {
- + m_disabled6 = true;
- +#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
- + {
- + if (m_log) fprintf(m_log, "%s failed to send message6: (%d) %s"
- + , time_now_string(), ec.value(), ec.message().c_str());
- + }
- +#endif
- +
- + }
- +#endif
- +
- +
- +#if TORRENT_USE_IPV6
- + if (m_disabled && m_disabled6)
- +#else
- + if (m_disabled)
- +#endif
- + return;
- +
- #if defined TORRENT_ASIO_DEBUGGING
- add_outstanding_async("lsd::resend_announce");
- #endif
- @@ -160,6 +205,9 @@ void lsd::resend_announce(error_code const& e, std::string msg)
- error_code ec;
- m_socket.send(msg.c_str(), int(msg.size()), ec);
- +#if TORRENT_USE_IPV6
- + m_socket6.send(msg.c_str(), int(msg.size()), ec);
- +#endif
- ++m_retry_count;
- if (m_retry_count >= 3) return;
- @@ -266,9 +314,15 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
- 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
- m_callback.clear();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement