mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 10:28:32 +00:00
fix: apply optional peer socket TOS to UDP sockets (#1043)
This effectively makes the TOS setting apply to uTP and DHT traffic. Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
@@ -2250,6 +2250,8 @@ static void toggle_utp(void* vsession)
|
||||
|
||||
tr_udpSetSocketBuffers(session);
|
||||
|
||||
tr_udpSetSocketTOS(session);
|
||||
|
||||
/* But don't call tr_utpClose -- see reset_timer in tr-utp.c for an
|
||||
explanation. */
|
||||
}
|
||||
|
||||
@@ -124,6 +124,24 @@ void tr_udpSetSocketBuffers(tr_session* session)
|
||||
}
|
||||
}
|
||||
|
||||
void tr_udpSetSocketTOS(tr_session* session)
|
||||
{
|
||||
if (session->peerSocketTOS == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (session->udp_socket != TR_BAD_SOCKET)
|
||||
{
|
||||
tr_netSetTOS(session->udp_socket, session->peerSocketTOS, TR_AF_INET);
|
||||
}
|
||||
|
||||
if (session->udp6_socket != TR_BAD_SOCKET)
|
||||
{
|
||||
tr_netSetTOS(session->udp6_socket, session->peerSocketTOS, TR_AF_INET6);
|
||||
}
|
||||
}
|
||||
|
||||
/* BEP-32 has a rather nice explanation of why we need to bind to one
|
||||
IPv6 address, if I may say so myself. */
|
||||
// TODO: remove goto, it prevents reducing scope of local variables
|
||||
@@ -359,6 +377,8 @@ void tr_udpInit(tr_session* ss)
|
||||
|
||||
tr_udpSetSocketBuffers(ss);
|
||||
|
||||
tr_udpSetSocketTOS(ss);
|
||||
|
||||
if (ss->isDHTEnabled)
|
||||
{
|
||||
tr_dhtInit(ss);
|
||||
|
||||
@@ -30,5 +30,6 @@ THE SOFTWARE.
|
||||
void tr_udpInit(tr_session*);
|
||||
void tr_udpUninit(tr_session*);
|
||||
void tr_udpSetSocketBuffers(tr_session*);
|
||||
void tr_udpSetSocketTOS(tr_session*);
|
||||
|
||||
bool tau_handle_message(tr_session* session, uint8_t const* msg, size_t msglen);
|
||||
|
||||
Reference in New Issue
Block a user