addr: Rename and make resolved_addr_set_last() function public

Rename the static function update_resolved_cache() to resolved_addr_set_last()
and make it public.

We are about to use it in order to record any suggested address from a NETINFO
cell.

Related to #40022

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet
2020-07-06 09:40:03 -04:00
parent 78bc52c47c
commit f57ce632fe
2 changed files with 7 additions and 5 deletions
+5 -5
View File
@@ -370,7 +370,7 @@ get_address_from_interface(const or_options_t *options, int warn_severity,
return FN_RET_OK;
}
/** @brief Update the last resolved address cache using the given address.
/** @brief Set the last resolved address cache using the given address.
*
* A log notice is emitted if the given address has changed from before. Not
* emitted on first resolve.
@@ -386,9 +386,9 @@ get_address_from_interface(const or_options_t *options, int warn_severity,
* @param hostname_used Which hostname was used. If none were used, it is
* NULL. (for logging and control port).
*/
static void
update_resolved_cache(const tor_addr_t *addr, const char *method_used,
const char *hostname_used)
void
resolved_addr_set_last(const tor_addr_t *addr, const char *method_used,
const char *hostname_used)
{
/** Have we done a first resolve. This is used to control logging. */
static bool have_resolved_once[IDX_SIZE] = { false, false, false };
@@ -561,7 +561,7 @@ find_my_address(const or_options_t *options, int family, int warn_severity,
/*
* Step 2: Update last resolved address cache and inform the control port.
*/
update_resolved_cache(&my_addr, method_used, hostname_used);
resolved_addr_set_last(&my_addr, method_used, hostname_used);
if (method_out) {
*method_out = method_used;
+2
View File
@@ -17,6 +17,8 @@ bool find_my_address(const or_options_t *options, int family,
void resolved_addr_get_last(int family, tor_addr_t *addr_out);
void resolved_addr_reset_last(int family);
void resolved_addr_set_last(const tor_addr_t *addr, const char *method_used,
const char *hostname_used);
MOCK_DECL(bool, is_local_to_resolve_addr, (const tor_addr_t *addr));