[tor-commits] [tor/master] relay: Look at our cache when looking for an IP change

nickm at torproject.org nickm at torproject.org
Tue Nov 17 12:58:50 UTC 2020


commit a5538a36037641e49ca05aa3e90fec256794412b
Author: David Goulet <dgoulet at torproject.org>
Date:   Fri Sep 18 12:22:23 2020 -0400

    relay: Look at our cache when looking for an IP change
    
    Regularly, tor looks if its IP has changed. It does the entire auto discovery
    process again. However, it is possible that it does not find anything.
    
    Instead of thinking the IP changed to an unknown address, look at our cache
    and see if that value has changed.
    
    The reason for this is because if tor gets its address as a suggestion from a
    directory authority, it is because the auto discovery failed and thus that
    address should be consider for the IP change check.
    
    Related to #40071
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 src/feature/relay/router.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index 29103ed6c6..259c38f162 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -2679,8 +2679,21 @@ check_descriptor_ipaddress_changed(time_t now)
 
     /* Ignore returned value because we want to notice not only an address
      * change but also if an address is lost (current == UNSPEC). */
-    find_my_address(get_options(), family, LOG_INFO, &current, &method,
-                    &hostname);
+    bool found = find_my_address(get_options(), family, LOG_INFO, &current,
+                                 &method, &hostname);
+    if (!found) {
+      /* Address was possibly not found because it is simply not configured or
+       * discoverable. Fallback to our cache, which includes any suggestion
+       * sent by a trusted directory server. */
+      found = relay_find_addr_to_publish(get_options(), family,
+                                         RELAY_FIND_ADDR_CACHE_ONLY,
+                                         &current);
+    }
+
+    /* The "current" address might be UNSPEC meaning it was not discovered nor
+     * found in our current cache. If we had an address before and we have
+     * none now, we consider this an IP change since it appears the relay lost
+     * its address. */
 
     if (!tor_addr_eq(previous, &current)) {
       char *source;





More information about the tor-commits mailing list