From afd556796974a0b366aaa05604ed39e3872fe62d Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 21 Aug 2010 22:07:29 +0000 Subject: [PATCH] session::set_tracker_proxy fix for udp trackers --- include/libtorrent/aux_/session_impl.hpp | 5 ++++- src/udp_socket.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 9b33b999b..195a4b3e4 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -315,7 +315,10 @@ namespace libtorrent void set_web_seed_proxy(proxy_settings const& s) { m_web_seed_proxy = s; } void set_tracker_proxy(proxy_settings const& s) - { m_tracker_proxy = s; } + { + m_udp_socket.set_proxy_settings(s); + m_tracker_proxy = s; + } proxy_settings const& peer_proxy() const { return m_peer_proxy; } diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index d9932ba0d..a86c7346d 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -113,6 +113,7 @@ void udp_socket::send_hostname(char const* hostname, int port return; } + // this function is only supported when we're using a proxy TORRENT_ASSERT(m_queue_packets); if (!m_queue_packets) return; @@ -614,6 +615,7 @@ void udp_socket::on_connected(error_code const& e) write_uint8(0, p); // no authentication write_uint8(2, p); // username/password } + TORRENT_ASSERT(p - m_tmp_buf < sizeof(m_tmp_buf)); asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf) , boost::bind(&udp_socket::handshake1, this, _1)); } @@ -664,6 +666,7 @@ void udp_socket::handshake2(error_code const& e) write_string(m_proxy_settings.username, p); write_uint8(m_proxy_settings.password.size(), p); write_string(m_proxy_settings.password, p); + TORRENT_ASSERT(p - m_tmp_buf < sizeof(m_tmp_buf)); asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf) , boost::bind(&udp_socket::handshake3, this, _1)); } @@ -729,7 +732,7 @@ void udp_socket::socks_forward_udp(mutex::scoped_lock& l) port = m_ipv6_sock.local_endpoint(ec).port(); #endif detail::write_uint16(port , p); - + TORRENT_ASSERT(p - m_tmp_buf < sizeof(m_tmp_buf)); asio::async_write(m_socks5_sock, asio::buffer(m_tmp_buf, p - m_tmp_buf) , boost::bind(&udp_socket::connect1, this, _1)); }