fix for when DHT is started before a listen port has been configured

This commit is contained in:
Arvid Norberg 2008-10-27 03:45:08 +00:00
parent 7d83bfb6b3
commit efcaee9c2d
1 changed files with 4 additions and 9 deletions

View File

@ -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)