Commit c74542c5 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

Add accessors as needed to repair compilation

The previous commit, in moving a bunch of functions to bridges.c,
broke compilation because bridges.c required two entry points to
entrynodes.c it didn't have.
parent 8da24c99
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ typedef struct {
} bridge_info_t;

static void bridge_free(bridge_info_t *bridge);
static int num_bridges_usable(void);

/** A list of configured bridges. Whenever we actually get a descriptor
 * for one, we add it as an entry guard.  Note that the order of bridges
@@ -719,7 +718,7 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
                   fmt_and_decorate_addr(&bridge->addr),
                   (int) bridge->port);
      }
      add_an_entry_guard(get_guard_selection_info(), node, 1, 1, 0, 0);
      add_bridge_as_entry_guard(get_guard_selection_info(), node);

      log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname,
                 from_cache ? "cached" : "fresh", router_describe(ri));
@@ -747,19 +746,6 @@ any_bridge_descriptors_known(void)
  return choose_random_entry(NULL) != NULL;
}

/** Return the number of bridges that have descriptors that are marked with
 * purpose 'bridge' and are running.
 */
static int
num_bridges_usable(void)
{
  int n_options = 0;
  tor_assert(get_options()->UseBridges);
  (void) choose_random_entry_impl(get_guard_selection_info(),
                                  NULL, 0, 0, &n_options);
  return n_options;
}

/** Return a smartlist containing all bridge identity digests */
MOCK_IMPL(smartlist_t *,
list_bridge_identities, (void))
+23 −0
Original line number Diff line number Diff line
@@ -893,6 +893,16 @@ add_an_entry_guard(guard_selection_t *gs,
  return node;
}

/** Entry point for bridges.c to add a bridge as guard.
 *
 * XXXX prop271 refactor.*/
void
add_bridge_as_entry_guard(guard_selection_t *gs,
                          const node_t *chosen)
{
  add_an_entry_guard(gs, chosen, 1, 1, 0, 0);
}

/** Choose how many entry guards or directory guards we'll use. If
 * <b>for_directory</b> is true, we return how many directory guards to
 * use; else we return how many entry guards to use. */
@@ -1490,6 +1500,19 @@ choose_random_dirguard(dirinfo_type_t type)
                                  NULL, 1, type, NULL);
}

/** Return the number of bridges that have descriptors that are marked with
 * purpose 'bridge' and are running.
 */
int
num_bridges_usable(void)
{
  int n_options = 0;
  tor_assert(get_options()->UseBridges);
  (void) choose_random_entry_impl(get_guard_selection_info(),
                                  NULL, 0, 0, &n_options);
  return n_options;
}

/** Filter <b>all_entry_guards</b> for usable entry guards and put them
 * in <b>live_entry_guards</b>. We filter based on whether the node is
 * currently alive, and on whether it satisfies the restrictions
+5 −0
Original line number Diff line number Diff line
@@ -154,6 +154,11 @@ const char *entry_guard_get_rsa_id_digest(const entry_guard_t *guard);
const char *entry_guard_describe(const entry_guard_t *guard);
guard_pathbias_t *entry_guard_get_pathbias_state(entry_guard_t *guard);

/* Used by bridges.c only. */
void add_bridge_as_entry_guard(guard_selection_t *gs,
                               const node_t *chosen);
int num_bridges_usable(void);

#ifdef ENTRYNODES_PRIVATE
STATIC time_t randomize_time(time_t now, time_t max_backdate);
STATIC void entry_guard_add_to_sample(guard_selection_t *gs,