From 5431d867791372db9829cf57a70c67a179db48c2 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 7 Mar 2011 07:02:30 +0000 Subject: [PATCH] no need to close and re-open the listen socket when starting the DHT. Report the actual port we ended up listening on if the system chose one. don't try to listen on i2p --- examples/client_test.cpp | 2 +- src/i2p_stream.cpp | 2 ++ src/session_impl.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index d1d50e905..1921966de 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1152,7 +1152,7 @@ int main(int argc, char* argv[]) ses.set_proxy(ps); - ses.listen_on(std::make_pair(listen_port, listen_port + 10) + ses.listen_on(std::make_pair(listen_port, listen_port) , ec, bind_to_interface.c_str()); if (ec) { diff --git a/src/i2p_stream.cpp b/src/i2p_stream.cpp index 72921a71b..ea353827b 100644 --- a/src/i2p_stream.cpp +++ b/src/i2p_stream.cpp @@ -91,6 +91,8 @@ namespace libtorrent m_sam_router = s; m_sam_router.type = proxy_settings::i2p_proxy; + if (m_sam_router.hostname.empty()) return; + m_state = sam_connecting; char tmp[20]; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f0462aed0..a1d4581a3 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1779,6 +1779,11 @@ namespace aux { return listen_socket_t(); } + // if we asked the system to listen on port 0, which + // socket did it end up choosing? + if (ep.port() == 0) + ep.port(s.sock->local_endpoint().port()); + if (m_alerts.should_post()) m_alerts.post_alert(listen_succeeded_alert(ep)); @@ -4365,12 +4370,6 @@ namespace aux { { INVARIANT_CHECK; - if (m_listen_interface.port() != 0) - { - error_code ec; - open_listen_port(0, ec); - } - if (m_dht) { m_dht->stop();