From 68130d9c4ea282bdde449e852ae5ff3e38728348 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sat, 22 Jan 2011 13:49:15 +0000 Subject: [PATCH] (trunk libT) #3906 "DHT ignores bind-address-ipv6" -- test fix. Add code to honor the ipv6 bind address. Thanks to jch for saving me a little work by confirming the bug and pointing out where in the code the change needed to be made. --- libtransmission/tr-udp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libtransmission/tr-udp.c b/libtransmission/tr-udp.c index ab56b81c4..5cfdb8217 100644 --- a/libtransmission/tr-udp.c +++ b/libtransmission/tr-udp.c @@ -38,6 +38,8 @@ THE SOFTWARE. static void rebind_ipv6(tr_session *ss, tr_bool force) { + tr_bool is_default; + const struct tr_address * public_addr; struct sockaddr_in6 sin6; const unsigned char *ipv6 = tr_globalIPv6(); int s = -1, rc; @@ -71,6 +73,10 @@ rebind_ipv6(tr_session *ss, tr_bool force) if(ipv6) memcpy(&sin6.sin6_addr, ipv6, 16); sin6.sin6_port = htons(ss->udp_port); + public_addr = tr_sessionGetPublicAddress(ss, TR_AF_INET6, &is_default); + if(public_addr && !is_default) + sin6.sin6_addr = public_addr->addr.addr6; + rc = bind(s, (struct sockaddr*)&sin6, sizeof(sin6)); if(rc < 0) goto fail; -- 2.40.0