]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check for new IP addr after circuit liveliness returns
authorMatthew Finkel <matthew.finkel@gmail.com>
Tue, 1 Apr 2014 21:30:20 +0000 (17:30 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 8 Apr 2014 19:37:01 +0000 (15:37 -0400)
When we successfully create a usable circuit after it previously
timed out for a certain amount of time, we should make sure that
our public IP address hasn't changed and update our descriptor.

changes/bug2454 [new file with mode: 0644]
src/or/circuitstats.c
src/or/main.c
src/or/main.h

diff --git a/changes/bug2454 b/changes/bug2454
new file mode 100644 (file)
index 0000000..18e327b
--- /dev/null
@@ -0,0 +1,6 @@
+  o Enhancement:
+    - If a circuit timed out for at least 3 minutes check if we have a new
+      external IP address the next time we run our routine checks. If our
+      IP address has changed, then publish a new descriptor with the new
+      IP address. Resolves ticket 2454.
+
index c093ecd269dedc7a3af354d1d9d6ad6f79b88afc..e362b1b49ee542a553b5825d77a0ed653adad26f 100644 (file)
@@ -12,6 +12,7 @@
 #include "config.h"
 #include "confparse.h"
 #include "control.h"
+#include "main.h"
 #include "networkstatus.h"
 #include "statefile.h"
 
@@ -1184,6 +1185,12 @@ circuit_build_times_needs_circuits_now(const circuit_build_times_t *cbt)
     approx_time()-cbt->last_circ_at > circuit_build_times_test_frequency();
 }
 
+/**
+ * How long should we be unreachable before we think we need to check if
+ * our published IP address has changed.
+ */
+#define CIRCUIT_TIMEOUT_BEFORE_RECHECK_IP (60*3)
+
 /**
  * Called to indicate that the network showed some signs of liveness,
  * i.e. we received a cell.
@@ -1199,12 +1206,15 @@ circuit_build_times_network_is_live(circuit_build_times_t *cbt)
 {
   time_t now = approx_time();
   if (cbt->liveness.nonlive_timeouts > 0) {
+    time_t time_since_live = now - cbt->liveness.network_last_live;
     log_notice(LD_CIRC,
                "Tor now sees network activity. Restoring circuit build "
                "timeout recording. Network was down for %d seconds "
                "during %d circuit attempts.",
-               (int)(now - cbt->liveness.network_last_live),
+               (int)time_since_live,
                cbt->liveness.nonlive_timeouts);
+    if (time_since_live > CIRCUIT_TIMEOUT_BEFORE_RECHECK_IP)
+      reschedule_descriptor_update_check();
   }
   cbt->liveness.network_last_live = now;
   cbt->liveness.nonlive_timeouts = 0;
index feca35c44093f60566df9958218d4837677aaed3..86f3437502e00b558a9b9342549a4a4b670086fc 100644 (file)
@@ -1162,6 +1162,18 @@ get_signewnym_epoch(void)
   return newnym_epoch;
 }
 
+static time_t time_to_check_descriptor = 0;
+/**
+ * Update our schedule so that we'll check whether we need to update our
+ * descriptor immediately, rather than after up to CHECK_DESCRIPTOR_INTERVAL
+ * seconds.
+ */
+void
+reschedule_descriptor_update_check(void)
+{
+  time_to_check_descriptor = 0;
+}
+
 /** Perform regular maintenance tasks.  This function gets run once per
  * second by second_elapsed_callback().
  */
@@ -1171,7 +1183,6 @@ run_scheduled_events(time_t now)
   static time_t last_rotated_x509_certificate = 0;
   static time_t time_to_check_v3_certificate = 0;
   static time_t time_to_check_listeners = 0;
-  static time_t time_to_check_descriptor = 0;
   static time_t time_to_download_networkstatus = 0;
   static time_t time_to_shrink_memory = 0;
   static time_t time_to_try_getting_descriptors = 0;
index df302ffa723693a4b76f21eafe6cd205866b6b2d..a2f03d9546e91fb0fb8a3fee8c6d3c6d901a5ef2 100644 (file)
@@ -50,6 +50,7 @@ void directory_info_has_arrived(time_t now, int from_cache);
 
 void ip_address_changed(int at_interface);
 void dns_servers_relaunch_checks(void);
+void reschedule_descriptor_update_check(void);
 
 long get_uptime(void);
 unsigned get_signewnym_epoch(void);