From 0f38acf829c2edf8089a6748c029a3853938ae67 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 27 Nov 2016 16:20:01 -0500 Subject: [PATCH] don't send dht-port if we don't have a udp listen socket --- src/bt_peer_connection.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 3771c23ea..2823e5529 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -328,7 +328,10 @@ namespace libtorrent TORRENT_ASSERT(m_sent_bitfield); #ifndef TORRENT_DISABLE_DHT if (m_supports_dht_port && m_ses.has_dht()) - write_dht_port(m_ses.external_udp_port()); + { + int const port = m_ses.external_udp_port(); + if (port >= 0) write_dht_port(port); + } #endif } @@ -1340,7 +1343,10 @@ namespace libtorrent m_supports_dht_port = true; #ifndef TORRENT_DISABLE_DHT if (m_supports_dht_port && m_ses.has_dht()) - write_dht_port(m_ses.external_udp_port()); + { + int const port = m_ses.external_udp_port(); + if (port >= 0) write_dht_port(port); + } #endif } } @@ -3433,7 +3439,10 @@ namespace libtorrent write_bitfield(); #ifndef TORRENT_DISABLE_DHT if (m_supports_dht_port && m_ses.has_dht()) - write_dht_port(m_ses.external_udp_port()); + { + int const port = m_ses.external_udp_port(); + if (port >= 0) write_dht_port(port); + } #endif // if we don't have any pieces, don't do any preemptive