From 9306c6b3b0bac1c7fad4fef7a92879f5c152404b Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 30 Jun 2024 12:39:03 +0200 Subject: [PATCH] apply DSCP setting to peers before connecting --- ChangeLog | 1 + src/peer_connection.cpp | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ece91e118a..24875553831 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2.0.11 not released + * apply DSCP/TOS to sockets before initiating the TCP connection * assume copy_file_range() exists on linux (unless old glibc) * fix issue where set_piece_deadline() did not correctly post read_piece_alert * fix integer overflow in piece picker diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index c37a5e95ba3..76db3ac5aac 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -381,6 +381,20 @@ namespace libtorrent { init(); } + if (m_settings.get_int(settings_pack::peer_dscp) != 0) + { + int const value = m_settings.get_int(settings_pack::peer_dscp); + error_code ec; + aux::set_traffic_class(m_socket, value, ec); +#ifndef TORRENT_DISABLE_LOGGING + if (ec && should_log(peer_log_alert::outgoing)) + { + peer_log(peer_log_alert::outgoing, "SET_DSCP", "value: %d e: %s" + , value, ec.message().c_str()); + } +#endif + } + // if this is an incoming connection, we're done here if (!m_connecting) { @@ -6386,19 +6400,6 @@ namespace libtorrent { return; } - if (m_settings.get_int(settings_pack::peer_dscp) != 0) - { - int const value = m_settings.get_int(settings_pack::peer_dscp); - aux::set_traffic_class(m_socket, value, ec); -#ifndef TORRENT_DISABLE_LOGGING - if (ec && should_log(peer_log_alert::outgoing)) - { - peer_log(peer_log_alert::outgoing, "SET_DSCP", "value: %d e: %s" - , value, ec.message().c_str()); - } -#endif - } - #ifndef TORRENT_DISABLE_EXTENSIONS for (auto const& ext : m_extensions) {