[tor-commits] [tor/master] Clear the cached address from resolve_my_address() when our IP changes

nickm at torproject.org nickm at torproject.org
Mon Sep 29 17:49:20 UTC 2014


commit b448ec195dd8687d2d5f363e12fec046eb2d1677
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Sep 29 13:46:30 2014 -0400

    Clear the cached address from resolve_my_address() when our IP changes
    
    Closes 11582; patch from "ra".
---
 changes/ticket11582 |    5 +++++
 src/or/config.c     |    7 +++++++
 src/or/config.h     |    1 +
 src/or/connection.c |    2 ++
 4 files changed, 15 insertions(+)

diff --git a/changes/ticket11582 b/changes/ticket11582
new file mode 100644
index 0000000..e54f779
--- /dev/null
+++ b/changes/ticket11582
@@ -0,0 +1,5 @@
+  o Minor features:
+    - Re-check our address after we detect a changed IP address from
+      getsockname(). This ensures that the controller command "GETINFO
+      address" will report the correct value. Resolves ticket 11582.
+      Patch from "ra".
\ No newline at end of file
diff --git a/src/or/config.c b/src/or/config.c
index d620f58..921d032 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2037,6 +2037,13 @@ get_last_resolved_addr(void)
   return last_resolved_addr;
 }
 
+/** Reset last_resolved_addr from outside this file. */
+void
+reset_last_resolved_addr(void)
+{
+  last_resolved_addr = 0;
+}
+
 /**
  * Use <b>options-\>Address</b> to guess our public IP address.
  *
diff --git a/src/or/config.h b/src/or/config.h
index 8a1919c..fd95698 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -29,6 +29,7 @@ setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
                                   int clear_first, char **msg);
 
 uint32_t get_last_resolved_addr(void);
+void reset_last_resolved_addr(void);
 int resolve_my_address(int warn_severity, const or_options_t *options,
                        uint32_t *addr_out,
                        const char **method_out, char **hostname_out);
diff --git a/src/or/connection.c b/src/or/connection.c
index 4a3bd2c..5c1b6d9 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -4386,6 +4386,8 @@ client_check_address_changed(tor_socket_t sock)
     SMARTLIST_FOREACH(outgoing_addrs, tor_addr_t*, a_ptr, tor_free(a_ptr));
     smartlist_clear(outgoing_addrs);
     smartlist_add(outgoing_addrs, tor_memdup(&out_addr, sizeof(tor_addr_t)));
+    /* We'll need to resolve ourselves again. */
+    reset_last_resolved_addr();
     /* Okay, now change our keys. */
     ip_address_changed(1);
   }



More information about the tor-commits mailing list