Tor  0.4.5.0-alpha-dev
bridges.c
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-2020, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file bridges.c
9  * \brief Code to manage bridges and bridge selection.
10  *
11  * Bridges are fixed entry nodes, used for censorship circumvention.
12  **/
13 
14 #define TOR_BRIDGES_PRIVATE
15 
16 #include "core/or/or.h"
17 #include "app/config/config.h"
19 #include "core/or/circuitbuild.h"
20 #include "core/or/policies.h"
21 #include "feature/client/bridges.h"
33 
34 #include "core/or/extend_info_st.h"
39 
40 /** Information about a configured bridge. Currently this just matches the
41  * ones in the torrc file, but one day we may be able to learn about new
42  * bridges on our own, and remember them in the state file. */
43 struct bridge_info_t {
44  /** Address and port of the bridge, as configured by the user.*/
46  /** Address of the bridge. */
48  /** TLS port for the bridge. */
49  uint16_t port;
50  /** Boolean: We are re-parsing our bridge list, and we are going to remove
51  * this one if we don't find it in the list of configured bridges. */
52  unsigned marked_for_removal : 1;
53  /** Expected identity digest, or all zero bytes if we don't know what the
54  * digest should be. */
56 
57  /** Name of pluggable transport protocol taken from its config line. */
59 
60  /** When should we next try to fetch a descriptor for this bridge? */
62 
63  /** A smartlist of k=v values to be passed to the SOCKS proxy, if
64  transports are used for this bridge. */
66 };
67 
68 #define bridge_free(bridge) \
69  FREE_AND_NULL(bridge_info_t, bridge_free_, (bridge))
70 
71 static void bridge_free_(bridge_info_t *bridge);
72 static void rewrite_node_address_for_bridge(const bridge_info_t *bridge,
73  node_t *node);
74 
75 /** A list of configured bridges. Whenever we actually get a descriptor
76  * for one, we add it as an entry guard. Note that the order of bridges
77  * in this list does not necessarily correspond to the order of bridges
78  * in the torrc. */
79 static smartlist_t *bridge_list = NULL;
80 
81 /** Mark every entry of the bridge list to be removed on our next call to
82  * sweep_bridge_list unless it has first been un-marked. */
83 void
85 {
86  if (!bridge_list)
89  b->marked_for_removal = 1);
90 }
91 
92 /** Remove every entry of the bridge list that was marked with
93  * mark_bridge_list if it has not subsequently been un-marked. */
94 void
96 {
97  if (!bridge_list)
100  if (b->marked_for_removal) {
102  bridge_free(b);
103  }
104  } SMARTLIST_FOREACH_END(b);
105 }
106 
107 /** Initialize the bridge list to empty, creating it if needed. */
108 STATIC void
110 {
111  if (!bridge_list)
113  SMARTLIST_FOREACH(bridge_list, bridge_info_t *, b, bridge_free(b));
115 }
116 
117 /** Free the bridge <b>bridge</b>. */
118 static void
120 {
121  if (!bridge)
122  return;
123 
124  tor_free(bridge->transport_name);
125  if (bridge->socks_args) {
126  SMARTLIST_FOREACH(bridge->socks_args, char*, s, tor_free(s));
127  smartlist_free(bridge->socks_args);
128  }
129 
130  tor_free(bridge);
131 }
132 
133 /** Return a list of all the configured bridges, as bridge_info_t pointers. */
134 const smartlist_t *
136 {
137  if (!bridge_list)
139  return bridge_list;
140 }
141 
142 /**
143  * Given a <b>bridge</b>, return a pointer to its RSA identity digest, or
144  * NULL if we don't know one for it.
145  */
146 const uint8_t *
148 {
149  tor_assert(bridge);
150  if (tor_digest_is_zero(bridge->identity))
151  return NULL;
152  else
153  return (const uint8_t *) bridge->identity;
154 }
155 
156 /**
157  * Given a <b>bridge</b>, return a pointer to its configured addr:port
158  * combination.
159  */
160 const tor_addr_port_t *
162 {
163  tor_assert(bridge);
164  return &bridge->addrport_configured;
165 }
166 
167 /** If we have a bridge configured whose digest matches <b>digest</b>, or a
168  * bridge with no known digest whose address matches any of the
169  * tor_addr_port_t's in <b>orports</b>, return that bridge. Else return
170  * NULL. */
173  const smartlist_t *orports)
174 {
175  if (!bridge_list)
176  return NULL;
178  {
179  if (tor_digest_is_zero(bridge->identity)) {
181  {
182  if (tor_addr_compare(&bridge->addr, &ap->addr, CMP_EXACT) == 0 &&
183  bridge->port == ap->port)
184  return bridge;
185  }
186  SMARTLIST_FOREACH_END(ap);
187  }
188  if (digest && tor_memeq(bridge->identity, digest, DIGEST_LEN))
189  return bridge;
190  }
191  SMARTLIST_FOREACH_END(bridge);
192  return NULL;
193 }
194 
195 /** If we have a bridge configured whose digest matches <b>digest</b>, or a
196  * bridge with no known digest whose address matches <b>addr</b>:<b>port</b>,
197  * return that bridge. Else return NULL. If <b>digest</b> is NULL, check for
198  * address/port matches only. */
201  uint16_t port,
202  const char *digest)
203 {
204  if (!bridge_list)
205  return NULL;
207  {
208  if ((tor_digest_is_zero(bridge->identity) || digest == NULL) &&
209  !tor_addr_compare(&bridge->addr, addr, CMP_EXACT) &&
210  bridge->port == port)
211  return bridge;
212  if (digest && tor_memeq(bridge->identity, digest, DIGEST_LEN))
213  return bridge;
214  }
215  SMARTLIST_FOREACH_END(bridge);
216  return NULL;
217 }
218 
219 /**
220  * As get_configured_bridge_by_addr_port, but require that the
221  * address match <b>addr</b>:<b>port</b>, and that the ID digest match
222  * <b>digest</b>. (The other function will ignore the address if the
223  * digest matches.)
224  */
227  uint16_t port,
228  const char *digest)
229 {
230  if (!bridge_list)
231  return NULL;
233  if (!tor_addr_compare(&bridge->addr, addr, CMP_EXACT) &&
234  bridge->port == port) {
235 
236  if (digest && tor_memeq(bridge->identity, digest, DIGEST_LEN))
237  return bridge;
238  else if (!digest || tor_digest_is_zero(bridge->identity))
239  return bridge;
240  }
241 
242  } SMARTLIST_FOREACH_END(bridge);
243  return NULL;
244 }
245 
246 /** If we have a bridge configured whose digest matches <b>digest</b>, or a
247  * bridge with no known digest whose address matches <b>addr</b>:<b>port</b>,
248  * return 1. Else return 0. If <b>digest</b> is NULL, check for
249  * address/port matches only. */
250 int
252  uint16_t port,
253  const char *digest)
254 {
255  tor_assert(addr);
256  return get_configured_bridge_by_addr_port_digest(addr, port, digest) ? 1 : 0;
257 }
258 
259 /** If we have a bridge configured whose digest matches
260  * <b>ei->identity_digest</b>, or a bridge with no known digest whose address
261  * matches <b>ei->addr</b>:<b>ei->port</b>, return 1. Else return 0.
262  * If <b>ei->onion_key</b> is NULL, check for address/port matches only.
263  *
264  * Note that if the extend_info_t contains multiple addresses, we return true
265  * only if _every_ address is a bridge.
266  */
267 int
269 {
270  const char *digest = ei->onion_key ? ei->identity_digest : NULL;
271  const tor_addr_port_t *ap1 = NULL, *ap2 = NULL;
272  if (! tor_addr_is_null(&ei->orports[0].addr))
273  ap1 = &ei->orports[0];
274  if (! tor_addr_is_null(&ei->orports[1].addr))
275  ap2 = &ei->orports[1];
276  IF_BUG_ONCE(ap1 == NULL) {
277  return 0;
278  }
279  return addr_is_a_configured_bridge(&ap1->addr, ap1->port, digest) &&
280  (ap2 == NULL ||
281  addr_is_a_configured_bridge(&ap2->addr, ap2->port, digest));
282 }
283 
284 /** Wrapper around get_configured_bridge_by_addr_port_digest() to look
285  * it up via router descriptor <b>ri</b>. */
286 static bridge_info_t *
288 {
289  bridge_info_t *bi = NULL;
290  smartlist_t *orports = router_get_all_orports(ri);
292  orports);
293  SMARTLIST_FOREACH(orports, tor_addr_port_t *, p, tor_free(p));
294  smartlist_free(orports);
295  return bi;
296 }
297 
298 /** Return 1 if <b>ri</b> is one of our known bridges, else 0. */
299 int
301 {
302  return get_configured_bridge_by_routerinfo(ri) ? 1 : 0;
303 }
304 
305 /**
306  * Return 1 iff <b>bridge_list</b> contains entry matching given
307  * <b>addr</b> and <b>port</b> (and no identity digest) OR
308  * it contains an entry whose identity matches <b>digest</b>.
309  * Otherwise, return 0.
310  */
311 static int
313  const uint16_t port,
314  const char *digest)
315 {
316  if (!tor_addr_port_is_valid(addr, port, 0))
317  return 0;
318 
319  bridge_info_t *bridge =
320  get_configured_bridge_by_addr_port_digest(addr, port, digest);
321 
322  return (bridge != NULL);
323 }
324 
325 /** Return 1 if <b>node</b> is one of our configured bridges, else 0.
326  * More specifically, return 1 iff: a bridge_info_t object exists in
327  * <b>bridge_list</b> such that: 1) It's identity is equal to node
328  * identity OR 2) It's identity digest is zero, but it matches
329  * address and port of any ORPort in the node.
330  */
331 int
333 {
334  /* First, let's try searching for a bridge with matching identity. */
335  if (BUG(fast_mem_is_zero(node->identity, DIGEST_LEN)))
336  return 0;
337 
338  if (find_bridge_by_digest(node->identity) != NULL)
339  return 1;
340 
341  /* At this point, we have established that no bridge exists with
342  * matching identity digest. However, we still pass it into
343  * bridge_exists_* functions because we want further code to
344  * check for absence of identity digest in a bridge.
345  */
346  if (node->ri) {
348  node->ri->ipv4_orport,
349  node->identity))
350  return 1;
351 
353  node->ri->ipv6_orport,
354  node->identity))
355  return 1;
356  } else if (node->rs) {
357  if (bridge_exists_with_addr_and_port(&node->rs->ipv4_addr,
358  node->rs->ipv4_orport,
359  node->identity))
360  return 1;
361 
363  node->rs->ipv6_orport,
364  node->identity))
365  return 1;
366  } else if (node->md) {
368  node->md->ipv6_orport,
369  node->identity))
370  return 1;
371  }
372 
373  return 0;
374 }
375 
376 /** We made a connection to a router at <b>addr</b>:<b>port</b>
377  * without knowing its digest. Its digest turned out to be <b>digest</b>.
378  * If it was a bridge, and we still don't know its digest, record it.
379  */
380 void
381 learned_router_identity(const tor_addr_t *addr, uint16_t port,
382  const char *digest,
383  const ed25519_public_key_t *ed_id)
384 {
385  // XXXX prop220 use ed_id here, once there is some way to specify
386  (void)ed_id;
387  int learned = 0;
388  bridge_info_t *bridge =
390  if (bridge && tor_digest_is_zero(bridge->identity)) {
391  memcpy(bridge->identity, digest, DIGEST_LEN);
392  learned = 1;
393  }
394  /* XXXX prop220 remember bridge ed25519 identities -- add a field */
395 #if 0
396  if (bridge && ed_id &&
397  ed25519_public_key_is_zero(&bridge->ed25519_identity) &&
398  !ed25519_public_key_is_zero(ed_id)) {
399  memcpy(&bridge->ed25519_identity, ed_id, sizeof(*ed_id));
400  learned = 1;
401  }
402 #endif /* 0 */
403  if (learned) {
404  char *transport_info = NULL;
405  const char *transport_name =
407  if (transport_name)
408  tor_asprintf(&transport_info, " (with transport '%s')", transport_name);
409 
410  // XXXX prop220 log both fingerprints.
411  log_notice(LD_DIR, "Learned fingerprint %s for bridge %s%s.",
412  hex_str(digest, DIGEST_LEN), fmt_addrport(addr, port),
413  transport_info ? transport_info : "");
414  tor_free(transport_info);
416  (const uint8_t *)digest);
417  }
418 }
419 
420 /** Return true if <b>bridge</b> has the same identity digest as
421  * <b>digest</b>. If <b>digest</b> is NULL, it matches
422  * bridges with unspecified identity digests. */
423 static int
424 bridge_has_digest(const bridge_info_t *bridge, const char *digest)
425 {
426  if (digest)
427  return tor_memeq(digest, bridge->identity, DIGEST_LEN);
428  else
429  return tor_digest_is_zero(bridge->identity);
430 }
431 
432 /** We are about to add a new bridge at <b>addr</b>:<b>port</b>, with optional
433  * <b>digest</b> and <b>transport_name</b>. Mark for removal any previously
434  * existing bridge with the same address and port, and warn the user as
435  * appropriate.
436  */
437 STATIC void
438 bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
439  const char *digest, const char *transport_name)
440 {
441  /* Iterate the already-registered bridge list:
442 
443  If you find a bridge with the same address and port, mark it for
444  removal. It doesn't make sense to have two active bridges with
445  the same IP:PORT. If the bridge in question has a different
446  digest or transport than <b>digest</b>/<b>transport_name</b>,
447  it's probably a misconfiguration and we should warn the user.
448  */
450  if (bridge->marked_for_removal)
451  continue;
452 
453  if (tor_addr_eq(&bridge->addr, addr) && (bridge->port == port)) {
454 
455  bridge->marked_for_removal = 1;
456 
457  if (!bridge_has_digest(bridge, digest) ||
458  strcmp_opt(bridge->transport_name, transport_name)) {
459  /* warn the user */
460  char *bridge_description_new, *bridge_description_old;
461  tor_asprintf(&bridge_description_new, "%s:%s:%s",
462  fmt_addrport(addr, port),
463  digest ? hex_str(digest, DIGEST_LEN) : "",
464  transport_name ? transport_name : "");
465  tor_asprintf(&bridge_description_old, "%s:%s:%s",
466  fmt_addrport(&bridge->addr, bridge->port),
467  tor_digest_is_zero(bridge->identity) ?
468  "" : hex_str(bridge->identity,DIGEST_LEN),
469  bridge->transport_name ? bridge->transport_name : "");
470 
471  log_warn(LD_GENERAL,"Tried to add bridge '%s', but we found a conflict"
472  " with the already registered bridge '%s'. We will discard"
473  " the old bridge and keep '%s'. If this is not what you"
474  " wanted, please change your configuration file accordingly.",
475  bridge_description_new, bridge_description_old,
476  bridge_description_new);
477 
478  tor_free(bridge_description_new);
479  tor_free(bridge_description_old);
480  }
481  }
482  } SMARTLIST_FOREACH_END(bridge);
483 }
484 
485 /** Return True if we have a bridge that uses a transport with name
486  * <b>transport_name</b>. */
487 MOCK_IMPL(int,
488 transport_is_needed, (const char *transport_name))
489 {
490  if (!bridge_list)
491  return 0;
492 
494  if (bridge->transport_name &&
495  !strcmp(bridge->transport_name, transport_name))
496  return 1;
497  } SMARTLIST_FOREACH_END(bridge);
498 
499  return 0;
500 }
501 
502 /** Register the bridge information in <b>bridge_line</b> to the
503  * bridge subsystem. Steals reference of <b>bridge_line</b>. */
504 void
506 {
507  bridge_info_t *b;
508 
509  // XXXX prop220 add a way to specify ed25519 ID to bridge_line_t.
510 
511  { /* Log the bridge we are about to register: */
512  log_debug(LD_GENERAL, "Registering bridge at %s (transport: %s) (%s)",
513  fmt_addrport(&bridge_line->addr, bridge_line->port),
514  bridge_line->transport_name ?
515  bridge_line->transport_name : "no transport",
516  tor_digest_is_zero(bridge_line->digest) ?
517  "no key listed" : hex_str(bridge_line->digest, DIGEST_LEN));
518 
519  if (bridge_line->socks_args) { /* print socks arguments */
520  int i = 0;
521 
522  tor_assert(smartlist_len(bridge_line->socks_args) > 0);
523 
524  log_debug(LD_GENERAL, "Bridge uses %d SOCKS arguments:",
525  smartlist_len(bridge_line->socks_args));
526  SMARTLIST_FOREACH(bridge_line->socks_args, const char *, arg,
527  log_debug(LD_CONFIG, "%d: %s", ++i, arg));
528  }
529  }
530 
531  bridge_resolve_conflicts(&bridge_line->addr,
532  bridge_line->port,
533  bridge_line->digest,
534  bridge_line->transport_name);
535 
536  b = tor_malloc_zero(sizeof(bridge_info_t));
537  tor_addr_copy(&b->addrport_configured.addr, &bridge_line->addr);
538  b->addrport_configured.port = bridge_line->port;
539  tor_addr_copy(&b->addr, &bridge_line->addr);
540  b->port = bridge_line->port;
541  memcpy(b->identity, bridge_line->digest, DIGEST_LEN);
542  if (bridge_line->transport_name)
543  b->transport_name = bridge_line->transport_name;
544  b->fetch_status.schedule = DL_SCHED_BRIDGE;
545  b->fetch_status.increment_on = DL_SCHED_INCREMENT_ATTEMPT;
546  /* We can't reset the bridge's download status here, because UseBridges
547  * might be 0 now, and it might be changed to 1 much later. */
548  b->socks_args = bridge_line->socks_args;
549  if (!bridge_list)
551 
552  tor_free(bridge_line); /* Deallocate bridge_line now. */
553 
555 }
556 
557 /** If <b>digest</b> is one of our known bridges, return it. */
559 find_bridge_by_digest(const char *digest)
560 {
561  if (! bridge_list)
562  return NULL;
564  {
565  if (tor_memeq(bridge->identity, digest, DIGEST_LEN))
566  return bridge;
567  });
568  return NULL;
569 }
570 
571 /** Given the <b>addr</b> and <b>port</b> of a bridge, if that bridge
572  * supports a pluggable transport, return its name. Otherwise, return
573  * NULL. */
574 const char *
576 {
577  if (!bridge_list)
578  return NULL;
579 
581  if (tor_addr_eq(&bridge->addr, addr) &&
582  (bridge->port == port))
583  return bridge->transport_name;
584  } SMARTLIST_FOREACH_END(bridge);
585 
586  return NULL;
587 }
588 
589 /** If <b>addr</b> and <b>port</b> match the address and port of a
590  * bridge of ours that uses pluggable transports, place its transport
591  * in <b>transport</b>.
592  *
593  * Return 0 on success (found a transport, or found a bridge with no
594  * transport, or found no bridge); return -1 if we should be using a
595  * transport, but the transport could not be found.
596  */
597 int
598 get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
599  const transport_t **transport)
600 {
601  *transport = NULL;
602  if (!bridge_list)
603  return 0;
604 
606  if (tor_addr_eq(&bridge->addr, addr) &&
607  (bridge->port == port)) { /* bridge matched */
608  if (bridge->transport_name) { /* it also uses pluggable transports */
609  *transport = transport_get_by_name(bridge->transport_name);
610  if (*transport == NULL) { /* it uses pluggable transports, but
611  the transport could not be found! */
612  return -1;
613  }
614  return 0;
615  } else { /* bridge matched, but it doesn't use transports. */
616  break;
617  }
618  }
619  } SMARTLIST_FOREACH_END(bridge);
620 
621  *transport = NULL;
622  return 0;
623 }
624 
625 /** Return a smartlist containing all the SOCKS arguments that we
626  * should pass to the SOCKS proxy. */
627 const smartlist_t *
629 {
631  port,
632  NULL);
633  return bridge ? bridge->socks_args : NULL;
634 }
635 
636 /** We need to ask <b>bridge</b> for its server descriptor. */
637 static void
639 {
640  const or_options_t *options = get_options();
641  circuit_guard_state_t *guard_state = NULL;
642 
644  CONN_TYPE_DIR, &bridge->addr, bridge->port,
646  return; /* it's already on the way */
647 
648  if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
650  log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
651  safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
652  return;
653  }
654 
655  /* Until we get a descriptor for the bridge, we only know one address for
656  * it. */
657  if (!fascist_firewall_allows_address_addr(&bridge->addr, bridge->port,
658  FIREWALL_OR_CONNECTION, 0, 0)) {
659  log_notice(LD_CONFIG, "Tried to fetch a descriptor directly from a "
660  "bridge, but that bridge is not reachable through our "
661  "firewall.");
662  return;
663  }
664 
665  /* If we already have a node_t for this bridge, rewrite its address now. */
666  node_t *node = node_get_mutable_by_id(bridge->identity);
667  if (node) {
668  rewrite_node_address_for_bridge(bridge, node);
669  }
670 
671  tor_addr_port_t bridge_addrport;
672  memcpy(&bridge_addrport.addr, &bridge->addr, sizeof(tor_addr_t));
673  bridge_addrport.port = bridge->port;
674 
675  guard_state = get_guard_state_for_bridge_desc_fetch(bridge->identity);
676 
677  directory_request_t *req =
679  directory_request_set_or_addr_port(req, &bridge_addrport);
682  directory_request_set_resource(req, "authority.z");
683  if (guard_state) {
684  directory_request_set_guard_state(req, guard_state);
685  }
687  directory_request_free(req);
688 }
689 
690 /** Fetching the bridge descriptor from the bridge authority returned a
691  * "not found". Fall back to trying a direct fetch. */
692 void
694 {
695  bridge_info_t *bridge = find_bridge_by_digest(digest);
696  if (!bridge)
697  return; /* not found? oh well. */
698 
700 }
701 
702 /** For each bridge in our list for which we don't currently have a
703  * descriptor, fetch a new copy of its descriptor -- either directly
704  * from the bridge or via a bridge authority. */
705 void
706 fetch_bridge_descriptors(const or_options_t *options, time_t now)
707 {
708  int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO);
709  int ask_bridge_directly;
710  int can_use_bridge_authority;
711 
712  if (!bridge_list)
713  return;
714 
715  /* If we still have unconfigured managed proxies, don't go and
716  connect to a bridge. */
718  return;
719 
721  {
722  /* This resets the download status on first use */
723  if (!download_status_is_ready(&bridge->fetch_status, now))
724  continue; /* don't bother, no need to retry yet */
725  if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
726  download_status_mark_impossible(&bridge->fetch_status);
727  log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
728  safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
729  continue;
730  }
731 
732  /* schedule the next attempt
733  * we can't increment after a failure, because sometimes we use the
734  * bridge authority, and sometimes we use the bridge direct */
736  &bridge->fetch_status,
737  safe_str_client(fmt_and_decorate_addr(&bridge->addr)),
738  now);
739 
740  can_use_bridge_authority = !tor_digest_is_zero(bridge->identity) &&
741  num_bridge_auths;
742  ask_bridge_directly = !can_use_bridge_authority ||
743  !options->UpdateBridgesFromAuthority;
744  log_debug(LD_DIR, "ask_bridge_directly=%d (%d, %d, %d)",
745  ask_bridge_directly, tor_digest_is_zero(bridge->identity),
746  !options->UpdateBridgesFromAuthority, !num_bridge_auths);
747 
748  if (ask_bridge_directly &&
749  !fascist_firewall_allows_address_addr(&bridge->addr, bridge->port,
750  FIREWALL_OR_CONNECTION, 0,
751  0)) {
752  log_notice(LD_DIR, "Bridge at '%s' isn't reachable by our "
753  "firewall policy. %s.",
754  fmt_addrport(&bridge->addr, bridge->port),
755  can_use_bridge_authority ?
756  "Asking bridge authority instead" : "Skipping");
757  if (can_use_bridge_authority)
758  ask_bridge_directly = 0;
759  else
760  continue;
761  }
762 
763  if (ask_bridge_directly) {
764  /* we need to ask the bridge itself for its descriptor. */
766  } else {
767  /* We have a digest and we want to ask an authority. We could
768  * combine all the requests into one, but that may give more
769  * hints to the bridge authority than we want to give. */
770  char resource[10 + HEX_DIGEST_LEN];
771  memcpy(resource, "fp/", 3);
772  base16_encode(resource+3, HEX_DIGEST_LEN+1,
773  bridge->identity, DIGEST_LEN);
774  memcpy(resource+3+HEX_DIGEST_LEN, ".z", 3);
775  log_info(LD_DIR, "Fetching bridge info '%s' from bridge authority.",
776  resource);
778  ROUTER_PURPOSE_BRIDGE, resource, 0, DL_WANT_AUTHORITY);
779  }
780  }
781  SMARTLIST_FOREACH_END(bridge);
782 }
783 
784 /** If our <b>bridge</b> is configured to be a different address than
785  * the bridge gives in <b>node</b>, rewrite the routerinfo
786  * we received to use the address we meant to use. Now we handle
787  * multihomed bridges better.
788  */
789 static void
791 {
792  /* XXXX move this function. */
793  /* XXXX overridden addresses should really live in the node_t, so that the
794  * routerinfo_t and the microdesc_t can be immutable. But we can only
795  * do that safely if we know that no function that connects to an OR
796  * does so through an address from any source other than node_get_addr().
797  */
798  const or_options_t *options = get_options();
799 
800  if (node->ri) {
801  routerinfo_t *ri = node->ri;
802  if ((!tor_addr_compare(&bridge->addr, &ri->ipv4_addr, CMP_EXACT) &&
803  bridge->port == ri->ipv4_orport) ||
804  (!tor_addr_compare(&bridge->addr, &ri->ipv6_addr, CMP_EXACT) &&
805  bridge->port == ri->ipv6_orport)) {
806  /* they match, so no need to do anything */
807  } else {
808  if (tor_addr_family(&bridge->addr) == AF_INET) {
809  tor_addr_copy(&ri->ipv4_addr, &bridge->addr);
810  ri->ipv4_orport = bridge->port;
811  log_info(LD_DIR,
812  "Adjusted bridge routerinfo for '%s' to match configured "
813  "address %s:%d.",
814  ri->nickname, fmt_addr(&ri->ipv4_addr), ri->ipv4_orport);
815  } else if (tor_addr_family(&bridge->addr) == AF_INET6) {
816  tor_addr_copy(&ri->ipv6_addr, &bridge->addr);
817  ri->ipv6_orport = bridge->port;
818  log_info(LD_DIR,
819  "Adjusted bridge routerinfo for '%s' to match configured "
820  "address %s.",
821  ri->nickname, fmt_addrport(&ri->ipv6_addr, ri->ipv6_orport));
822  } else {
823  log_err(LD_BUG, "Address family not supported: %d.",
824  tor_addr_family(&bridge->addr));
825  return;
826  }
827  }
828 
829  if (options->ClientPreferIPv6ORPort == -1) {
830  /* Mark which address to use based on which bridge_t we got. */
831  node->ipv6_preferred = (tor_addr_family(&bridge->addr) == AF_INET6 &&
832  !tor_addr_is_null(&node->ri->ipv6_addr));
833  } else {
834  /* Mark which address to use based on user preference */
836  !tor_addr_is_null(&node->ri->ipv6_addr));
837  }
838 
839  /* XXXipv6 we lack support for falling back to another address for
840  the same relay, warn the user */
841  if (!tor_addr_is_null(&ri->ipv6_addr)) {
842  tor_addr_port_t ap;
843  node_get_pref_orport(node, &ap);
844  log_notice(LD_CONFIG,
845  "Bridge '%s' has both an IPv4 and an IPv6 address. "
846  "Will prefer using its %s address (%s) based on %s.",
847  ri->nickname,
848  node->ipv6_preferred ? "IPv6" : "IPv4",
849  fmt_addrport(&ap.addr, ap.port),
850  options->ClientPreferIPv6ORPort == -1 ?
851  "the configured Bridge address" :
852  "ClientPreferIPv6ORPort");
853  }
854  }
855  if (node->rs) {
856  routerstatus_t *rs = node->rs;
857 
858  if ((!tor_addr_compare(&bridge->addr, &rs->ipv4_addr, CMP_EXACT) &&
859  bridge->port == rs->ipv4_orport) ||
860  (!tor_addr_compare(&bridge->addr, &rs->ipv6_addr, CMP_EXACT) &&
861  bridge->port == rs->ipv6_orport)) {
862  /* they match, so no need to do anything */
863  } else {
864  if (tor_addr_family(&bridge->addr) == AF_INET) {
865  tor_addr_copy(&rs->ipv4_addr, &bridge->addr);
866  rs->ipv4_orport = bridge->port;
867  log_info(LD_DIR,
868  "Adjusted bridge routerstatus for '%s' to match "
869  "configured address %s.",
870  rs->nickname, fmt_addrport(&bridge->addr, rs->ipv4_orport));
871  /* set IPv6 preferences even if there is no ri */
872  } else if (tor_addr_family(&bridge->addr) == AF_INET6) {
873  tor_addr_copy(&rs->ipv6_addr, &bridge->addr);
874  rs->ipv6_orport = bridge->port;
875  log_info(LD_DIR,
876  "Adjusted bridge routerstatus for '%s' to match configured"
877  " address %s.",
878  rs->nickname, fmt_addrport(&rs->ipv6_addr, rs->ipv6_orport));
879  } else {
880  log_err(LD_BUG, "Address family not supported: %d.",
881  tor_addr_family(&bridge->addr));
882  return;
883  }
884  }
885 
886  if (options->ClientPreferIPv6ORPort == -1) {
887  /* Mark which address to use based on which bridge_t we got. */
888  node->ipv6_preferred = (tor_addr_family(&bridge->addr) == AF_INET6 &&
889  !tor_addr_is_null(&node->rs->ipv6_addr));
890  } else {
891  /* Mark which address to use based on user preference */
893  !tor_addr_is_null(&node->rs->ipv6_addr));
894  }
895 
896  /* XXXipv6 we lack support for falling back to another address for
897  the same relay, warn the user */
898  if (!tor_addr_is_null(&rs->ipv6_addr)) {
899  tor_addr_port_t ap;
900  node_get_pref_orport(node, &ap);
901  log_notice(LD_CONFIG,
902  "Bridge '%s' has both an IPv4 and an IPv6 address. "
903  "Will prefer using its %s address (%s) based on %s.",
904  rs->nickname,
905  node->ipv6_preferred ? "IPv6" : "IPv4",
906  fmt_addrport(&ap.addr, ap.port),
907  options->ClientPreferIPv6ORPort == -1 ?
908  "the configured Bridge address" :
909  "ClientPreferIPv6ORPort");
910  }
911  }
912 }
913 
914 /** We just learned a descriptor for a bridge. See if that
915  * digest is in our entry guard list, and add it if not. */
916 void
918 {
919  tor_assert(ri);
921  if (get_options()->UseBridges) {
922  /* Retry directory downloads whenever we get a bridge descriptor:
923  * - when bootstrapping, and
924  * - when we aren't sure if any of our bridges are reachable.
925  * Keep on retrying until we have at least one reachable bridge. */
926  int first = num_bridges_usable(0) < 1;
928  time_t now = time(NULL);
929  router_set_status(ri->cache_info.identity_digest, 1);
930 
931  if (bridge) { /* if we actually want to use this one */
932  node_t *node;
933  /* it's here; schedule its re-fetch for a long time from now. */
934  if (!from_cache) {
935  /* This schedules the re-fetch at a constant interval, which produces
936  * a pattern of bridge traffic. But it's better than trying all
937  * configured briges several times in the first few minutes. */
939  }
940 
941  node = node_get_mutable_by_id(ri->cache_info.identity_digest);
942  tor_assert(node);
943  rewrite_node_address_for_bridge(bridge, node);
944  if (tor_digest_is_zero(bridge->identity)) {
945  memcpy(bridge->identity,ri->cache_info.identity_digest, DIGEST_LEN);
946  log_notice(LD_DIR, "Learned identity %s for bridge at %s:%d",
947  hex_str(bridge->identity, DIGEST_LEN),
948  fmt_and_decorate_addr(&bridge->addr),
949  (int) bridge->port);
950  }
952  (const uint8_t*)ri->cache_info.identity_digest);
953 
954  log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname,
955  from_cache ? "cached" : "fresh", router_describe(ri));
956  /* If we didn't have a reachable bridge before this one, try directory
957  * documents again. */
958  if (first) {
960  }
961  }
962  }
963 }
964 
965 /** Return a smartlist containing all bridge identity digests */
968 {
969  smartlist_t *result = NULL;
970  char *digest_tmp;
971 
972  if (get_options()->UseBridges && bridge_list) {
973  result = smartlist_new();
974 
976  digest_tmp = tor_malloc(DIGEST_LEN);
977  memcpy(digest_tmp, b->identity, DIGEST_LEN);
978  smartlist_add(result, digest_tmp);
979  } SMARTLIST_FOREACH_END(b);
980  }
981 
982  return result;
983 }
984 
985 /** Get the download status for a bridge descriptor given its identity */
987 get_bridge_dl_status_by_id, (const char *digest))
988 {
989  download_status_t *dl = NULL;
990 
991  if (digest && get_options()->UseBridges && bridge_list) {
993  if (tor_memeq(digest, b->identity, DIGEST_LEN)) {
994  dl = &(b->fetch_status);
995  break;
996  }
997  } SMARTLIST_FOREACH_END(b);
998  }
999 
1000  return dl;
1001 }
1002 
1003 /** Release all storage held in bridges.c */
1004 void
1006 {
1008  smartlist_free(bridge_list);
1009  bridge_list = NULL;
1010 }
routerinfo_t::purpose
uint8_t purpose
Definition: routerinfo_st.h:115
tor_addr_compare
int tor_addr_compare(const tor_addr_t *addr1, const tor_addr_t *addr2, tor_addr_comparison_t how)
Definition: address.c:984
tor_free
#define tor_free(p)
Definition: malloc.h:52
routerinfo_t
Definition: routerinfo_st.h:20
tor_addr_family
static sa_family_t tor_addr_family(const tor_addr_t *a)
Definition: address.h:187
get_configured_bridge_by_routerinfo
static bridge_info_t * get_configured_bridge_by_routerinfo(const routerinfo_t *ri)
Definition: bridges.c:287
hex_str
const char * hex_str(const char *from, size_t fromlen)
Definition: binascii.c:34
routerinfo.h
Header file for routerinfo.c.
fascist_firewall_prefer_ipv6_orport
int fascist_firewall_prefer_ipv6_orport(const or_options_t *options)
Definition: policies.c:485
download_status_mark_impossible
void download_status_mark_impossible(download_status_t *dl)
Definition: dlstatus.c:393
directory_request_set_router_purpose
void directory_request_set_router_purpose(directory_request_t *req, uint8_t router_purpose)
Definition: dirclient.c:1016
transport_t
Definition: transports.h:17
tor_addr_t
Definition: address.h:69
directory_initiate_request
void directory_initiate_request(directory_request_t *request)
Definition: dirclient.c:1235
MOCK_IMPL
#define MOCK_IMPL(rv, funcname, arglist)
Definition: testsupport.h:133
extend_info_t::onion_key
crypto_pk_t * onion_key
Definition: extend_info_st.h:38
transport_get_by_name
transport_t * transport_get_by_name(const char *name)
Definition: transports.c:236
tor_assert
#define tor_assert(expr)
Definition: util_bug.h:102
CONN_TYPE_DIR
#define CONN_TYPE_DIR
Definition: connection.h:55
LD_BUG
#define LD_BUG
Definition: log.h:86
fast_mem_is_zero
int fast_mem_is_zero(const char *mem, size_t len)
Definition: util_string.c:74
bridge_get_rsa_id_digest
const uint8_t * bridge_get_rsa_id_digest(const bridge_info_t *bridge)
Definition: bridges.c:147
LD_GENERAL
#define LD_GENERAL
Definition: log.h:62
bridge_resolve_conflicts
STATIC void bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port, const char *digest, const char *transport_name)
Definition: bridges.c:438
base16_encode
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
Definition: binascii.c:478
learned_router_identity
void learned_router_identity(const tor_addr_t *addr, uint16_t port, const char *digest, const ed25519_public_key_t *ed_id)
Definition: bridges.c:381
describe.h
Header file for describe.c.
node_get_pref_orport
void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out)
Definition: nodelist.c:1761
or_options_t::ClientPreferIPv6ORPort
int ClientPreferIPv6ORPort
Definition: or_options_st.h:678
fascist_firewall_allows_address_addr
int fascist_firewall_allows_address_addr(const tor_addr_t *addr, uint16_t port, firewall_connection_t fw_connection, int pref_only, int pref_ipv6)
Definition: policies.c:531
smartlist_add
void smartlist_add(smartlist_t *sl, void *element)
Definition: smartlist_core.c:117
transport_is_needed
int transport_is_needed(const char *transport_name)
Definition: bridges.c:488
ed25519_public_key_is_zero
int ed25519_public_key_is_zero(const ed25519_public_key_t *pubkey)
Definition: crypto_ed25519.c:227
routerstatus_t
Definition: routerstatus_st.h:19
num_bridges_usable
int num_bridges_usable(int use_maybe_reachable)
Definition: entrynodes.c:3412
routerstatus_t::nickname
char nickname[MAX_NICKNAME_LEN+1]
Definition: routerstatus_st.h:25
smartlist_new
smartlist_t * smartlist_new(void)
Definition: smartlist_core.c:26
routerinfo_t::ipv6_addr
tor_addr_t ipv6_addr
Definition: routerinfo_st.h:30
addr_is_a_configured_bridge
int addr_is_a_configured_bridge(const tor_addr_t *addr, uint16_t port, const char *digest)
Definition: bridges.c:251
SMARTLIST_FOREACH
#define SMARTLIST_FOREACH(sl, type, var, cmd)
Definition: smartlist_foreach.h:112
bridge_free_
static void bridge_free_(bridge_info_t *bridge)
Definition: bridges.c:119
download_status_t::schedule
download_schedule_bitfield_t schedule
Definition: download_status_st.h:49
routerinfo_is_a_configured_bridge
int routerinfo_is_a_configured_bridge(const routerinfo_t *ri)
Definition: bridges.c:300
router_get_all_orports
smartlist_t * router_get_all_orports(const routerinfo_t *ri)
Definition: routerinfo.c:67
signed_descriptor_t::identity_digest
char identity_digest[DIGEST_LEN]
Definition: signed_descriptor_st.h:31
tor_memeq
int tor_memeq(const void *a, const void *b, size_t sz)
Definition: di_ops.c:107
dirlist.h
Header file for dirlist.c.
directory_get_from_dirserver
void directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose, const char *resource, int pds_flags, download_want_authority_t want_authority)
Definition: dirclient.c:456
learned_bridge_descriptor
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
Definition: bridges.c:917
get_n_authorities
int get_n_authorities(dirinfo_type_t type)
Definition: dirlist.c:87
get_bridge_dl_status_by_id
download_status_t * get_bridge_dl_status_by_id(const char *digest)
Definition: bridges.c:987
DIGEST_LEN
#define DIGEST_LEN
Definition: digest_sizes.h:20
ROUTER_PURPOSE_BRIDGE
#define ROUTER_PURPOSE_BRIDGE
Definition: routerinfo_st.h:106
node_get_mutable_by_id
node_t * node_get_mutable_by_id(const char *identity_digest)
Definition: nodelist.c:194
strcmp_opt
int strcmp_opt(const char *s1, const char *s2)
Definition: util_string.c:188
DIR_PURPOSE_FETCH_SERVERDESC
#define DIR_PURPOSE_FETCH_SERVERDESC
Definition: directory.h:39
fmt_and_decorate_addr
#define fmt_and_decorate_addr(a)
Definition: address.h:243
bridges.h
Header file for circuitbuild.c.
directory_request_set_directory_id_digest
void directory_request_set_directory_id_digest(directory_request_t *req, const char *digest)
Definition: dirclient.c:1004
routerinfo_t::ipv4_addr
tor_addr_t ipv4_addr
Definition: routerinfo_st.h:25
pt_proxies_configuration_pending
int pt_proxies_configuration_pending(void)
Definition: transports.c:374
tor_addr_port_t
Definition: address.h:81
routerstatus_t::ipv4_orport
uint16_t ipv4_orport
Definition: routerstatus_st.h:33
entrynodes.h
Header file for circuitbuild.c.
get_configured_bridge_by_exact_addr_port_digest
bridge_info_t * get_configured_bridge_by_exact_addr_port_digest(const tor_addr_t *addr, uint16_t port, const char *digest)
Definition: bridges.c:226
bridge_list
static smartlist_t * bridge_list
Definition: bridges.c:79
routerlist_retry_directory_downloads
void routerlist_retry_directory_downloads(time_t now)
Definition: routerlist.c:2314
node_t
Definition: node_st.h:34
get_socks_args_by_bridge_addrport
const smartlist_t * get_socks_args_by_bridge_addrport(const tor_addr_t *addr, uint16_t port)
Definition: bridges.c:628
list_bridge_identities
smartlist_t * list_bridge_identities(void)
Definition: bridges.c:967
directory.h
Header file for directory.c.
get_guard_state_for_bridge_desc_fetch
circuit_guard_state_t * get_guard_state_for_bridge_desc_fetch(const char *digest)
Definition: entrynodes.c:3350
find_transport_name_by_bridge_addrport
const char * find_transport_name_by_bridge_addrport(const tor_addr_t *addr, uint16_t port)
Definition: bridges.c:575
tor_digest_is_zero
int tor_digest_is_zero(const char *digest)
Definition: util_string.c:96
ed25519_public_key_t
Definition: crypto_ed25519.h:23
bridges_free_all
void bridges_free_all(void)
Definition: bridges.c:1005
or_options_t::ExcludeNodes
struct routerset_t * ExcludeNodes
Definition: or_options_st.h:102
extend_info_t::orports
tor_addr_port_t orports[EXTEND_INFO_MAX_ADDRS]
Definition: extend_info_st.h:36
rewrite_node_address_for_bridge
static void rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
Definition: bridges.c:790
bridge_exists_with_addr_and_port
static int bridge_exists_with_addr_and_port(const tor_addr_t *addr, const uint16_t port, const char *digest)
Definition: bridges.c:312
microdesc_t::ipv6_orport
uint16_t ipv6_orport
Definition: microdesc_st.h:81
directory_request_set_or_addr_port
void directory_request_set_or_addr_port(directory_request_t *req, const tor_addr_port_t *p)
Definition: dirclient.c:983
microdesc_st.h
Microdescriptor structure.
download_status_t
Definition: download_status_st.h:41
nodelist.h
Header file for nodelist.c.
bridge_line_t
Definition: config.h:222
routerlist.h
Header file for routerlist.c.
routerset.h
Header file for routerset.c.
routerinfo_st.h
Router descriptor structure.
LD_CONFIG
#define LD_CONFIG
Definition: log.h:68
directory_request_set_guard_state
void directory_request_set_guard_state(directory_request_t *req, circuit_guard_state_t *state)
Definition: dirclient.c:1137
retry_bridge_descriptor_fetch_directly
void retry_bridge_descriptor_fetch_directly(const char *digest)
Definition: bridges.c:693
extend_info_is_a_configured_bridge
int extend_info_is_a_configured_bridge(const extend_info_t *ei)
Definition: bridges.c:268
transports.h
Headers for transports.c.
bridge_info_t::transport_name
char * transport_name
Definition: bridges.c:58
fmt_addr
#define fmt_addr(a)
Definition: address.h:239
get_options
const or_options_t * get_options(void)
Definition: config.c:928
mark_bridge_list
void mark_bridge_list(void)
Definition: bridges.c:84
fetch_bridge_descriptors
void fetch_bridge_descriptors(const or_options_t *options, time_t now)
Definition: bridges.c:706
circuitbuild.h
Header file for circuitbuild.c.
fmt_addrport
const char * fmt_addrport(const tor_addr_t *addr, uint16_t port)
Definition: address.c:1199
download_status_t::increment_on
download_schedule_increment_bitfield_t increment_on
Definition: download_status_st.h:58
bridge_info_t::socks_args
smartlist_t * socks_args
Definition: bridges.c:65
smartlist_clear
void smartlist_clear(smartlist_t *sl)
Definition: smartlist_core.c:50
directory_request_set_resource
void directory_request_set_resource(directory_request_t *req, const char *resource)
Definition: dirclient.c:1045
bridge_info_t::marked_for_removal
unsigned marked_for_removal
Definition: bridges.c:52
extend_info_st.h
Extend-info structure.
routerstatus_st.h
Routerstatus (consensus entry) structure.
sweep_bridge_list
void sweep_bridge_list(void)
Definition: bridges.c:95
IF_BUG_ONCE
#define IF_BUG_ONCE(cond)
Definition: util_bug.h:246
get_configured_bridge_by_addr_port_digest
bridge_info_t * get_configured_bridge_by_addr_port_digest(const tor_addr_t *addr, uint16_t port, const char *digest)
Definition: bridges.c:200
connection.h
Header file for connection.c.
download_status_reset
void download_status_reset(download_status_t *dls)
Definition: dlstatus.c:364
extend_info_t::identity_digest
char identity_digest[DIGEST_LEN]
Definition: extend_info_st.h:31
bridge_info_t
Definition: bridges.c:43
directory_request_new
directory_request_t * directory_request_new(uint8_t dir_purpose)
Definition: dirclient.c:948
tor_addr_is_null
int tor_addr_is_null(const tor_addr_t *addr)
Definition: address.c:780
download_status_is_ready
int download_status_is_ready(download_status_t *dls, time_t now)
Definition: dlstatus.c:381
dirclient.h
Header file for dirclient.c.
tor_asprintf
int tor_asprintf(char **strp, const char *fmt,...)
Definition: printf.c:75
microdesc_t::ipv6_addr
tor_addr_t ipv6_addr
Definition: microdesc_st.h:79
SMARTLIST_FOREACH_BEGIN
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
Definition: smartlist_foreach.h:78
dlstatus.h
Header file for dlstatus.c.
download_status_increment_attempt
time_t download_status_increment_attempt(download_status_t *dls, const char *item, time_t now)
Definition: dlstatus.c:309
SMARTLIST_DEL_CURRENT
#define SMARTLIST_DEL_CURRENT(sl, var)
Definition: smartlist_foreach.h:120
bridge_info_t::port
uint16_t port
Definition: bridges.c:49
HEX_DIGEST_LEN
#define HEX_DIGEST_LEN
Definition: crypto_digest.h:35
get_configured_bridge_by_orports_digest
STATIC bridge_info_t * get_configured_bridge_by_orports_digest(const char *digest, const smartlist_t *orports)
Definition: bridges.c:172
node_st.h
Node information structure.
routerstatus_t::ipv6_addr
tor_addr_t ipv6_addr
Definition: routerstatus_st.h:35
get_transport_by_bridge_addrport
int get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port, const transport_t **transport)
Definition: bridges.c:598
bridge_info_t::identity
char identity[DIGEST_LEN]
Definition: bridges.c:55
clear_bridge_list
STATIC void clear_bridge_list(void)
Definition: bridges.c:109
router_describe
const char * router_describe(const routerinfo_t *ri)
Definition: describe.c:122
policies.h
Header file for policies.c.
LD_APP
#define LD_APP
Definition: log.h:78
config.h
Header file for config.c.
or_options_t::UpdateBridgesFromAuthority
int UpdateBridgesFromAuthority
Definition: or_options_st.h:254
launch_direct_bridge_descriptor_fetch
static void launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
Definition: bridges.c:638
BRIDGE_DIRINFO
@ BRIDGE_DIRINFO
Definition: or.h:910
node_t::ipv6_preferred
unsigned int ipv6_preferred
Definition: node_st.h:88
bridge_add_from_config
void bridge_add_from_config(bridge_line_t *bridge_line)
Definition: bridges.c:505
bridge_list_get
const smartlist_t * bridge_list_get(void)
Definition: bridges.c:135
or_options_t
Definition: or_options_st.h:45
STATIC
#define STATIC
Definition: testsupport.h:32
routerstatus_t::ipv6_orport
uint16_t ipv6_orport
Definition: routerstatus_st.h:36
routerset_contains_bridge
int routerset_contains_bridge(const routerset_t *set, const bridge_info_t *bridge)
Definition: routerset.c:364
bridge_info_t::addrport_configured
tor_addr_port_t addrport_configured
Definition: bridges.c:45
routerinfo_t::nickname
char * nickname
Definition: routerinfo_st.h:22
LD_DIR
#define LD_DIR
Definition: log.h:88
find_bridge_by_digest
STATIC bridge_info_t * find_bridge_by_digest(const char *digest)
Definition: bridges.c:559
bridge_get_addr_port
const tor_addr_port_t * bridge_get_addr_port(const bridge_info_t *bridge)
Definition: bridges.c:161
connection_get_by_type_addr_port_purpose
connection_t * connection_get_by_type_addr_port_purpose(int type, const tor_addr_t *addr, uint16_t port, int purpose)
Definition: connection.c:4729
directory_request_t
struct directory_request_t directory_request_t
Definition: dirclient.h:52
smartlist_t
Definition: smartlist_core.h:26
tor_addr_eq
#define tor_addr_eq(a, b)
Definition: address.h:280
bridge_info_t::addr
tor_addr_t addr
Definition: bridges.c:47
bridge_has_digest
static int bridge_has_digest(const bridge_info_t *bridge, const char *digest)
Definition: bridges.c:424
tor_addr_copy
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
Definition: address.c:933
extend_info_t
Definition: extend_info_st.h:27
node_t::identity
char identity[DIGEST_LEN]
Definition: node_st.h:46
bridge_info_t::fetch_status
download_status_t fetch_status
Definition: bridges.c:61
or.h
Master header file for Tor-specific functionality.
router_set_status
void router_set_status(const char *digest, int up)
Definition: nodelist.c:2290
entry_guard_learned_bridge_identity
void entry_guard_learned_bridge_identity(const tor_addr_port_t *addrport, const uint8_t *rsa_id_digest)
Definition: entrynodes.c:960
node_is_a_configured_bridge
int node_is_a_configured_bridge(const node_t *node)
Definition: bridges.c:332