Ticket #2454: 0001-Check-for-new-IP-addr-after-circuit-liveliness-retur.patch

File 0001-Check-for-new-IP-addr-after-circuit-liveliness-retur.patch, 4.0 KB (added by sysrqb, 7 years ago)
  • new file changes/bug2454

    From a169e2264a11c932416dff847e306a9979aba3cc Mon Sep 17 00:00:00 2001
    From: Matthew Finkel <matthew.finkel@gmail.com>
    Date: Tue, 16 Oct 2012 14:52:03 -0400
    Subject: [PATCH] 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.
    ---
     changes/bug2454       |  6 ++++++
     src/or/circuitbuild.c | 15 +++++++++++++++
     src/or/circuitbuild.h |  2 ++
     src/or/main.c         |  8 ++++++--
     4 files changed, 29 insertions(+), 2 deletions(-)
     create mode 100644 changes/bug2454
    
    diff --git a/changes/bug2454 b/changes/bug2454
    new file mode 100644
    index 0000000..2adefd6
    - +  
     1  o Enhancement:
     2    - If a circuit timed out for at least 3 minutes check if we have a new
     3      external IP address the next time we run our routine checks. If our
     4      IP address has changed, then publish a new descriptor with the new
     5      IP address.
     6 
  • src/or/circuitbuild.c

    diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
    index 9287084..3bc8be4 100644
    a b static int entry_guards_dirty = 0; 
    125125 * our state file or accessing get_options() or get_or_state() */
    126126static int unit_tests = 0;
    127127
     128/** If building a circuit succeeds after failing for a certain amount
     129 * of time, then we are set so we know to recheck our IP address the
     130 * next time run_scheduled_events is fired.
     131 */
     132int check_new_ip_addr_after_circuit_alive_again = 0;
     133
    128134/********* END VARIABLES ************/
    129135
    130136static channel_t * channel_connect_for_circuit(const tor_addr_t *addr,
    circuit_build_times_needs_circuits_now(circuit_build_times_t *cbt) 
    12871293}
    12881294
    12891295/**
     1296 * How long should we be unreachable before we think we need to check if
     1297 * our published IP address has changed.
     1298 */
     1299#define CIRCUIT_TIMEOUT_BEFORE_RECHECK_IP (60*3)
     1300
     1301/**
    12901302 * Called to indicate that the network showed some signs of liveness,
    12911303 * i.e. we received a cell.
    12921304 *
    circuit_build_times_network_is_live(circuit_build_times_t *cbt) 
    13071319               "during %d circuit attempts.",
    13081320               (int)(now - cbt->liveness.network_last_live),
    13091321               cbt->liveness.nonlive_timeouts);
     1322    if(cbt->liveness.nonlive_timeouts > CIRCUIT_TIMEOUT_BEFORE_RECHECK_IP) {
     1323      check_new_ip_addr_after_circuit_alive_again = 1;
     1324    }
    13101325  }
    13111326  cbt->liveness.network_last_live = now;
    13121327  cbt->liveness.nonlive_timeouts = 0;
  • src/or/circuitbuild.h

    diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
    index 3ab8fd5..37a542b 100644
    a b  
    1212#ifndef TOR_CIRCUITBUILD_H
    1313#define TOR_CIRCUITBUILD_H
    1414
     15extern int check_new_ip_addr_after_circuit_alive_again;
     16
    1517char *circuit_list_path(origin_circuit_t *circ, int verbose);
    1618char *circuit_list_path_for_controller(origin_circuit_t *circ);
    1719void circuit_log_path(int severity, unsigned int domain,
  • src/or/main.c

    diff --git a/src/or/main.c b/src/or/main.c
    index adc1f5d..855bb14 100644
    a b run_scheduled_events(time_t now) 
    14081408
    14091409  /* 2b. Once per minute, regenerate and upload the descriptor if the old
    14101410   * one is inaccurate. */
    1411   if (time_to_check_descriptor < now && !options->DisableNetwork) {
     1411  if ((time_to_check_descriptor < now ||
     1412       check_new_ip_addr_after_circuit_alive_again) &&
     1413      !options->DisableNetwork) {
    14121414    static int dirport_reachability_count = 0;
    14131415    time_to_check_descriptor = now + CHECK_DESCRIPTOR_INTERVAL;
    14141416    check_descriptor_bandwidth_changed(now);
    1415     if (time_to_check_ipaddress < now) {
     1417    if (time_to_check_ipaddress < now ||
     1418        check_new_ip_addr_after_circuit_alive_again) {
    14161419      time_to_check_ipaddress = now + CHECK_IPADDRESS_INTERVAL;
    14171420      check_descriptor_ipaddress_changed(now);
     1421      check_new_ip_addr_after_circuit_alive_again = 0;
    14181422    }
    14191423    mark_my_descriptor_dirty_if_too_old(now);
    14201424    consider_publishable_server(0);