mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
addr: Rename last_resolved_addr to be v4 specific
Part of #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
6da8c0b4fa
commit
d08d7e1535
@ -20,20 +20,20 @@
|
|||||||
#include "lib/net/resolve.h"
|
#include "lib/net/resolve.h"
|
||||||
|
|
||||||
/** Last value actually set by resolve_my_address. */
|
/** Last value actually set by resolve_my_address. */
|
||||||
static uint32_t last_resolved_addr = 0;
|
static uint32_t last_resolved_addr_v4 = 0;
|
||||||
|
|
||||||
/** Accessor for last_resolved_addr from outside this file. */
|
/** Accessor for last_resolved_addr_v4 from outside this file. */
|
||||||
uint32_t
|
uint32_t
|
||||||
get_last_resolved_addr(void)
|
get_last_resolved_addr_v4(void)
|
||||||
{
|
{
|
||||||
return last_resolved_addr;
|
return last_resolved_addr_v4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reset last_resolved_addr from outside this file. */
|
/** Reset last_resolved_addr_v4 from outside this file. */
|
||||||
void
|
void
|
||||||
reset_last_resolved_addr(void)
|
reset_last_resolved_addr_v4(void)
|
||||||
{
|
{
|
||||||
last_resolved_addr = 0;
|
last_resolved_addr_v4 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,7 +257,7 @@ resolve_my_address_v4(int warn_severity, const or_options_t *options,
|
|||||||
* us up-to-date.
|
* us up-to-date.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (last_resolved_addr && last_resolved_addr != *addr_out) {
|
if (last_resolved_addr_v4 && last_resolved_addr_v4 != *addr_out) {
|
||||||
/* Leave this as a notice, regardless of the requested severity,
|
/* Leave this as a notice, regardless of the requested severity,
|
||||||
* at least until dynamic IP address support becomes bulletproof. */
|
* at least until dynamic IP address support becomes bulletproof. */
|
||||||
log_notice(LD_NET,
|
log_notice(LD_NET,
|
||||||
@ -269,14 +269,14 @@ resolve_my_address_v4(int warn_severity, const or_options_t *options,
|
|||||||
ip_address_changed(0);
|
ip_address_changed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_resolved_addr != *addr_out) {
|
if (last_resolved_addr_v4 != *addr_out) {
|
||||||
control_event_server_status(LOG_NOTICE,
|
control_event_server_status(LOG_NOTICE,
|
||||||
"EXTERNAL_ADDRESS ADDRESS=%s METHOD=%s%s%s",
|
"EXTERNAL_ADDRESS ADDRESS=%s METHOD=%s%s%s",
|
||||||
addr_string, method_used,
|
addr_string, method_used,
|
||||||
hostname_used ? " HOSTNAME=" : "",
|
hostname_used ? " HOSTNAME=" : "",
|
||||||
hostname_used ? hostname_used : "");
|
hostname_used ? hostname_used : "");
|
||||||
}
|
}
|
||||||
last_resolved_addr = *addr_out;
|
last_resolved_addr_v4 = *addr_out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And finally, clean up and return success.
|
* And finally, clean up and return success.
|
||||||
@ -303,11 +303,11 @@ is_local_addr, (const tor_addr_t *addr))
|
|||||||
/* It's possible that this next check will hit before the first time
|
/* It's possible that this next check will hit before the first time
|
||||||
* resolve_my_address actually succeeds. (For clients, it is likely that
|
* resolve_my_address actually succeeds. (For clients, it is likely that
|
||||||
* resolve_my_address will never be called at all). In those cases,
|
* resolve_my_address will never be called at all). In those cases,
|
||||||
* last_resolved_addr will be 0, and so checking to see whether ip is on
|
* last_resolved_addr_v4 will be 0, and so checking to see whether ip is
|
||||||
* the same /24 as last_resolved_addr will be the same as checking whether
|
* on the same /24 as last_resolved_addr_v4 will be the same as checking
|
||||||
* it was on net 0, which is already done by tor_addr_is_internal.
|
* whether it was on net 0, which is already done by tor_addr_is_internal.
|
||||||
*/
|
*/
|
||||||
if ((last_resolved_addr & (uint32_t)0xffffff00ul)
|
if ((last_resolved_addr_v4 & (uint32_t)0xffffff00ul)
|
||||||
== (ip & (uint32_t)0xffffff00ul))
|
== (ip & (uint32_t)0xffffff00ul))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ int resolve_my_address_v4(int warn_severity, const or_options_t *options,
|
|||||||
uint32_t *addr_out,
|
uint32_t *addr_out,
|
||||||
const char **method_out, char **hostname_out);
|
const char **method_out, char **hostname_out);
|
||||||
|
|
||||||
uint32_t get_last_resolved_addr(void);
|
uint32_t get_last_resolved_addr_v4(void);
|
||||||
void reset_last_resolved_addr(void);
|
void reset_last_resolved_addr_v4(void);
|
||||||
|
|
||||||
MOCK_DECL(int, is_local_addr, (const tor_addr_t *addr));
|
MOCK_DECL(int, is_local_addr, (const tor_addr_t *addr));
|
||||||
|
|
||||||
|
@ -4870,7 +4870,7 @@ client_check_address_changed(tor_socket_t sock)
|
|||||||
smartlist_clear(outgoing_addrs);
|
smartlist_clear(outgoing_addrs);
|
||||||
smartlist_add(outgoing_addrs, tor_memdup(&out_addr, sizeof(tor_addr_t)));
|
smartlist_add(outgoing_addrs, tor_memdup(&out_addr, sizeof(tor_addr_t)));
|
||||||
/* We'll need to resolve ourselves again. */
|
/* We'll need to resolve ourselves again. */
|
||||||
reset_last_resolved_addr();
|
reset_last_resolved_addr_v4();
|
||||||
/* Okay, now change our keys. */
|
/* Okay, now change our keys. */
|
||||||
ip_address_changed(1);
|
ip_address_changed(1);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ router_new_address_suggestion(const char *suggestion,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXXX ipv6 */
|
/* XXXX ipv6 */
|
||||||
cur = get_last_resolved_addr();
|
cur = get_last_resolved_addr_v4();
|
||||||
if (cur ||
|
if (cur ||
|
||||||
resolve_my_address_v4(LOG_INFO, options, &cur, NULL, NULL) >= 0) {
|
resolve_my_address_v4(LOG_INFO, options, &cur, NULL, NULL) >= 0) {
|
||||||
/* We're all set -- we already know our address. Great. */
|
/* We're all set -- we already know our address. Great. */
|
||||||
@ -112,7 +112,7 @@ router_pick_published_address, (const or_options_t *options, uint32_t *addr,
|
|||||||
int cache_only))
|
int cache_only))
|
||||||
{
|
{
|
||||||
/* First, check the cached output from resolve_my_address(). */
|
/* First, check the cached output from resolve_my_address(). */
|
||||||
*addr = get_last_resolved_addr();
|
*addr = get_last_resolved_addr_v4();
|
||||||
if (*addr)
|
if (*addr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user