From 51bc8d8b80d064f259e088513975c78a01b352a3 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 18 Feb 2011 00:35:56 +0000 Subject: [PATCH] Push testig for UTP enabled further down. There's no need to test for DHT/uTP being enabled in tr-udp. The DHT will silently discard any packets directed at the wrong session (see the beginning of dhtCallback). As to uTP, we need to grok uTP packets to close any remaining connections after we disabled uTP, so it's better to participate in uTP, just reject any incoming connections. --- libtransmission/tr-udp.c | 4 ++-- libtransmission/tr-utp.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libtransmission/tr-udp.c b/libtransmission/tr-udp.c index 5f896c48f..85d962650 100644 --- a/libtransmission/tr-udp.c +++ b/libtransmission/tr-udp.c @@ -135,11 +135,11 @@ event_callback(int s, short type UNUSED, void *sv) if(rc <= 0) return; - if((buf[0] == 'd') && tr_sessionIsDHTEnabled(ss)) { + if( buf[0] == 'd' ) { /* DHT packet. */ buf[rc] = '\0'; tr_dhtCallback(buf, rc, (struct sockaddr*)&from, fromlen, sv); - } else if(tr_sessionIsUTPEnabled(ss)){ + } else { rc = tr_utpPacket(buf, rc, (struct sockaddr*)&from, fromlen, ss); if(!rc) tr_ndbg("UDP", "Unexpected UDP packet"); diff --git a/libtransmission/tr-utp.c b/libtransmission/tr-utp.c index 83aa51cac..5c506b3d9 100644 --- a/libtransmission/tr-utp.c +++ b/libtransmission/tr-utp.c @@ -49,6 +49,11 @@ incoming(void *closure, struct UTPSocket *s) socklen_t fromlen = sizeof(from_storage); tr_address addr; tr_port port; + + if( !tr_sessionIsUTPEnabled(ss) ) { + UTP_Close(s); + return; + } UTP_GetPeerName(s, from, &fromlen); if(from->sa_family == AF_INET) {