aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitstats.c
diff options
context:
space:
mode:
authorMatthew Finkel <matthew.finkel@gmail.com>2014-04-01 17:30:20 -0400
committerNick Mathewson <nickm@torproject.org>2014-04-08 15:37:01 -0400
commit2d5a7b1842b3dad522166659ff3a88e418f36d13 (patch)
treebd2ec85f4291a644502f5282e7a6fc791bdb29c5 /src/or/circuitstats.c
parent6bef082d0a6047fd3625f548d60ad257aaed2fab (diff)
downloadtor-2d5a7b1842b3dad522166659ff3a88e418f36d13.tar
tor-2d5a7b1842b3dad522166659ff3a88e418f36d13.tar.gz
Check for new IP addr after circuit liveliness returns
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.
Diffstat (limited to 'src/or/circuitstats.c')
-rw-r--r--src/or/circuitstats.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index c093ecd26..e362b1b49 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -12,6 +12,7 @@
#include "config.h"
#include "confparse.h"
#include "control.h"
+#include "main.h"
#include "networkstatus.h"
#include "statefile.h"
@@ -1185,6 +1186,12 @@ circuit_build_times_needs_circuits_now(const circuit_build_times_t *cbt)
}
/**
+ * 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;