mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 04:18:39 +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:
@@ -225,10 +225,10 @@ buildHandshakeMessage( tr_handshake * handshake, uint8_t * buf )
|
|||||||
HANDSHAKE_SET_LTEP( walk );
|
HANDSHAKE_SET_LTEP( walk );
|
||||||
HANDSHAKE_SET_FASTEXT( walk );
|
HANDSHAKE_SET_FASTEXT( walk );
|
||||||
|
|
||||||
/* Note that this doesn't depend on whether the torrent is private. We
|
/* Note that this doesn't depend on whether the torrent is private.
|
||||||
don't accept DHT peers for a private torrent, but we participate in
|
* We don't accept DHT peers for a private torrent,
|
||||||
the DHT regardless. */
|
* but we participate in the DHT regardless. */
|
||||||
if(tr_dhtEnabled(handshake->session))
|
if( tr_dhtEnabled( handshake->session ) )
|
||||||
HANDSHAKE_SET_DHT( walk );
|
HANDSHAKE_SET_DHT( walk );
|
||||||
|
|
||||||
walk += HANDSHAKE_FLAGS_LEN;
|
walk += HANDSHAKE_FLAGS_LEN;
|
||||||
@@ -312,10 +312,7 @@ parseHandshake( tr_handshake * handshake,
|
|||||||
|
|
||||||
tr_peerIoEnableFEXT( handshake->io, HANDSHAKE_HAS_FASTEXT( reserved ) );
|
tr_peerIoEnableFEXT( handshake->io, HANDSHAKE_HAS_FASTEXT( reserved ) );
|
||||||
|
|
||||||
/* This is independent of whether or not DHT is actually used.
|
tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
|
||||||
* 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 ) );
|
|
||||||
|
|
||||||
return HANDSHAKE_OK;
|
return HANDSHAKE_OK;
|
||||||
}
|
}
|
||||||
@@ -675,10 +672,7 @@ readHandshake( tr_handshake * handshake,
|
|||||||
|
|
||||||
tr_peerIoEnableFEXT( handshake->io, HANDSHAKE_HAS_FASTEXT( reserved ) );
|
tr_peerIoEnableFEXT( handshake->io, HANDSHAKE_HAS_FASTEXT( reserved ) );
|
||||||
|
|
||||||
/* This is independent of whether or not DHT is actually used.
|
tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
|
||||||
* it's okay to set this flag even for private torrents */
|
|
||||||
if( tr_sessionAllowsDHT( handshake->session ) )
|
|
||||||
tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) );
|
|
||||||
|
|
||||||
/* torrent hash */
|
/* torrent hash */
|
||||||
tr_peerIoReadBytes( handshake->io, inbuf, hash, sizeof( hash ) );
|
tr_peerIoReadBytes( handshake->io, inbuf, hash, sizeof( hash ) );
|
||||||
|
|||||||
@@ -2358,7 +2358,8 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
|
|||||||
if( tr_peerIoSupportsLTEP( peer->io ) )
|
if( tr_peerIoSupportsLTEP( peer->io ) )
|
||||||
sendLtepHandshake( m );
|
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). */
|
/* Only send PORT over IPv6 when the IPv6 DHT is running (BEP-32). */
|
||||||
const struct tr_address *addr = tr_peerIoGetAddress( peer->io, NULL );
|
const struct tr_address *addr = tr_peerIoGetAddress( peer->io, NULL );
|
||||||
if( addr->type == TR_AF_INET || tr_globalIPv6() ) {
|
if( addr->type == TR_AF_INET || tr_globalIPv6() ) {
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ tr_dhtUninit(tr_session *ss)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tr_bool
|
tr_bool
|
||||||
tr_dhtEnabled( tr_session * ss )
|
tr_dhtEnabled( const tr_session * ss )
|
||||||
{
|
{
|
||||||
return ss && ( ss == session );
|
return ss && ( ss == session );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ enum
|
|||||||
|
|
||||||
int tr_dhtInit( tr_session *, const tr_address * );
|
int tr_dhtInit( tr_session *, const tr_address * );
|
||||||
void tr_dhtUninit( tr_session * );
|
void tr_dhtUninit( tr_session * );
|
||||||
tr_bool tr_dhtEnabled( tr_session * );
|
tr_bool tr_dhtEnabled( const tr_session * );
|
||||||
tr_port tr_dhtPort ( tr_session * );
|
tr_port tr_dhtPort ( tr_session * );
|
||||||
int tr_dhtStatus( tr_session *, int af, int * setme_nodeCount );
|
int tr_dhtStatus( tr_session *, int af, int * setme_nodeCount );
|
||||||
const char *tr_dhtPrintableStatus(int status);
|
const char *tr_dhtPrintableStatus(int status);
|
||||||
|
|||||||
Reference in New Issue
Block a user