Commit d46b8a3e authored by Roger Dingledine's avatar Roger Dingledine
Browse files

Stop being so aggressive about fetching dir info if your DirPort is

on but your ORPort is off.

Add a new config option BridgeRelay that specifies you want to
be a bridge relay. Right now the only difference is that it makes
you answer begin_dir requests, and it makes you cache dir info,
even if your DirPort isn't on.

Refactor directory_caches_dir_info() into some more functions.


svn:r12668
parent 4a03959b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ Changes in version 0.2.0.13-alpha - 2007-12-??
    - Stop thinking that 0.1.2.x directory servers can handle "begin_dir"
      requests. Should ease bugs 406 and 419 where 0.1.2.x relays are
      crashing or mis-answering these requests.
    - Stop being so aggressive about fetching dir info if your DirPort is
      on but your ORPort is off.

  o Minor bugfixes:
    - The fix in 0.2.0.12-alpha cleared the "hsdir" flag in v3 network
@@ -37,9 +39,13 @@ Changes in version 0.2.0.13-alpha - 2007-12-??
      consumers. (We already do this on HUP.)
    - Authorities and caches fetch the v2 networkstatus documents
      less often, now that v3 is encouraged.
    - Add a new config option BridgeRelay that specifies you want to
      be a bridge relay. Right now the only difference is that it makes
      you answer begin_dir requests, and it makes you cache dir info,
      even if your DirPort isn't on.

  o Code simplifications:
    - 
    - ????


Changes in version 0.2.0.12-alpha - 2007-11-16
+1 −1
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ command_process_relay_cell(cell_t *cell, or_connection_t *conn)
  }

  if (CIRCUIT_IS_ORIGIN(circ)) {
    /* if we're a server and treating connections with recent local
    /* if we're a relay and treating connections with recent local
     * traffic better, then this is one of them. */
    conn->client_used = time(NULL);
  }
+5 −2
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ static config_var_t _option_vars[] = {
  V(BandwidthRate,               MEMUNIT,  "5 MB"),
  V(BridgeAuthoritativeDir,      BOOL,     "0"),
  VAR("Bridge",                  LINELIST, Bridges,    NULL),
  V(BridgeRelay,                 BOOL,     "0"),
  V(CircuitBuildTimeout,         INTERVAL, "1 minute"),
  V(CircuitIdleTimeout,          INTERVAL, "1 hour"),
  V(ClientDNSRejectInternalAddresses, BOOL,"1"),
@@ -1132,8 +1133,10 @@ options_act(or_options_t *old_options)
  if (old_options) {
    if (authdir_mode_v3(options) && !authdir_mode_v3(old_options))
      dirvote_recalculate_timing(options, time(NULL));
    if (!bool_eq(directory_caches_dir_info(options),
                 directory_caches_dir_info(old_options))) {
    if (!bool_eq(directory_fetches_dir_info_like_mirror(options),
                 directory_fetches_dir_info_like_mirror(old_options)) ||
        !bool_eq(directory_fetches_dir_info_like_bridge_user(options),
                 directory_fetches_dir_info_like_bridge_user(old_options))) {
      /* Make sure update_router_have_min_dir_info gets called. */
      router_dir_info_changed();
      /* We might need to download a new consensus status later or sooner than
+1 −2
Original line number Diff line number Diff line
@@ -2292,8 +2292,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
      return 0;
    }
  } else if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
    or_options_t *options = get_options();
    if (!directory_permits_begindir_requests(options) ||
    if (!directory_permits_begindir_requests(get_options()) ||
        circ->purpose != CIRCUIT_PURPOSE_OR) {
      end_payload[0] = END_STREAM_REASON_NOTDIRECTORY;
      relay_send_command_from_edge(rh.stream_id, circ, RELAY_COMMAND_END,
+48 −12
Original line number Diff line number Diff line
@@ -1089,25 +1089,50 @@ dirserv_dump_directory_to_string(char **dir_out,
/********************************************************************/

/* A set of functions to answer questions about how we'd like to behave
 * as a directory cache/client. */
 * as a directory mirror/client. */

/** Return 1 if we want to keep descriptors, networkstatuses, etc around
 * and serve them to others, or 0 otherwise.
 * Also causes us to fetch new networkstatuses, descriptors, etc on the
 * "mirror" schedule rather than the "client" schedule.
/** Return 1 if we fetch our directory material directly from the
 * authorities, rather than from a mirror. */
int
directory_fetches_from_authorities(or_options_t *options)
{
  if (options->DirPort == 0)
    return 0;
  /* XXX if dirport not advertised, return 0 too */
  if (!server_mode(options))
    return 0;
  /* XXX if orport or dirport not reachable, return 0 too */
  return 1;
}

/* Return 1 if we should fetch new networkstatuses, descriptors, etc
 * on the "mirror" schedule rather than the "client" schedule.
 */
int
directory_caches_dir_info(or_options_t *options)
directory_fetches_dir_info_like_mirror(or_options_t *options)
{
  return options->DirPort != 0;
  return directory_fetches_from_authorities(options);
}

/** Return 1 if we fetch our directory material directly from the
 * authorities, rather than some other cache. */
/* Return 1 if we should fetch new networkstatuses, descriptors, etc
 * on a very passive schedule -- waiting long enough for ordinary clients
 * to probably have the info we want. These would include bridge users,
 * and maybe others in the future e.g. if a Tor client uses another Tor
 * client as a directory guard.
 */
int
directory_fetches_from_authorities(or_options_t *options)
directory_fetches_dir_info_like_bridge_user(or_options_t *options)
{
  return options->UseBridges != 0;
}

/** Return 1 if we want to keep descriptors, networkstatuses, etc around
 * and we're willing to serve them to others. Else return 0.
 */
int
directory_caches_dir_info(or_options_t *options)
{
  return server_mode(options) && options->DirPort != 0;
  return options->BridgeRelay != 0 || options->DirPort != 0;
}

/** Return 1 if we want to allow remote people to ask us directory
@@ -1116,7 +1141,7 @@ directory_fetches_from_authorities(or_options_t *options)
int
directory_permits_begindir_requests(or_options_t *options)
{
  return options->DirPort != 0;
  return options->BridgeRelay != 0 || options->DirPort != 0;
}

/** Return 1 if we want to allow controllers to ask us directory
@@ -1128,6 +1153,17 @@ directory_permits_controller_requests(or_options_t *options)
  return options->DirPort != 0;
}

/** Return 1 if we have no need to fetch new descriptors. This generally
 * happens when we're not a dir cache and we haven't built any circuits
 * lately.
 */
int
directory_too_idle_to_fetch_descriptors(or_options_t *options, time_t now)
{
  return !options->DirPort && !options->FetchUselessDescriptors &&
         rep_hist_circbuilding_dormant(now);
}

/********************************************************************/

/* Used only by non-v1-auth dirservers: The v1 directory and
Loading