merged uTP fix from RC_0_16
This commit is contained in:
parent
90edd1dd80
commit
e44225cb57
|
@ -5,6 +5,7 @@
|
|||
* fix uTP edge case where udp socket buffer fills up
|
||||
* fix nagle implementation in uTP
|
||||
|
||||
* fix some issues with SSL over uTP connections
|
||||
* fix UDP trackers trying all endpoints behind the hostname
|
||||
|
||||
0.16.4 release
|
||||
|
|
|
@ -306,6 +306,9 @@ namespace libtorrent
|
|||
// returns true if this socket is an SSL socket
|
||||
bool is_ssl(socket_type const& s);
|
||||
|
||||
// returns true if this is a uTP socket
|
||||
bool is_utp(socket_type const& s);
|
||||
|
||||
// assuming the socket_type s is an ssl socket, make sure it
|
||||
// verifies the hostname in its SSL handshake
|
||||
void setup_ssl_hostname(socket_type& s, std::string const& hostname, error_code& ec);
|
||||
|
|
|
@ -367,7 +367,7 @@ namespace libtorrent
|
|||
if (is_queued()) p.flags |= peer_info::queued;
|
||||
|
||||
p.client = m_client_version;
|
||||
p.connection_type = get_socket()->get<utp_stream>()
|
||||
p.connection_type = is_utp(*get_socket())
|
||||
? peer_info::bittorrent_utp
|
||||
: peer_info::standard_bittorrent;
|
||||
}
|
||||
|
|
|
@ -3291,7 +3291,7 @@ namespace libtorrent
|
|||
// a connection attempt using uTP just failed
|
||||
// mark this peer as not supporting uTP
|
||||
// we'll never try it again (unless we're trying holepunch)
|
||||
if (m_socket->get<utp_stream>()
|
||||
if (is_utp(*m_socket)
|
||||
&& m_peer_info
|
||||
&& m_peer_info->supports_utp
|
||||
&& !m_holepunch_mode)
|
||||
|
@ -3310,7 +3310,8 @@ namespace libtorrent
|
|||
fast_reconnect(true);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
if ((!m_socket->get<utp_stream>() || !m_ses.m_settings.enable_outgoing_tcp)
|
||||
if ((!is_utp(*m_socket)
|
||||
|| !m_ses.m_settings.enable_outgoing_tcp)
|
||||
&& m_peer_info
|
||||
&& m_peer_info->supports_holepunch
|
||||
&& !m_holepunch_mode)
|
||||
|
@ -3400,7 +3401,7 @@ namespace libtorrent
|
|||
if (ec == error_code(errors::timed_out_no_handshake))
|
||||
++m_ses.m_connect_timeouts;
|
||||
|
||||
if (m_socket->get<utp_stream>()) ++m_ses.m_error_utp_peers;
|
||||
if (is_utp(*m_socket)) ++m_ses.m_error_utp_peers;
|
||||
else ++m_ses.m_error_tcp_peers;
|
||||
|
||||
if (m_outgoing) ++m_ses.m_error_outgoing_peers;
|
||||
|
@ -5384,11 +5385,7 @@ namespace libtorrent
|
|||
if (m_disconnecting) return;
|
||||
m_last_receive = time_now();
|
||||
|
||||
if ((m_socket->get<utp_stream>()
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
|| m_socket->get<ssl_stream<utp_stream> >()
|
||||
#endif
|
||||
) && m_peer_info)
|
||||
if (is_utp(*m_socket) && m_peer_info)
|
||||
{
|
||||
m_peer_info->confirmed_supports_utp = true;
|
||||
m_peer_info->supports_utp = false;
|
||||
|
|
|
@ -3111,7 +3111,7 @@ namespace aux {
|
|||
peer_connection& p = *(*i);
|
||||
if (p.in_handshake()) continue;
|
||||
int protocol = 0;
|
||||
if (p.get_socket()->get<utp_stream>()) protocol = 1;
|
||||
if (is_utp(*p.get_socket())) protocol = 1;
|
||||
|
||||
if (p.download_queue().size() + p.request_queue().size() > 0)
|
||||
++num_peers[protocol][peer_connection::download_channel];
|
||||
|
@ -3666,6 +3666,9 @@ namespace aux {
|
|||
++peers_up_send_buffer;
|
||||
|
||||
utp_stream* utp_socket = p->get_socket()->get<utp_stream>();
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
if (!utp_socket) utp_socket = p->get_socket()->get<ssl_stream<utp_stream> >();
|
||||
#endif
|
||||
if (utp_socket)
|
||||
{
|
||||
utp_up_rate += ul_rate;
|
||||
|
|
|
@ -63,6 +63,15 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
bool is_utp(socket_type const& s)
|
||||
{
|
||||
return s.get<utp_stream>()
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
|| s.get<ssl_stream<utp_stream> >()
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
void setup_ssl_hostname(socket_type& s, std::string const& hostname, error_code& ec)
|
||||
{
|
||||
#if defined TORRENT_USE_OPENSSL && BOOST_VERSION >= 104700
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace libtorrent { namespace
|
|||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
flags |= p->supports_encryption() ? 1 : 0;
|
||||
#endif
|
||||
flags |= p->get_socket()->get<utp_stream>() ? 4 : 0;
|
||||
flags |= is_utp(*p->get_socket()) ? 4 : 0;
|
||||
flags |= p->supports_holepunch() ? 8 : 0;
|
||||
|
||||
// i->first was added since the last time
|
||||
|
@ -521,7 +521,7 @@ namespace libtorrent { namespace
|
|||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
flags |= p->supports_encryption() ? 1 : 0;
|
||||
#endif
|
||||
flags |= p->get_socket()->get<utp_stream>() ? 4 : 0;
|
||||
flags |= is_utp(*p->get_socket()) ? 4 : 0;
|
||||
flags |= p->supports_holepunch() ? 8 : 0;
|
||||
|
||||
tcp::endpoint remote = peer->remote();
|
||||
|
|
Loading…
Reference in New Issue