diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-01-08 15:08:28 -0800 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-01-08 15:08:28 -0800 |
commit | 5b5abd8c038b88cba7078a105b0896cd151ee509 (patch) | |
tree | d4bfa46c7a830d5a1e262f1f53705f3a9061f949 /src/common/address.c | |
parent | a1019b82c1e26f0fb925bfc9ae55d213be579a90 (diff) | |
parent | 110765f5564a588c5f019d32b5e6f66cc7806c41 (diff) | |
download | tor-5b5abd8c038b88cba7078a105b0896cd151ee509.tar.gz tor-5b5abd8c038b88cba7078a105b0896cd151ee509.zip |
Merge commit '110765f5564a588c5f019d32b5e6f66cc7806c41'
Diffstat (limited to 'src/common/address.c')
-rw-r--r-- | src/common/address.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/common/address.c b/src/common/address.c index 061bb7e724..53be7027d5 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -1547,8 +1547,9 @@ tor_addr_is_multicast(const tor_addr_t *a) } /** Attempt to retrieve IP address of current host by utilizing some - * UDP socket trickery. Only look for address of given <b>family</b>. - * Set result to *<b>addr</b>. Return 0 on success, -1 on failure. + * UDP socket trickery. Only look for address of given <b>family</b> + * (only AF_INET and AF_INET6 are supported). Set result to *<b>addr</b>. + * Return 0 on success, -1 on failure. */ MOCK_IMPL(int, get_interface_address6_via_udp_socket_hack,(int severity, @@ -1720,15 +1721,27 @@ MOCK_IMPL(smartlist_t *,get_interface_address6_list,(int severity, } /* Okay, the smart way is out. */ - if (get_interface_address6_via_udp_socket_hack(severity,family,&addr)) - return smartlist_new(); - if (!include_internal && tor_addr_is_internal(&addr, 0)) { - return smartlist_new(); - } else { - addrs = smartlist_new(); - smartlist_add(addrs, tor_dup_addr(&addr)); - return addrs; + addrs = smartlist_new(); + + if (family == AF_INET || family == AF_UNSPEC) { + if (get_interface_address6_via_udp_socket_hack(severity,AF_INET, + &addr) == 0) { + if (include_internal || !tor_addr_is_internal(&addr, 0)) { + smartlist_add(addrs, tor_dup_addr(&addr)); + } + } } + + if (family == AF_INET6 || family == AF_UNSPEC) { + if (get_interface_address6_via_udp_socket_hack(severity,AF_INET6, + &addr) == 0) { + if (include_internal || !tor_addr_is_internal(&addr, 0)) { + smartlist_add(addrs, tor_dup_addr(&addr)); + } + } + } + + return addrs; } /* ====== |