diff --git a/libtransmission/session.c b/libtransmission/session.c index 3aff0314e..720fdb5e5 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -848,7 +848,7 @@ tr_sessionInitImpl( void * vdata ) #ifdef WITHOUT_DHT tr_inf( "DHT disabled by packager." ); #else - tr_dhtInit( session ); + tr_dhtInit( session, &session->public_ipv4->addr ); #endif } } @@ -1633,7 +1633,7 @@ toggleDHTImpl( void * data ) session->isDHTEnabled = !session->isDHTEnabled; if( session->isDHTEnabled ) - tr_dhtInit( session ); + tr_dhtInit( session, &session->public_ipv4->addr ); } void diff --git a/libtransmission/tr-dht.c b/libtransmission/tr-dht.c index b9b1105c3..2fa6237a4 100644 --- a/libtransmission/tr-dht.c +++ b/libtransmission/tr-dht.c @@ -119,7 +119,7 @@ dht_bootstrap(void *closure) } int -tr_dhtInit(tr_session *ss) +tr_dhtInit(tr_session *ss, tr_address * tr_addr) { struct sockaddr_in sin; tr_benc benc; @@ -146,6 +146,7 @@ tr_dhtInit(tr_session *ss) memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; + memcpy(&(sin.sin_addr), &(tr_addr->addr.addr4), sizeof (struct in_addr)); sin.sin_port = htons(dht_port); rc = bind(dht_socket, (struct sockaddr*)&sin, sizeof(sin)); if(rc < 0) diff --git a/libtransmission/tr-dht.h b/libtransmission/tr-dht.h index 2198d4b05..d0be03df6 100644 --- a/libtransmission/tr-dht.h +++ b/libtransmission/tr-dht.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define TR_DHT_FIREWALLED 3 #define TR_DHT_GOOD 4 -int tr_dhtInit( tr_session * ); +int tr_dhtInit( tr_session *, tr_address * ); void tr_dhtUninit( tr_session * ); tr_bool tr_dhtEnabled( const tr_session * ); tr_port tr_dhtPort ( const tr_session * );