1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

(trunk libT) #2903 "Don't send DHT port messages to peers if we didn't advertise support for DHT in the handshake" -- fixed in trunk for 1.90

This commit is contained in:
Charles Kerr 2010-02-14 19:35:09 +00:00
parent 6ddd5c4f12
commit e31b9d8fc5
4 changed files with 10 additions and 15 deletions

View file

@ -225,10 +225,10 @@ buildHandshakeMessage( tr_handshake * handshake, uint8_t * buf )
HANDSHAKE_SET_LTEP( walk );
HANDSHAKE_SET_FASTEXT( walk );
/* Note that this doesn't depend on whether the torrent is private. We
don't accept DHT peers for a private torrent, but we participate in
the DHT regardless. */
if(tr_dhtEnabled(handshake->session))
/* Note that this doesn't depend on whether the torrent is private.
* We don't accept DHT peers for a private torrent,
* but we participate in the DHT regardless. */
if( tr_dhtEnabled( handshake->session ) )
HANDSHAKE_SET_DHT( walk );
walk += HANDSHAKE_FLAGS_LEN;
@ -312,10 +312,7 @@ parseHandshake( tr_handshake * handshake,
tr_peerIoEnableFEXT( handshake->io, HANDSHAKE_HAS_FASTEXT( reserved ) );
/* This is independent of whether or not DHT is actually used.
* it's okay to set this flag even for private torrents */
if( tor && tr_sessionAllowsDHT( tor->session ) )
tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
return HANDSHAKE_OK;
}
@ -675,10 +672,7 @@ readHandshake( tr_handshake * handshake,
tr_peerIoEnableFEXT( handshake->io, HANDSHAKE_HAS_FASTEXT( reserved ) );
/* This is independent of whether or not DHT is actually used.
* it's okay to set this flag even for private torrents */
if( tr_sessionAllowsDHT( handshake->session ) )
tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
/* torrent hash */
tr_peerIoReadBytes( handshake->io, inbuf, hash, sizeof( hash ) );

View file

@ -2358,7 +2358,8 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
if( tr_peerIoSupportsLTEP( peer->io ) )
sendLtepHandshake( m );
if(tr_peerIoSupportsDHT(peer->io)) {
if( tr_dhtEnabled( torrent->session ) && tr_peerIoSupportsDHT( peer->io ))
{
/* Only send PORT over IPv6 when the IPv6 DHT is running (BEP-32). */
const struct tr_address *addr = tr_peerIoGetAddress( peer->io, NULL );
if( addr->type == TR_AF_INET || tr_globalIPv6() ) {

View file

@ -482,7 +482,7 @@ tr_dhtUninit(tr_session *ss)
}
tr_bool
tr_dhtEnabled( tr_session * ss )
tr_dhtEnabled( const tr_session * ss )
{
return ss && ( ss == session );
}

View file

@ -35,7 +35,7 @@ enum
int tr_dhtInit( tr_session *, const tr_address * );
void tr_dhtUninit( tr_session * );
tr_bool tr_dhtEnabled( tr_session * );
tr_bool tr_dhtEnabled( const tr_session * );
tr_port tr_dhtPort ( tr_session * );
int tr_dhtStatus( tr_session *, int af, int * setme_nodeCount );
const char *tr_dhtPrintableStatus(int status);