diff --git a/ChangeLog b/ChangeLog index f75bfbd88..f0104d4bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * announce port=1 instead of port=0, when there is no listen port * fix LSD over IPv6 * support TCP_NOTSENT_LOWAT on Linux * fix correct interface binding of local service discovery multicast diff --git a/simulation/test_tracker.cpp b/simulation/test_tracker.cpp index a1de3755b..e82d26254 100644 --- a/simulation/test_tracker.cpp +++ b/simulation/test_tracker.cpp @@ -353,7 +353,7 @@ void test_ipv6_support(char const* listen_interfaces // if we're not listening we'll just report port 0 std::string const expect_port = (listen_interfaces && listen_interfaces == ""_sv) - ? "&port=0" : "&port=6881"; + ? "&port=1" : "&port=6881"; http_v4.register_handler("/announce" , [&v4_announces,expect_port](std::string method, std::string req diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 15048d08c..e96624353 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -121,7 +121,7 @@ namespace libtorrent { , escape_string({tracker_req().pid.data(), 20}).c_str() // the i2p tracker seems to verify that the port is not 0, // even though it ignores it otherwise - , i2p ? 1 : tracker_req().listen_port + , tracker_req().listen_port , tracker_req().uploaded , tracker_req().downloaded , tracker_req().left diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 95c5a1797..08fa21e1c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1095,6 +1095,12 @@ namespace aux { return ret; } +namespace { + + std::uint16_t make_announce_port(std::uint16_t const p) + { return p == 0 ? 1 : p; } +} + void session_impl::queue_tracker_request(tracker_request&& req , std::weak_ptr c) { @@ -1116,11 +1122,14 @@ namespace aux { auto ls = req.outgoing_socket.get(); req.listen_port = +#if TORRENT_USE_I2P + (req.kind == tracker_request::i2p) ? 1 : +#endif #ifdef TORRENT_USE_OPENSSL // SSL torrents use the SSL listen port - use_ssl ? ssl_listen_port(ls) : + use_ssl ? make_announce_port(ssl_listen_port(ls)) : #endif - listen_port(ls); + make_announce_port(listen_port(ls)); m_tracker_manager.queue_request(get_io_service(), std::move(req), c); } else @@ -1133,11 +1142,14 @@ namespace aux { #endif tracker_request socket_req(req); socket_req.listen_port = +#if TORRENT_USE_I2P + (req.kind == tracker_request::i2p) ? 1 : +#endif #ifdef TORRENT_USE_OPENSSL // SSL torrents use the SSL listen port - use_ssl ? ssl_listen_port(ls.get()) : + use_ssl ? make_announce_port(ssl_listen_port(ls.get())) : #endif - listen_port(ls.get()); + make_announce_port(listen_port(ls.get())); socket_req.outgoing_socket = ls; m_tracker_manager.queue_request(get_io_service(), std::move(socket_req), c);