mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
(trunk libT) #3906 "DHT ignores bind-address-ipv6" -- make the process of getting the binding address consistent between IPv4 and IPv6 sockets.
As suggested by Juiusz after the IPv6 binding commit in r11749. See: https://trac.transmissionbt.com/ticket/3906#comment:6
This commit is contained in:
parent
f36fc1246c
commit
599d33035b
3 changed files with 9 additions and 5 deletions
|
@ -706,7 +706,7 @@ tr_sessionInitImpl( void * vdata )
|
|||
|
||||
tr_sessionSet( session, &settings );
|
||||
|
||||
tr_udpInit( session, &session->public_ipv4->addr );
|
||||
tr_udpInit( session );
|
||||
|
||||
if( session->isLPDEnabled )
|
||||
tr_lpdInit( session, &session->public_ipv4->addr );
|
||||
|
@ -1946,7 +1946,7 @@ toggleDHTImpl( void * data )
|
|||
|
||||
tr_udpUninit( session );
|
||||
session->isDHTEnabled = !session->isDHTEnabled;
|
||||
tr_udpInit( session, &session->public_ipv4->addr );
|
||||
tr_udpInit( session );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -148,8 +148,10 @@ event_callback(int s, short type, void *sv)
|
|||
}
|
||||
|
||||
void
|
||||
tr_udpInit(tr_session *ss, const tr_address * addr)
|
||||
tr_udpInit(tr_session *ss)
|
||||
{
|
||||
tr_bool is_default;
|
||||
const struct tr_address * public_addr;
|
||||
struct sockaddr_in sin;
|
||||
int rc;
|
||||
|
||||
|
@ -168,7 +170,9 @@ tr_udpInit(tr_session *ss, const tr_address * addr)
|
|||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
memcpy(&sin.sin_addr, &addr->addr.addr4, sizeof (struct in_addr));
|
||||
public_addr = tr_sessionGetPublicAddress(ss, TR_AF_INET, &is_default);
|
||||
if(public_addr && !is_default)
|
||||
memcpy(&sin.sin_addr, &public_addr->addr.addr4, sizeof (struct in_addr));
|
||||
sin.sin_port = htons(ss->udp_port);
|
||||
rc = bind(ss->udp_socket, (struct sockaddr*)&sin, sizeof(sin));
|
||||
if(rc < 0) {
|
||||
|
|
|
@ -25,6 +25,6 @@ THE SOFTWARE.
|
|||
#error only libtransmission should #include this header.
|
||||
#endif
|
||||
|
||||
void tr_udpInit( tr_session *, const tr_address *);
|
||||
void tr_udpInit( tr_session * );
|
||||
void tr_udpUninit( tr_session * );
|
||||
|
||||
|
|
Loading…
Reference in a new issue