From 6ef8106ab9cbf6a2907a386910b4119520fa0c22 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 --- src/peer_connection.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) 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) {