diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 4bfb1f2a2..1d8a5f9e8 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4706,10 +4706,14 @@ namespace libtorrent } // do not stall waiting for a handshake + int timeout = m_settings.get_int (settings_pack::handshake_timeout); +#if TORRENT_USE_I2P + timeout *= is_i2p(*m_socket) ? 4 : 1; +#endif if (may_timeout && !m_connecting && in_handshake() - && d > seconds(m_settings.get_int(settings_pack::handshake_timeout))) + && d > seconds(timeout)) { #ifndef TORRENT_DISABLE_LOGGING peer_log(peer_log_alert::info, "NO_HANDSHAKE", "waited %d seconds" diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 56c14f248..c20d1d4ec 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -3042,8 +3042,11 @@ retry: if (!p->associated_torrent().expired()) continue; // TODO: have a separate list for these connections, instead of having to loop through all of them - if (m_last_tick - p->connected_time() - > seconds(m_settings.get_int(settings_pack::handshake_timeout))) + int timeout = m_settings.get_int(settings_pack::handshake_timeout); +#if TORRENT_USE_I2P + timeout *= is_i2p(*p->get_socket()) ? 4 : 1; +#endif + if (m_last_tick - p->connected_time () > seconds(timeout)) p->disconnect(errors::timed_out, op_bittorrent); }