Tor 0.4.9.13
Loading...
Searching...
No Matches
entrynodes.h
Go to the documentation of this file.
1/* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * \file entrynodes.h
9 * \brief Header file for circuitbuild.c.
10 **/
11
12#ifndef TOR_ENTRYNODES_H
13#define TOR_ENTRYNODES_H
14
16
17struct bridge_info_t;
18struct entry_guard_handle_t;
19
20/* Forward declare for guard_selection_t; entrynodes.c has the real struct */
21typedef struct guard_selection_t guard_selection_t;
22
23/* Forward declare for entry_guard_t; the real declaration is private. */
24typedef struct entry_guard_t entry_guard_t;
25
26/* Forward declaration for circuit_guard_state_t; the real declaration is
27 private. */
28typedef struct circuit_guard_state_t circuit_guard_state_t;
29
30/* Forward declaration for entry_guard_restriction_t; the real declaration is
31 private. */
32typedef struct entry_guard_restriction_t entry_guard_restriction_t;
33
34/** Information about a guard's pathbias status.
35 * These fields are used in circpathbias.c to try to detect entry
36 * nodes that are failing circuits at a suspicious frequency.
37 */
38typedef struct guard_pathbias_t {
39 unsigned int path_bias_noticed : 1; /**< Did we alert the user about path
40 * bias for this node already? */
41 unsigned int path_bias_warned : 1; /**< Did we alert the user about path bias
42 * for this node already? */
43 unsigned int path_bias_extreme : 1; /**< Did we alert the user about path
44 * bias for this node already? */
45 unsigned int path_bias_disabled : 1; /**< Have we disabled this node because
46 * of path bias issues? */
47 unsigned int path_bias_use_noticed : 1; /**< Did we alert the user about path
48 * use bias for this node already? */
49 unsigned int path_bias_use_extreme : 1; /**< Did we alert the user about path
50 * use bias for this node already? */
51
52 double circ_attempts; /**< Number of circuits this guard has "attempted" */
53 double circ_successes; /**< Number of successfully built circuits using
54 * this guard as first hop. */
55 double successful_circuits_closed; /**< Number of circuits that carried
56 * streams successfully. */
57 double collapsed_circuits; /**< Number of fully built circuits that were
58 * remotely closed before any streams were
59 * attempted. */
60 double unusable_circuits; /**< Number of circuits for which streams were
61 * attempted, but none succeeded. */
62 double timeouts; /**< Number of 'right-censored' circuit timeouts for this
63 * guard. */
64 double use_attempts; /**< Number of circuits we tried to use with streams */
65 double use_successes; /**< Number of successfully used circuits using
66 * this guard as first hop. */
68
69#if defined(ENTRYNODES_PRIVATE)
71
72/**
73 * @name values for entry_guard_t.is_reachable.
74 *
75 * See entry_guard_t.is_reachable for more information.
76 */
77/**@{*/
78#define GUARD_REACHABLE_NO 0
79#define GUARD_REACHABLE_YES 1
80#define GUARD_REACHABLE_MAYBE 2
81/**@}*/
82
83/** An entry_guard_t represents our information about a chosen long-term
84 * first hop, known as a "helper" node in the literature. We can't just
85 * use a node_t, since we want to remember these even when we
86 * don't have any directory info. */
87struct entry_guard_t {
88 HANDLE_ENTRY(entry_guard, entry_guard_t);
89
90 char nickname[MAX_HEX_NICKNAME_LEN+1];
91 char identity[DIGEST_LEN];
93
94 /**
95 * @name new guard selection algorithm fields.
96 *
97 * Only the new (prop271) algorithm uses these. For a more full
98 * description of the algorithm, see the module documentation for
99 * entrynodes.c
100 */
101 /**@{*/
102
103 /* == Persistent fields, present for all sampled guards. */
104 /** When was this guard added to the sample? */
105 time_t sampled_on_date;
106 /** Since what date has this guard been "unlisted"? A guard counts as
107 * unlisted if we have a live consensus that does not include it, or
108 * if we have a live consensus that does not include it as a usable
109 * guard. This field is zero when the guard is listed. */
110 time_t unlisted_since_date; // can be zero
111 /** What version of Tor added this guard to the sample? */
112 char *sampled_by_version;
113 /** Is this guard listed right now? If this is set, then
114 * unlisted_since_date should be set too. */
115 unsigned currently_listed : 1;
116
117 /* == Persistent fields, for confirmed guards only */
118 /** When was this guard confirmed? (That is, when did we first use it
119 * successfully and decide to keep it?) This field is zero if this is not a
120 * confirmed guard. */
121 time_t confirmed_on_date; /* 0 if not confirmed */
122 /**
123 * In what order was this guard sampled? Guards with
124 * lower indices appear earlier on the sampled list, the confirmed list and
125 * the primary list as a result of Prop 310
126 */
127 int sampled_idx;
128
129 /**
130 * In what order was this guard confirmed? Guards with lower indices
131 * appear earlier on the confirmed list. If the confirmed list is compacted,
132 * this field corresponds to the index of this guard on the confirmed list.
133 *
134 * This field is set to -1 if this guard is not confirmed.
135 */
136 int confirmed_idx; /* -1 if not confirmed; otherwise the order that this
137 * item should occur in the CONFIRMED_GUARDS ordered
138 * list */
139
140 /**
141 * Which selection does this guard belong to?
142 */
143 char *selection_name;
144
145 /** Bridges only: address of the bridge. */
146 tor_addr_port_t *bridge_addr;
147
148 /* ==== Non-persistent fields. */
149 /* == These are used by sampled guards */
150 /** When did we last decide to try using this guard for a circuit? 0 for
151 * "not since we started up." */
152 time_t last_tried_to_connect;
153 /** How reachable do we consider this guard to be? One of
154 * GUARD_REACHABLE_NO, GUARD_REACHABLE_YES, or GUARD_REACHABLE_MAYBE. */
155 unsigned is_reachable : 2;
156 /** Boolean: true iff this guard is pending. A pending guard is one
157 * that we have an in-progress circuit through, and which we do not plan
158 * to try again until it either succeeds or fails. Primary guards can
159 * never be pending. */
160 unsigned is_pending : 1;
161 /** If true, don't write this guard to disk. (Used for bridges with unknown
162 * identities) */
163 unsigned is_persistent : 1;
164 /** When did we get the earliest connection failure for this guard?
165 * We clear this field on a successful connect. We do _not_ clear it
166 * when we mark the guard as "MAYBE" reachable.
167 */
168 time_t failing_since;
169
170 /* == Set inclusion flags. */
171 /** If true, this guard is in the filtered set. The filtered set includes
172 * all sampled guards that our configuration allows us to use. */
173 unsigned is_filtered_guard : 1;
174 /** If true, this guard is in the usable filtered set. The usable filtered
175 * set includes all filtered guards that are not believed to be
176 * unreachable. (That is, those for which is_reachable is not
177 * GUARD_REACHABLE_NO) */
178 unsigned is_usable_filtered_guard : 1;
179 unsigned is_primary:1;
180
181 /** This string holds any fields that we are maintaining because
182 * we saw them in the state, even if we don't understand them. */
183 char *extra_state_fields;
184
185 /** Backpointer to the guard selection that this guard belongs to.
186 * The entry_guard_t must never outlive its guard_selection. */
187 guard_selection_t *in_selection;
188 /**@}*/
189
190 /** Path bias information for this guard. */
192};
193
194/**
195 * Possible rules for a guard selection to follow
196 */
197typedef enum guard_selection_type_t {
198 /** Infer the type of this selection from its name. */
199 GS_TYPE_INFER=0,
200 /** Use the normal guard selection algorithm, taking our sample from the
201 * complete list of guards in the consensus. */
202 GS_TYPE_NORMAL=1,
203 /** Use the normal guard selection algorithm, taking our sample from the
204 * configured bridges, and allowing it to grow as large as all the configured
205 * bridges */
206 GS_TYPE_BRIDGE,
207 /** Use the normal guard selection algorithm, taking our sample from the
208 * set of filtered nodes. */
209 GS_TYPE_RESTRICTED,
210} guard_selection_type_t;
211
212/**
213 * All of the the context for guard selection on a particular client.
214 *
215 * We maintain multiple guard selection contexts for a client, depending
216 * aspects on its current configuration -- whether an extremely
217 * restrictive EntryNodes is used, whether UseBridges is enabled, and so
218 * on.)
219 *
220 * See the module documentation for entrynodes.c for more information
221 * about guard selection algorithms.
222 */
223struct guard_selection_t {
224 /**
225 * The name for this guard-selection object. (Must not contain spaces).
226 */
227 char *name;
228
229 /**
230 * What rules does this guard-selection object follow?
231 */
232 guard_selection_type_t type;
233
234 /**
235 * A value of 1 means that primary_entry_guards is up-to-date with respect to
236 * the consensus and status info that we currently have; 0 means we need to
237 * recalculate it before using primary_entry_guards or the is_primary flag on
238 * any guard.
239 */
240 int primary_guards_up_to_date;
241
242 /**
243 * A list of the sampled entry guards, as entry_guard_t structures.
244 * Not in any particular order. When we 'sample' a guard, we are
245 * noting it as a possible guard to pick in the future. The use of
246 * sampling here prevents us from being forced by an attacker to try
247 * every guard on the network. This list is persistent.
248 */
249 smartlist_t *sampled_entry_guards;
250
251 /**
252 * Ordered list (from highest to lowest priority) of guards that we
253 * have successfully contacted and decided to use. Every member of
254 * this list is a member of sampled_entry_guards. Every member should
255 * have confirmed_on_date set.
256 * The ordering of the list should be by sampled idx. The reasoning behind
257 * it is linked to Proposal 310.
258 *
259 * This list is persistent. It is a subset of the elements in
260 * sampled_entry_guards, and its pointers point to elements of
261 * sampled_entry_guards.
262 */
263 smartlist_t *confirmed_entry_guards;
264
265 /**
266 * Ordered list (from highest to lowest priority) of guards that we
267 * are willing to use the most happily. These guards may or may not
268 * yet be confirmed yet. If we can use one of these guards, we are
269 * probably not on a network that is trying to restrict our guard
270 * choices.
271 *
272 * This list is a subset of the elements in
273 * sampled_entry_guards, and its pointers point to elements of
274 * sampled_entry_guards.
275 */
276 smartlist_t *primary_entry_guards;
277
278 /** When did we last successfully build a circuit or use a circuit? */
279 time_t last_time_on_internet;
280
281 /** What confirmed_idx value should the next-added member of
282 * confirmed_entry_guards receive? */
283 int next_confirmed_idx;
284
285 /** What sampled_idx value should the next-added member of
286 * sampled_entry_guards receive? This should follow the size of the sampled
287 * list until sampled relays get pruned for some reason
288 */
289 int next_sampled_idx;
290
291};
292
293/** Types of restrictions we impose when picking guard nodes */
294typedef enum guard_restriction_type_t {
295 /* Don't pick the same guard node as our exit node (or its family) */
296 RST_EXIT_NODE = 0,
297 /* Don't pick dirguards that have previously shown to be outdated */
298 RST_OUTDATED_MD_DIRSERVER = 1,
299 /* Don't pick guards if they are in the exclusion list */
300 RST_EXCL_LIST = 2,
301} guard_restriction_type_t;
302
303/**
304 * A restriction to remember which entry guards are off-limits for a given
305 * circuit.
306 *
307 * Note: This mechanism is NOT for recording which guards are never to be
308 * used: only which guards cannot be used on <em>one particular circuit</em>.
309 */
310struct entry_guard_restriction_t {
311 /* What type of restriction are we imposing? */
312 guard_restriction_type_t type;
313
314 /* In case of restriction type RST_EXIT_NODE, the guard's RSA identity
315 * digest must not equal this; and it must not be in the same family as any
316 * node with this digest. */
317 uint8_t exclude_id[DIGEST_LEN];
318
319 /* In the case of RST_EXCL_LIST, any identity digests in this list
320 * must not be used. */
321 smartlist_t *excluded;
322};
323
324/**
325 * Per-circuit state to track whether we'll be able to use the circuit.
326 */
327struct circuit_guard_state_t {
328 /** Handle to the entry guard object for this circuit. */
329 struct entry_guard_handle_t *guard;
330 /** The time at which <b>state</b> last changed. */
331 time_t state_set_at;
332 /** One of GUARD_CIRC_STATE_* */
333 uint8_t state;
334
335 /**
336 * A set of restrictions that were placed on this guard when we selected it
337 * for this particular circuit. We need to remember the restrictions here,
338 * since any guard that breaks these restrictions will not block this
339 * circuit from becoming COMPLETE.
340 */
341 entry_guard_restriction_t *restrictions;
342};
343#endif /* defined(ENTRYNODES_PRIVATE) */
344
345/* Common entry points for old and new guard code */
346int guards_update_all(void);
348 cpath_build_state_t *state,
349 uint8_t purpose,
350 circuit_guard_state_t **guard_state_out);
351const node_t *guards_choose_dirguard(uint8_t dir_purpose,
352 circuit_guard_state_t **guard_state_out);
353
354#if 1
355/* XXXX NM I would prefer that all of this stuff be private to
356 * entrynodes.c. */
358 guard_selection_t *gs, const char *digest);
359entry_guard_t *entry_guard_get_by_id_digest(const char *digest);
360
361circuit_guard_state_t *
363
364void entry_guards_changed_for_guard_selection(guard_selection_t *gs);
365void entry_guards_changed(void);
366guard_selection_t * get_guard_selection_info(void);
367int num_live_entry_guards_for_guard_selection(
368 guard_selection_t *gs,
369 int for_directory);
370int num_live_entry_guards(int for_directory);
371#endif /* 1 */
372
373const node_t *entry_guard_find_node(const entry_guard_t *guard);
374const char *entry_guard_get_rsa_id_digest(const entry_guard_t *guard);
375const char *entry_guard_describe(const entry_guard_t *guard);
377
378/** Enum to specify how we're going to use a given guard, when we're picking
379 * one for immediate use. */
380typedef enum {
381 GUARD_USAGE_TRAFFIC = 0,
382 GUARD_USAGE_DIRGUARD = 1
384
385#define circuit_guard_state_free(val) \
386 FREE_AND_NULL(circuit_guard_state_t, circuit_guard_state_free_, (val))
387
388void circuit_guard_state_free_(circuit_guard_state_t *state);
389int entry_guard_pick_for_circuit(guard_selection_t *gs,
390 guard_usage_t usage,
391 entry_guard_restriction_t *rst,
392 const node_t **chosen_node_out,
393 circuit_guard_state_t **guard_state_out);
394
395/* We just connected to an entry guard. What should we do with the circuit? */
396typedef enum {
397 GUARD_USABLE_NEVER = -1, /* Never use the circuit */
398 GUARD_MAYBE_USABLE_LATER = 0, /* Keep it. We might use it in the future */
399 GUARD_USABLE_NOW = 1, /* Use it right now */
400} guard_usable_t;
401
402guard_usable_t entry_guard_succeeded(circuit_guard_state_t **guard_state_p);
403void entry_guard_cancel(circuit_guard_state_t **guard_state_p);
404struct entry_guard_handle_t *entry_guard_handle_from_state(
405 const circuit_guard_state_t *state);
406void entry_guard_handle_release(struct entry_guard_handle_t *handle);
407void entry_guard_connection_failed(struct entry_guard_handle_t *handle);
408int entry_guards_update_all(guard_selection_t *gs);
409int entry_guards_upgrade_waiting_circuits(guard_selection_t *gs,
410 const smartlist_t *all_circuits,
411 smartlist_t *newly_complete_out);
412int entry_guard_state_should_expire(circuit_guard_state_t *guard_state);
413void entry_guards_note_internet_connectivity(guard_selection_t *gs);
414
416
417int entry_guard_could_succeed(const circuit_guard_state_t *guard_state);
418
419MOCK_DECL(int,num_bridges_usable,(int use_maybe_reachable));
420
421#ifdef ENTRYNODES_PRIVATE
422/**
423 * @name Default values for the parameters for the new (prop271) entry guard
424 * algorithm.
425 */
426/**@{*/
427/**
428 * We never let our sampled guard set grow larger than this percentage
429 * of the guards on the network.
430 */
431#define DFLT_MAX_SAMPLE_THRESHOLD_PERCENT 20
432/**
433 * We never let our sampled guard set grow larger than this number of
434 * guards.
435 */
436#define DFLT_MAX_SAMPLE_SIZE 60
437/**
438 * We always try to make our sample contain at least this many guards.
439 */
440#define DFLT_MIN_FILTERED_SAMPLE_SIZE 20
441/**
442 * If a guard is unlisted for this many days in a row, we remove it.
443 */
444#define DFLT_REMOVE_UNLISTED_GUARDS_AFTER_DAYS 20
445/**
446 * We remove unconfirmed guards from the sample after this many days,
447 * regardless of whether they are listed or unlisted.
448 */
449#define DFLT_GUARD_LIFETIME_DAYS 120
450/**
451 * We remove confirmed guards from the sample if they were sampled
452 * GUARD_LIFETIME_DAYS ago and confirmed this many days ago.
453 */
454#define DFLT_GUARD_CONFIRMED_MIN_LIFETIME_DAYS 60
455/**
456 * How many guards do we try to keep on our primary guard list?
457 */
458#define DFLT_N_PRIMARY_GUARDS 3
459/**
460 * Of the live guards on the primary guard list, how many do we consider when
461 * choosing a guard to use?
462 */
463#define DFLT_N_PRIMARY_GUARDS_TO_USE 1
464/**
465 * As DFLT_N_PRIMARY_GUARDS, but for choosing which directory guard to use.
466 */
467#define DFLT_N_PRIMARY_DIR_GUARDS_TO_USE 3
468/**
469 * If we haven't successfully built or used a circuit in this long, then
470 * consider that the internet is probably down.
471 */
472#define DFLT_INTERNET_LIKELY_DOWN_INTERVAL (10*60)
473/**
474 * If we're trying to connect to a nonprimary guard for at least this
475 * many seconds, and we haven't gotten the connection to work, we will treat
476 * lower-priority guards as usable.
477 */
478#define DFLT_NONPRIMARY_GUARD_CONNECT_TIMEOUT 15
479/**
480 * If a circuit has been sitting around in 'waiting for better guard' state
481 * for at least this long, we'll expire it.
482 */
483#define DFLT_NONPRIMARY_GUARD_IDLE_TIMEOUT (10*60)
484/**
485 * If our configuration retains fewer than this fraction of guards from the
486 * torrc, we are in a restricted setting.
487 */
488#define DFLT_MEANINGFUL_RESTRICTION_PERCENT 20
489/**
490 * If our configuration retains fewer than this fraction of guards from the
491 * torrc, we are in an extremely restricted setting, and should warn.
492 */
493#define DFLT_EXTREME_RESTRICTION_PERCENT 1
494/**@}*/
495
500STATIC int get_guard_lifetime(void);
509
510HANDLE_DECL(entry_guard, entry_guard_t, STATIC)
511#define entry_guard_handle_free(h) \
512 FREE_AND_NULL(entry_guard_handle_t, entry_guard_handle_free_, (h))
513
514STATIC guard_selection_type_t guard_selection_infer_type(
515 guard_selection_type_t type_in,
516 const char *name);
517STATIC guard_selection_t *guard_selection_new(const char *name,
518 guard_selection_type_t type);
519STATIC guard_selection_t *get_guard_selection_by_name(
520 const char *name, guard_selection_type_t type, int create_if_absent);
521STATIC void guard_selection_free_(guard_selection_t *gs);
522#define guard_selection_free(gs) \
523 FREE_AND_NULL(guard_selection_t, guard_selection_free_, (gs))
525 (guard_selection_t *gs, const entry_guard_t *guard));
526STATIC const char *choose_guard_selection(const or_options_t *options,
527 const networkstatus_t *ns,
528 const guard_selection_t *old_selection,
529 guard_selection_type_t *type_out);
530STATIC entry_guard_t *get_sampled_guard_with_id(guard_selection_t *gs,
531 const uint8_t *rsa_id);
532
533MOCK_DECL(STATIC time_t, randomize_time, (time_t now, time_t max_backdate));
534
535MOCK_DECL(STATIC circuit_guard_state_t *,
536 circuit_guard_state_new,(entry_guard_t *guard, unsigned state,
537 entry_guard_restriction_t *rst));
538
539STATIC entry_guard_t *entry_guard_add_to_sample(guard_selection_t *gs,
540 const node_t *node);
541STATIC entry_guard_t *entry_guards_expand_sample(guard_selection_t *gs);
542STATIC char *entry_guard_encode_for_state(entry_guard_t *guard, int
543 dense_sampled_index);
544STATIC entry_guard_t *entry_guard_parse_from_state(const char *s);
545#define entry_guard_free(e) \
546 FREE_AND_NULL(entry_guard_t, entry_guard_free_, (e))
547STATIC void entry_guard_free_(entry_guard_t *e);
548STATIC void entry_guards_update_filtered_sets(guard_selection_t *gs);
549STATIC int entry_guards_all_primary_guards_are_down(guard_selection_t *gs);
550/**
551 * @name Flags for first_reachable_filtered_entry_guard()
552 */
553/**@{*/
554#define SAMPLE_EXCLUDE_CONFIRMED (1u<<0)
555#define SAMPLE_EXCLUDE_PRIMARY (1u<<1)
556#define SAMPLE_EXCLUDE_PENDING (1u<<2)
557#define SAMPLE_NO_UPDATE_PRIMARY (1u<<3)
558#define SAMPLE_EXCLUDE_NO_DESCRIPTOR (1u<<4)
559/**@}*/
561 guard_selection_t *gs,
562 const entry_guard_restriction_t *rst,
563 unsigned flags);
564STATIC void entry_guard_consider_retry(entry_guard_t *guard);
565STATIC void make_guard_confirmed(guard_selection_t *gs, entry_guard_t *guard);
566STATIC void entry_guards_update_confirmed(guard_selection_t *gs);
567STATIC void entry_guards_update_primary(guard_selection_t *gs);
568STATIC int num_reachable_filtered_guards(const guard_selection_t *gs,
569 const entry_guard_restriction_t *rst);
570STATIC void sampled_guards_update_from_consensus(guard_selection_t *gs);
571/**
572 * @name Possible guard-states for a circuit.
573 */
574/**@{*/
575/** State for a circuit that can (so far as the guard subsystem is
576 * concerned) be used for actual traffic as soon as it is successfully
577 * opened. */
578#define GUARD_CIRC_STATE_USABLE_ON_COMPLETION 1
579/** State for an non-open circuit that we shouldn't use for actual
580 * traffic, when it completes, unless other circuits to preferable
581 * guards fail. */
582#define GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD 2
583/** State for an open circuit that we shouldn't use for actual traffic
584 * unless other circuits to preferable guards fail. */
585#define GUARD_CIRC_STATE_WAITING_FOR_BETTER_GUARD 3
586/** State for a circuit that can (so far as the guard subsystem is
587 * concerned) be used for actual traffic. */
588#define GUARD_CIRC_STATE_COMPLETE 4
589/** State for a circuit that is unusable, and will not become usable. */
590#define GUARD_CIRC_STATE_DEAD 5
591/**@}*/
592STATIC void entry_guards_note_guard_failure(guard_selection_t *gs,
593 entry_guard_t *guard);
594STATIC entry_guard_t *select_entry_guard_for_circuit(guard_selection_t *gs,
595 guard_usage_t usage,
596 const entry_guard_restriction_t *rst,
597 unsigned *state_out);
598STATIC void mark_primary_guards_maybe_reachable(guard_selection_t *gs);
599STATIC unsigned entry_guards_note_guard_success(guard_selection_t *gs,
600 entry_guard_t *guard,
601 unsigned old_state);
602STATIC int entry_guard_has_higher_priority(entry_guard_t *a, entry_guard_t *b);
603STATIC char *getinfo_helper_format_single_entry_guard(const entry_guard_t *e);
604
605STATIC entry_guard_restriction_t *guard_create_exit_restriction(
606 const uint8_t *exit_id);
607
608STATIC entry_guard_restriction_t *guard_create_dirserver_md_restriction(void);
609
610STATIC entry_guard_restriction_t * guard_create_conflux_restriction(
611 const origin_circuit_t *circ, const uint8_t *exit_id);
612
613STATIC void entry_guard_restriction_free_(entry_guard_restriction_t *rst);
614#define entry_guard_restriction_free(rst) \
615 FREE_AND_NULL(entry_guard_restriction_t, \
616 entry_guard_restriction_free_, (rst))
617
618#endif /* defined(ENTRYNODES_PRIVATE) */
619
620void remove_all_entry_guards_for_guard_selection(guard_selection_t *gs);
621void remove_all_entry_guards(void);
622
623struct bridge_info_t;
625 const uint8_t *rsa_id_digest);
626
627int entry_list_is_constrained(const or_options_t *options);
628int guards_retry_optimistic(const or_options_t *options);
629int entry_guards_parse_state_for_guard_selection(
630 guard_selection_t *gs, or_state_t *state, int set, char **msg);
631int entry_guards_parse_state(or_state_t *state, int set, char **msg);
634 const char *question, char **answer,
635 const char **errmsg);
636
637int entries_known_but_down(const or_options_t *options);
638void entries_retry_all(const or_options_t *options);
639
641 int num_present, int num_usable);
642char *guard_selection_get_err_str_if_dir_info_missing(guard_selection_t *gs,
643 int using_mds,
644 int num_present, int num_usable);
645
646void entry_guards_free_all(void);
647
648double pathbias_get_close_success_count(entry_guard_t *guard);
649double pathbias_get_use_success_count(entry_guard_t *guard);
650
651/** Contains the bandwidth of a relay as a guard and as a non-guard
652 * after the guardfraction has been considered. */
654 /** Bandwidth as a guard after guardfraction has been considered. */
656 /** Bandwidth as a non-guard after guardfraction has been considered. */
659
661
662void
663guard_get_guardfraction_bandwidth(guardfraction_bandwidth_t *guardfraction_bw,
664 int orig_bandwidth,
665 uint32_t guardfraction_percentage);
666
668const routerset_t *get_layer2_guards(void);
669void maintain_layer2_guards(void);
670void purge_vanguards_lite(void);
671
672#endif /* !defined(TOR_ENTRYNODES_H) */
const char * name
Definition config.c:2475
Header for crypto_ed25519.c.
#define DIGEST_LEN
STATIC int get_n_primary_guards(void)
Definition entrynodes.c:466
STATIC void entry_guards_update_primary(guard_selection_t *gs)
STATIC void entry_guards_note_guard_failure(guard_selection_t *gs, entry_guard_t *guard)
STATIC void guard_selection_free_(guard_selection_t *gs)
STATIC guard_selection_t * guard_selection_new(const char *name, guard_selection_type_t type)
Definition entrynodes.c:241
STATIC guard_selection_t * get_guard_selection_by_name(const char *name, guard_selection_type_t type, int create_if_absent)
Definition entrynodes.c:264
STATIC double get_meaningful_restriction_threshold(void)
Definition entrynodes.c:550
STATIC guard_selection_type_t guard_selection_infer_type(guard_selection_type_t type, const char *name)
Definition entrynodes.c:223
STATIC int get_nonprimary_guard_idle_timeout(void)
Definition entrynodes.c:538
STATIC void mark_primary_guards_maybe_reachable(guard_selection_t *gs)
Definition entrynodes.c:608
STATIC double get_extreme_restriction_threshold(void)
Definition entrynodes.c:563
STATIC circuit_guard_state_t * circuit_guard_state_new(entry_guard_t *guard, unsigned state, entry_guard_restriction_t *rst)
STATIC entry_guard_t * first_reachable_filtered_entry_guard(guard_selection_t *gs, const entry_guard_restriction_t *rst, unsigned flags)
STATIC int get_min_filtered_sample_size(void)
Definition entrynodes.c:404
STATIC void entry_guard_free_(entry_guard_t *e)
STATIC void entry_guard_restriction_free_(entry_guard_restriction_t *rst)
STATIC int get_guard_confirmed_min_lifetime(void)
Definition entrynodes.c:452
STATIC int entry_guard_has_higher_priority(entry_guard_t *a, entry_guard_t *b)
STATIC void entry_guards_update_confirmed(guard_selection_t *gs)
STATIC char * entry_guard_encode_for_state(entry_guard_t *guard, int dense_sampled_idx)
STATIC void entry_guards_update_filtered_sets(guard_selection_t *gs)
STATIC entry_guard_restriction_t * guard_create_dirserver_md_restriction(void)
STATIC int get_remove_unlisted_guards_after_days(void)
Definition entrynodes.c:414
STATIC int get_max_sample_size_absolute(void)
Definition entrynodes.c:394
STATIC int get_nonprimary_guard_connect_timeout(void)
Definition entrynodes.c:526
STATIC entry_guard_t * get_sampled_guard_with_id(guard_selection_t *gs, const uint8_t *rsa_id)
Definition entrynodes.c:805
STATIC unsigned entry_guards_note_guard_success(guard_selection_t *gs, entry_guard_t *guard, unsigned old_state)
STATIC int entry_guard_is_listed(guard_selection_t *gs, const entry_guard_t *guard)
STATIC void entry_guard_consider_retry(entry_guard_t *guard)
STATIC double get_max_sample_threshold(void)
Definition entrynodes.c:382
STATIC entry_guard_t * entry_guard_add_to_sample(guard_selection_t *gs, const node_t *node)
Definition entrynodes.c:868
STATIC int num_reachable_filtered_guards(const guard_selection_t *gs, const entry_guard_restriction_t *rst)
STATIC int entry_guards_all_primary_guards_are_down(guard_selection_t *gs)
STATIC time_t randomize_time(time_t now, time_t max_backdate)
Definition entrynodes.c:356
STATIC int get_n_primary_guards_to_use(guard_usage_t usage)
Definition entrynodes.c:486
STATIC const char * choose_guard_selection(const or_options_t *options, const networkstatus_t *live_ns, const guard_selection_t *old_selection, guard_selection_type_t *type_out)
Definition entrynodes.c:640
circuit_guard_state_t * get_guard_state_for_bridge_desc_fetch(const bridge_info_t *bridge)
STATIC char * getinfo_helper_format_single_entry_guard(const entry_guard_t *e)
STATIC void make_guard_confirmed(guard_selection_t *gs, entry_guard_t *guard)
STATIC entry_guard_t * entry_guard_parse_from_state(const char *s)
STATIC entry_guard_t * select_entry_guard_for_circuit(guard_selection_t *gs, guard_usage_t usage, const entry_guard_restriction_t *rst, unsigned *state_out)
STATIC int get_guard_lifetime(void)
Definition entrynodes.c:437
STATIC void sampled_guards_update_from_consensus(guard_selection_t *gs)
STATIC entry_guard_t * entry_guards_expand_sample(guard_selection_t *gs)
STATIC int get_internet_likely_down_interval(void)
Definition entrynodes.c:514
char * guard_selection_get_err_str_if_dir_info_missing(guard_selection_t *gs, int using_mds, int num_present, int num_usable)
const node_t * entry_guard_find_node(const entry_guard_t *guard)
void entry_guard_learned_bridge_identity(const tor_addr_port_t *addrport, const uint8_t *rsa_id_digest)
Definition entrynodes.c:981
const routerset_t * get_layer2_guards(void)
void entry_guards_changed(void)
void remove_all_entry_guards(void)
void purge_vanguards_lite(void)
void entry_guard_cancel(circuit_guard_state_t **guard_state_p)
entry_guard_t * entry_guard_get_by_id_digest(const char *digest)
void remove_all_entry_guards_for_guard_selection(guard_selection_t *gs)
int num_bridges_usable(int use_maybe_reachable)
void entry_guard_connection_failed(struct entry_guard_handle_t *handle)
int entry_guards_update_all(guard_selection_t *gs)
int entry_list_is_constrained(const or_options_t *options)
guard_usable_t entry_guard_succeeded(circuit_guard_state_t **guard_state_p)
void entry_guards_note_internet_connectivity(guard_selection_t *gs)
const char * entry_guard_get_rsa_id_digest(const entry_guard_t *guard)
Definition entrynodes.c:337
double pathbias_get_use_success_count(entry_guard_t *guard)
char * entry_guards_get_err_str_if_dir_info_missing(int using_mds, int num_present, int num_usable)
void entry_guards_update_state(or_state_t *state)
bool vanguards_lite_is_enabled(void)
struct entry_guard_handle_t * entry_guard_handle_from_state(const circuit_guard_state_t *state)
int update_guard_selection_choice(const or_options_t *options)
Definition entrynodes.c:746
void entry_guard_handle_release(struct entry_guard_handle_t *handle)
void circuit_guard_state_free_(circuit_guard_state_t *state)
int entry_guard_pick_for_circuit(guard_selection_t *gs, guard_usage_t usage, entry_guard_restriction_t *rst, const node_t **chosen_node_out, circuit_guard_state_t **guard_state_out)
void maintain_layer2_guards(void)
int entry_guards_parse_state(or_state_t *state, int set, char **msg)
int entry_guard_state_should_expire(circuit_guard_state_t *guard_state)
guard_pathbias_t * entry_guard_get_pathbias_state(entry_guard_t *guard)
Definition entrynodes.c:344
const node_t * guards_choose_guard(const origin_circuit_t *circ, cpath_build_state_t *state, uint8_t purpose, circuit_guard_state_t **guard_state_out)
int entry_guard_could_succeed(const circuit_guard_state_t *guard_state)
int guards_retry_optimistic(const or_options_t *options)
const node_t * guards_choose_dirguard(uint8_t dir_purpose, circuit_guard_state_t **guard_state_out)
int should_apply_guardfraction(const networkstatus_t *ns)
Definition entrynodes.c:190
void entry_guards_changed_for_guard_selection(guard_selection_t *gs)
int getinfo_helper_entry_guards(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
guard_selection_t * get_guard_selection_info(void)
Definition entrynodes.c:313
int guards_update_all(void)
guard_usage_t
Definition entrynodes.h:380
entry_guard_t * entry_guard_get_by_id_digest_for_guard_selection(guard_selection_t *gs, const char *digest)
const char * entry_guard_describe(const entry_guard_t *guard)
Definition entrynodes.c:325
int entry_guards_upgrade_waiting_circuits(guard_selection_t *gs, const smartlist_t *all_circuits, smartlist_t *newly_complete_out)
void entry_guards_free_all(void)
double pathbias_get_close_success_count(entry_guard_t *guard)
Macros for C weak-handle implementation.
#define MAX_HEX_NICKNAME_LEN
Definition or.h:115
unsigned int path_bias_use_noticed
Definition entrynodes.h:47
unsigned int path_bias_use_extreme
Definition entrynodes.h:49
double use_successes
Definition entrynodes.h:65
unsigned int path_bias_warned
Definition entrynodes.h:41
unsigned int path_bias_extreme
Definition entrynodes.h:43
double circ_attempts
Definition entrynodes.h:52
double collapsed_circuits
Definition entrynodes.h:57
double circ_successes
Definition entrynodes.h:53
unsigned int path_bias_disabled
Definition entrynodes.h:45
double unusable_circuits
Definition entrynodes.h:60
double successful_circuits_closed
Definition entrynodes.h:55
double use_attempts
Definition entrynodes.h:64
unsigned int path_bias_noticed
Definition entrynodes.h:39
#define STATIC
Definition testsupport.h:32
#define MOCK_DECL(rv, funcname, arglist)