diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 575e8f487..261d2cfa0 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2133,15 +2133,10 @@ namespace aux { || m_dht_same_port) { m_dht_same_port = true; - // if you hit this assert you are trying to start the - // DHT with the same port as the tcp listen port - // (which is default) _before_ you have opened the - // tcp listen port (so there is no configured port to use) - // basically, make sure you call listen_on() before - // start_dht(). See documentation for listen_on() for - // more information. - TORRENT_ASSERT(m_listen_interface.port() > 0); - m_dht_settings.service_port = m_listen_interface.port(); + if (m_listen_interface.port() > 0) + m_dht_settings.service_port = m_listen_interface.port(); + else + m_dht_settings.service_port = 45000 + (rand() % 10000); } m_external_udp_port = m_dht_settings.service_port; if (m_natpmp.get() && m_udp_mapping[0] == -1)