Tor  0.4.6.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 /**
168  * Given a <b>bridge</b>, return the transport name. If none were configured,
169  * NULL is returned.
170  */
171 const char *
173 {
174  tor_assert(bridge);
175  return bridge->transport_name;
176 }
177 
178 /** If we have a bridge configured whose digest matches <b>digest</b>, or a
179  * bridge with no known digest whose address matches any of the
180  * tor_addr_port_t's in <b>orports</b>, return that bridge. Else return
181  * NULL. */
184  const smartlist_t *orports)
185 {
186  if (!bridge_list)
187  return NULL;
189  {
190  if (tor_digest_is_zero(bridge->identity)) {
192  {
193  if (tor_addr_compare(&bridge->addr, &ap->addr, CMP_EXACT) == 0 &&
194  bridge->port == ap->port)
195  return bridge;
196  }
197  SMARTLIST_FOREACH_END(ap);
198  }
199  if (digest && tor_memeq(bridge->identity, digest, DIGEST_LEN))
200  return bridge;
201  }
202  SMARTLIST_FOREACH_END(bridge);
203  return NULL;
204 }
205 
206 /** If we have a bridge configured whose digest matches <b>digest</b>, or a
207  * bridge with no known digest whose address matches <b>addr</b>:<b>port</b>,
208  * return that bridge. Else return NULL. If <b>digest</b> is NULL, check for
209  * address/port matches only. */
212  uint16_t port,
213  const char *digest)
214 {
215  if (!bridge_list)
216  return NULL;
218  {
219  if ((tor_digest_is_zero(bridge->identity) || digest == NULL) &&
220  !tor_addr_compare(&bridge->addr, addr, CMP_EXACT) &&
221  bridge->port == port)
222  return bridge;
223  if (digest && tor_memeq(bridge->identity, digest, DIGEST_LEN))
224  return bridge;
225  }
226  SMARTLIST_FOREACH_END(bridge);
227  return NULL;
228 }
229 
230 /**
231  * As get_configured_bridge_by_addr_port, but require that the
232  * address match <b>addr</b>:<b>port</b>, and that the ID digest match
233  * <b>digest</b>. (The other function will ignore the address if the
234  * digest matches.)
235  */
238  uint16_t port,
239  const char *digest)
240 {
241  if (!bridge_list)
242  return NULL;
244  if (!tor_addr_compare(&bridge->addr, addr, CMP_EXACT) &&
245  bridge->port == port) {
246 
247  if (digest && tor_memeq(bridge->identity, digest, DIGEST_LEN))
248  return bridge;
249  else if (!digest || tor_digest_is_zero(bridge->identity))
250  return bridge;
251  }
252 
253  } SMARTLIST_FOREACH_END(bridge);
254  return NULL;
255 }
256 
257 /** If we have a bridge configured whose digest matches <b>digest</b>, or a
258  * bridge with no known digest whose address matches <b>addr</b>:<b>port</b>,
259  * return 1. Else return 0. If <b>digest</b> is NULL, check for
260  * address/port matches only. */
261 int
263  uint16_t port,
264  const char *digest)
265 {
266  tor_assert(addr);
267  return get_configured_bridge_by_addr_port_digest(addr, port, digest) ? 1 : 0;
268 }
269 
270 /** If we have a bridge configured whose digest matches
271  * <b>ei->identity_digest</b>, or a bridge with no known digest whose address
272  * matches <b>ei->addr</b>:<b>ei->port</b>, return 1. Else return 0.
273  * If <b>ei->onion_key</b> is NULL, check for address/port matches only.
274  *
275  * Note that if the extend_info_t contains multiple addresses, we return true
276  * only if _every_ address is a bridge.
277  */
278 int
280 {
281  const char *digest = ei->onion_key ? ei->identity_digest : NULL;
282  const tor_addr_port_t *ap1 = NULL, *ap2 = NULL;
283  if (! tor_addr_is_null(&ei->orports[0].addr))
284  ap1 = &ei->orports[0];
285  if (! tor_addr_is_null(&ei->orports[1].addr))
286  ap2 = &ei->orports[1];
287  IF_BUG_ONCE(ap1 == NULL) {
288  return 0;
289  }
290  return addr_is_a_configured_bridge(&ap1->addr, ap1->port, digest) &&
291  (ap2 == NULL ||
292  addr_is_a_configured_bridge(&ap2->addr, ap2->port, digest));
293 }
294 
295 /** Wrapper around get_configured_bridge_by_addr_port_digest() to look
296  * it up via router descriptor <b>ri</b>. */
297 static bridge_info_t *
299 {
300  bridge_info_t *bi = NULL;
301  smartlist_t *orports = router_get_all_orports(ri);
303  orports);
304  SMARTLIST_FOREACH(orports, tor_addr_port_t *, p, tor_free(p));
305  smartlist_free(orports);
306  return bi;
307 }
308 
309 /** Return 1 if <b>ri</b> is one of our known bridges, else 0. */
310 int
312 {
313  return get_configured_bridge_by_routerinfo(ri) ? 1 : 0;
314 }
315 
316 /**
317  * Return 1 iff <b>bridge_list</b> contains entry matching given
318  * <b>addr</b> and <b>port</b> (and no identity digest) OR
319  * it contains an entry whose identity matches <b>digest</b>.
320  * Otherwise, return 0.
321  */
322 static int
324  const uint16_t port,
325  const char *digest)
326 {
327  if (!tor_addr_port_is_valid(addr, port, 0))
328  return 0;
329 
330  bridge_info_t *bridge =
331  get_configured_bridge_by_addr_port_digest(addr, port, digest);
332 
333  return (bridge != NULL);
334 }
335 
336 /** Return 1 if <b>node</b> is one of our configured bridges, else 0.
337  * More specifically, return 1 iff: a bridge_info_t object exists in
338  * <b>bridge_list</b> such that: 1) It's identity is equal to node
339  * identity OR 2) It's identity digest is zero, but it matches
340  * address and port of any ORPort in the node.
341  */
342 int
344 {
345  /* First, let's try searching for a bridge with matching identity. */
346  if (BUG(fast_mem_is_zero(node->identity, DIGEST_LEN)))
347  return 0;
348 
349  if (find_bridge_by_digest(node->identity) != NULL)
350  return 1;
351 
352  /* At this point, we have established that no bridge exists with
353  * matching identity digest. However, we still pass it into
354  * bridge_exists_* functions because we want further code to
355  * check for absence of identity digest in a bridge.
356  */
357  if (node->ri) {
359  node->ri->ipv4_orport,
360  node->identity))
361  return 1;
362 
364  node->ri->ipv6_orport,
365  node->identity))
366  return 1;
367  } else if (node->rs) {
368  if (bridge_exists_with_addr_and_port(&node->rs->ipv4_addr,
369  node->rs->ipv4_orport,
370  node->identity))
371  return 1;
372 
374  node->rs->ipv6_orport,
375  node->identity))
376  return 1;
377  } else if (node->md) {
379  node->md->ipv6_orport,
380  node->identity))
381  return 1;
382  }
383 
384  return 0;
385 }
386 
387 /** We made a connection to a router at <b>addr</b>:<b>port</b>
388  * without knowing its digest. Its digest turned out to be <b>digest</b>.
389  * If it was a bridge, and we still don't know its digest, record it.
390  */
391 void
392 learned_router_identity(const tor_addr_t *addr, uint16_t port,
393  const char *digest,
394  const ed25519_public_key_t *ed_id)
395 {
396  // XXXX prop220 use ed_id here, once there is some way to specify
397  (void)ed_id;
398  int learned = 0;
399  bridge_info_t *bridge =
401  if (bridge && tor_digest_is_zero(bridge->identity)) {
402  memcpy(bridge->identity, digest, DIGEST_LEN);
403  learned = 1;
404  }
405  /* XXXX prop220 remember bridge ed25519 identities -- add a field */
406 #if 0
407  if (bridge && ed_id &&
408  ed25519_public_key_is_zero(&bridge->ed25519_identity) &&
409  !ed25519_public_key_is_zero(ed_id)) {
410  memcpy(&bridge->ed25519_identity, ed_id, sizeof(*ed_id));
411  learned = 1;
412  }
413 #endif /* 0 */
414  if (learned) {
415  char *transport_info = NULL;
416  const char *transport_name =
418  if (transport_name)
419  tor_asprintf(&transport_info, " (with transport '%s')", transport_name);
420 
421  // XXXX prop220 log both fingerprints.
422  log_notice(LD_DIR, "Learned fingerprint %s for bridge %s%s.",
423  hex_str(digest, DIGEST_LEN), fmt_addrport(addr, port),
424  transport_info ? transport_info : "");
425  tor_free(transport_info);
427  (const uint8_t *)digest);
428  }
429 }
430 
431 /** Return true if <b>bridge</b> has the same identity digest as
432  * <b>digest</b>. If <b>digest</b> is NULL, it matches
433  * bridges with unspecified identity digests. */
434 static int
435 bridge_has_digest(const bridge_info_t *bridge, const char *digest)
436 {
437  if (digest)
438  return tor_memeq(digest, bridge->identity, DIGEST_LEN);
439  else
440  return tor_digest_is_zero(bridge->identity);
441 }
442 
443 /** We are about to add a new bridge at <b>addr</b>:<b>port</b>, with optional
444  * <b>digest</b> and <b>transport_name</b>. Mark for removal any previously
445  * existing bridge with the same address and port, and warn the user as
446  * appropriate.
447  */
448 STATIC void
449 bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
450  const char *digest, const char *transport_name)
451 {
452  /* Iterate the already-registered bridge list:
453 
454  If you find a bridge with the same address and port, mark it for
455  removal. It doesn't make sense to have two active bridges with
456  the same IP:PORT. If the bridge in question has a different
457  digest or transport than <b>digest</b>/<b>transport_name</b>,
458  it's probably a misconfiguration and we should warn the user.
459  */
461  if (bridge->marked_for_removal)
462  continue;
463 
464  if (tor_addr_eq(&bridge->addr, addr) && (bridge->port == port)) {
465 
466  bridge->marked_for_removal = 1;
467 
468  if (!bridge_has_digest(bridge, digest) ||
469  strcmp_opt(bridge->transport_name, transport_name)) {
470  /* warn the user */
471  char *bridge_description_new, *bridge_description_old;
472  tor_asprintf(&bridge_description_new, "%s:%s:%s",
473  fmt_addrport(addr, port),
474  digest ? hex_str(digest, DIGEST_LEN) : "",
475  transport_name ? transport_name : "");
476  tor_asprintf(&bridge_description_old, "%s:%s:%s",
477  fmt_addrport(&bridge->addr, bridge->port),
478  tor_digest_is_zero(bridge->identity) ?
479  "" : hex_str(bridge->identity,DIGEST_LEN),
480  bridge->transport_name ? bridge->transport_name : "");
481 
482  log_warn(LD_GENERAL,"Tried to add bridge '%s', but we found a conflict"
483  " with the already registered bridge '%s'. We will discard"
484  " the old bridge and keep '%s'. If this is not what you"
485  " wanted, please change your configuration file accordingly.",
486  bridge_description_new, bridge_description_old,
487  bridge_description_new);
488 
489  tor_free(bridge_description_new);
490  tor_free(bridge_description_old);
491  }
492  }
493  } SMARTLIST_FOREACH_END(bridge);
494 }
495 
496 /** Return True if we have a bridge that uses a transport with name
497  * <b>transport_name</b>. */
498 MOCK_IMPL(int,
499 transport_is_needed, (const char *transport_name))
500 {
501  if (!bridge_list)
502  return 0;
503 
505  if (bridge->transport_name &&
506  !strcmp(bridge->transport_name, transport_name))
507  return 1;
508  } SMARTLIST_FOREACH_END(bridge);
509 
510  return 0;
511 }
512 
513 /** Register the bridge information in <b>bridge_line</b> to the
514  * bridge subsystem. Steals reference of <b>bridge_line</b>. */
515 void
517 {
518  bridge_info_t *b;
519 
520  // XXXX prop220 add a way to specify ed25519 ID to bridge_line_t.
521 
522  { /* Log the bridge we are about to register: */
523  log_debug(LD_GENERAL, "Registering bridge at %s (transport: %s) (%s)",
524  fmt_addrport(&bridge_line->addr, bridge_line->port),
525  bridge_line->transport_name ?
526  bridge_line->transport_name : "no transport",
527  tor_digest_is_zero(bridge_line->digest) ?
528  "no key listed" : hex_str(bridge_line->digest, DIGEST_LEN));
529 
530  if (bridge_line->socks_args) { /* print socks arguments */
531  int i = 0;
532 
533  tor_assert(smartlist_len(bridge_line->socks_args) > 0);
534 
535  log_debug(LD_GENERAL, "Bridge uses %d SOCKS arguments:",
536  smartlist_len(bridge_line->socks_args));
537  SMARTLIST_FOREACH(bridge_line->socks_args, const char *, arg,
538  log_debug(LD_CONFIG, "%d: %s", ++i, arg));
539  }
540  }
541 
542  bridge_resolve_conflicts(&bridge_line->addr,
543  bridge_line->port,
544  bridge_line->digest,
545  bridge_line->transport_name);
546 
547  b = tor_malloc_zero(sizeof(bridge_info_t));
548  tor_addr_copy(&b->addrport_configured.addr, &bridge_line->addr);
549  b->addrport_configured.port = bridge_line->port;
550  tor_addr_copy(&b->addr, &bridge_line->addr);
551  b->port = bridge_line->port;
552  memcpy(b->identity, bridge_line->digest, DIGEST_LEN);
553  if (bridge_line->transport_name)
554  b->transport_name = bridge_line->transport_name;
555  b->fetch_status.schedule = DL_SCHED_BRIDGE;
556  b->fetch_status.increment_on = DL_SCHED_INCREMENT_ATTEMPT;
557  /* We can't reset the bridge's download status here, because UseBridges
558  * might be 0 now, and it might be changed to 1 much later. */
559  b->socks_args = bridge_line->socks_args;
560  if (!bridge_list)
562 
563  tor_free(bridge_line); /* Deallocate bridge_line now. */
564 
566 }
567 
568 /** If <b>digest</b> is one of our known bridges, return it. */
570 find_bridge_by_digest(const char *digest)
571 {
572  if (! bridge_list)
573  return NULL;
575  {
576  if (tor_memeq(bridge->identity, digest, DIGEST_LEN))
577  return bridge;
578  });
579  return NULL;
580 }
581 
582 /** Given the <b>addr</b> and <b>port</b> of a bridge, if that bridge
583  * supports a pluggable transport, return its name. Otherwise, return
584  * NULL. */
585 const char *
587 {
588  if (!bridge_list)
589  return NULL;
590 
592  if (tor_addr_eq(&bridge->addr, addr) &&
593  (bridge->port == port))
594  return bridge->transport_name;
595  } SMARTLIST_FOREACH_END(bridge);
596 
597  return NULL;
598 }
599 
600 /** If <b>addr</b> and <b>port</b> match the address and port of a
601  * bridge of ours that uses pluggable transports, place its transport
602  * in <b>transport</b>.
603  *
604  * Return 0 on success (found a transport, or found a bridge with no
605  * transport, or found no bridge); return -1 if we should be using a
606  * transport, but the transport could not be found.
607  */
608 int
609 get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
610  const transport_t **transport)
611 {
612  *transport = NULL;
613  if (!bridge_list)
614  return 0;
615 
617  if (tor_addr_eq(&bridge->addr, addr) &&
618  (bridge->port == port)) { /* bridge matched */
619  if (bridge->transport_name) { /* it also uses pluggable transports */
620  *transport = transport_get_by_name(bridge->transport_name);
621  if (*transport == NULL) { /* it uses pluggable transports, but
622  the transport could not be found! */
623  return -1;
624  }
625  return 0;
626  } else { /* bridge matched, but it doesn't use transports. */
627  break;
628  }
629  }
630  } SMARTLIST_FOREACH_END(bridge);
631 
632  *transport = NULL;
633  return 0;
634 }
635 
636 /** Return a smartlist containing all the SOCKS arguments that we
637  * should pass to the SOCKS proxy. */
638 const smartlist_t *
640 {
642  port,
643  NULL);
644  return bridge ? bridge->socks_args : NULL;
645 }
646 
647 /** We need to ask <b>bridge</b> for its server descriptor. */
648 static void
650 {
651  const or_options_t *options = get_options();
652  circuit_guard_state_t *guard_state = NULL;
653 
655  CONN_TYPE_DIR, &bridge->addr, bridge->port,
657  return; /* it's already on the way */
658 
659  if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
661  log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
662  safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
663  return;
664  }
665 
666  /* Until we get a descriptor for the bridge, we only know one address for
667  * it. */
668  if (!reachable_addr_allows_addr(&bridge->addr, bridge->port,
669  FIREWALL_OR_CONNECTION, 0, 0)) {
670  log_notice(LD_CONFIG, "Tried to fetch a descriptor directly from a "
671  "bridge, but that bridge is not reachable through our "
672  "firewall.");
673  return;
674  }
675 
676  /* If we already have a node_t for this bridge, rewrite its address now. */
677  node_t *node = node_get_mutable_by_id(bridge->identity);
678  if (node) {
679  rewrite_node_address_for_bridge(bridge, node);
680  }
681 
682  tor_addr_port_t bridge_addrport;
683  memcpy(&bridge_addrport.addr, &bridge->addr, sizeof(tor_addr_t));
684  bridge_addrport.port = bridge->port;
685 
686  guard_state = get_guard_state_for_bridge_desc_fetch(bridge->identity);
687 
688  directory_request_t *req =
690  directory_request_set_or_addr_port(req, &bridge_addrport);
693  directory_request_set_resource(req, "authority.z");
694  if (guard_state) {
695  directory_request_set_guard_state(req, guard_state);
696  }
698  directory_request_free(req);
699 }
700 
701 /** Fetching the bridge descriptor from the bridge authority returned a
702  * "not found". Fall back to trying a direct fetch. */
703 void
705 {
706  bridge_info_t *bridge = find_bridge_by_digest(digest);
707  if (!bridge)
708  return; /* not found? oh well. */
709 
711 }
712 
713 /** For each bridge in our list for which we don't currently have a
714  * descriptor, fetch a new copy of its descriptor -- either directly
715  * from the bridge or via a bridge authority. */
716 void
717 fetch_bridge_descriptors(const or_options_t *options, time_t now)
718 {
719  int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO);
720  int ask_bridge_directly;
721  int can_use_bridge_authority;
722 
723  if (!bridge_list)
724  return;
725 
726  /* If we still have unconfigured managed proxies, don't go and
727  connect to a bridge. */
729  return;
730 
732  {
733  /* This resets the download status on first use */
734  if (!download_status_is_ready(&bridge->fetch_status, now))
735  continue; /* don't bother, no need to retry yet */
736  if (routerset_contains_bridge(options->ExcludeNodes, bridge)) {
737  download_status_mark_impossible(&bridge->fetch_status);
738  log_warn(LD_APP, "Not using bridge at %s: it is in ExcludeNodes.",
739  safe_str_client(fmt_and_decorate_addr(&bridge->addr)));
740  continue;
741  }
742 
743  /* schedule the next attempt
744  * we can't increment after a failure, because sometimes we use the
745  * bridge authority, and sometimes we use the bridge direct */
747  &bridge->fetch_status,
748  safe_str_client(fmt_and_decorate_addr(&bridge->addr)),
749  now);
750 
751  can_use_bridge_authority = !tor_digest_is_zero(bridge->identity) &&
752  num_bridge_auths;
753  ask_bridge_directly = !can_use_bridge_authority ||
754  !options->UpdateBridgesFromAuthority;
755  log_debug(LD_DIR, "ask_bridge_directly=%d (%d, %d, %d)",
756  ask_bridge_directly, tor_digest_is_zero(bridge->identity),
757  !options->UpdateBridgesFromAuthority, !num_bridge_auths);
758 
759  if (ask_bridge_directly &&
760  !reachable_addr_allows_addr(&bridge->addr, bridge->port,
761  FIREWALL_OR_CONNECTION, 0,
762  0)) {
763  log_notice(LD_DIR, "Bridge at '%s' isn't reachable by our "
764  "firewall policy. %s.",
765  fmt_addrport(&bridge->addr, bridge->port),
766  can_use_bridge_authority ?
767  "Asking bridge authority instead" : "Skipping");
768  if (can_use_bridge_authority)
769  ask_bridge_directly = 0;
770  else
771  continue;
772  }
773 
774  if (ask_bridge_directly) {
775  /* we need to ask the bridge itself for its descriptor. */
777  } else {
778  /* We have a digest and we want to ask an authority. We could
779  * combine all the requests into one, but that may give more
780  * hints to the bridge authority than we want to give. */
781  char resource[10 + HEX_DIGEST_LEN];
782  memcpy(resource, "fp/", 3);
783  base16_encode(resource+3, HEX_DIGEST_LEN+1,
784  bridge->identity, DIGEST_LEN);
785  memcpy(resource+3+HEX_DIGEST_LEN, ".z", 3);
786  log_info(LD_DIR, "Fetching bridge info '%s' from bridge authority.",
787  resource);
789  ROUTER_PURPOSE_BRIDGE, resource, 0, DL_WANT_AUTHORITY);
790  }
791  }
792  SMARTLIST_FOREACH_END(bridge);
793 }
794 
795 /** If our <b>bridge</b> is configured to be a different address than
796  * the bridge gives in <b>node</b>, rewrite the routerinfo
797  * we received to use the address we meant to use. Now we handle
798  * multihomed bridges better.
799  */
800 static void
802 {
803  /* XXXX move this function. */
804  /* XXXX overridden addresses should really live in the node_t, so that the
805  * routerinfo_t and the microdesc_t can be immutable. But we can only
806  * do that safely if we know that no function that connects to an OR
807  * does so through an address from any source other than node_get_addr().
808  */
809  const or_options_t *options = get_options();
810 
811  if (node->ri) {
812  routerinfo_t *ri = node->ri;
813  if ((!tor_addr_compare(&bridge->addr, &ri->ipv4_addr, CMP_EXACT) &&
814  bridge->port == ri->ipv4_orport) ||
815  (!tor_addr_compare(&bridge->addr, &ri->ipv6_addr, CMP_EXACT) &&
816  bridge->port == ri->ipv6_orport)) {
817  /* they match, so no need to do anything */
818  } else {
819  if (tor_addr_family(&bridge->addr) == AF_INET) {
820  tor_addr_copy(&ri->ipv4_addr, &bridge->addr);
821  ri->ipv4_orport = bridge->port;
822  log_info(LD_DIR,
823  "Adjusted bridge routerinfo for '%s' to match configured "
824  "address %s:%d.",
825  ri->nickname, fmt_addr(&ri->ipv4_addr), ri->ipv4_orport);
826  } else if (tor_addr_family(&bridge->addr) == AF_INET6) {
827  tor_addr_copy(&ri->ipv6_addr, &bridge->addr);
828  ri->ipv6_orport = bridge->port;
829  log_info(LD_DIR,
830  "Adjusted bridge routerinfo for '%s' to match configured "
831  "address %s.",
832  ri->nickname, fmt_addrport(&ri->ipv6_addr, ri->ipv6_orport));
833  } else {
834  log_err(LD_BUG, "Address family not supported: %d.",
835  tor_addr_family(&bridge->addr));
836  return;
837  }
838  }
839 
840  if (options->ClientPreferIPv6ORPort == -1) {
841  /* Mark which address to use based on which bridge_t we got. */
842  node->ipv6_preferred = (tor_addr_family(&bridge->addr) == AF_INET6 &&
843  !tor_addr_is_null(&node->ri->ipv6_addr));
844  } else {
845  /* Mark which address to use based on user preference */
847  !tor_addr_is_null(&node->ri->ipv6_addr));
848  }
849 
850  /* XXXipv6 we lack support for falling back to another address for
851  the same relay, warn the user */
852  if (!tor_addr_is_null(&ri->ipv6_addr)) {
853  tor_addr_port_t ap;
854  node_get_pref_orport(node, &ap);
855  log_notice(LD_CONFIG,
856  "Bridge '%s' has both an IPv4 and an IPv6 address. "
857  "Will prefer using its %s address (%s) based on %s.",
858  ri->nickname,
859  node->ipv6_preferred ? "IPv6" : "IPv4",
860  fmt_addrport(&ap.addr, ap.port),
861  options->ClientPreferIPv6ORPort == -1 ?
862  "the configured Bridge address" :
863  "ClientPreferIPv6ORPort");
864  }
865  }
866  if (node->rs) {
867  routerstatus_t *rs = node->rs;
868 
869  if ((!tor_addr_compare(&bridge->addr, &rs->ipv4_addr, CMP_EXACT) &&
870  bridge->port == rs->ipv4_orport) ||
871  (!tor_addr_compare(&bridge->addr, &rs->ipv6_addr, CMP_EXACT) &&
872  bridge->port == rs->ipv6_orport)) {
873  /* they match, so no need to do anything */
874  } else {
875  if (tor_addr_family(&bridge->addr) == AF_INET) {
876  tor_addr_copy(&rs->ipv4_addr, &bridge->addr);
877  rs->ipv4_orport = bridge->port;
878  log_info(LD_DIR,
879  "Adjusted bridge routerstatus for '%s' to match "
880  "configured address %s.",
881  rs->nickname, fmt_addrport(&bridge->addr, rs->ipv4_orport));
882  /* set IPv6 preferences even if there is no ri */
883  } else if (tor_addr_family(&bridge->addr) == AF_INET6) {
884  tor_addr_copy(&rs->ipv6_addr, &bridge->addr);
885  rs->ipv6_orport = bridge->port;
886  log_info(LD_DIR,
887  "Adjusted bridge routerstatus for '%s' to match configured"
888  " address %s.",
889  rs->nickname, fmt_addrport(&rs->ipv6_addr, rs->ipv6_orport));
890  } else {
891  log_err(LD_BUG, "Address family not supported: %d.",
892  tor_addr_family(&bridge->addr));
893  return;
894  }
895  }
896 
897  if (options->ClientPreferIPv6ORPort == -1) {
898  /* Mark which address to use based on which bridge_t we got. */
899  node->ipv6_preferred = (tor_addr_family(&bridge->addr) == AF_INET6 &&
900  !tor_addr_is_null(&node->rs->ipv6_addr));
901  } else {
902  /* Mark which address to use based on user preference */
904  !tor_addr_is_null(&node->rs->ipv6_addr));
905  }
906 
907  /* XXXipv6 we lack support for falling back to another address for
908  the same relay, warn the user */
909  if (!tor_addr_is_null(&rs->ipv6_addr)) {
910  tor_addr_port_t ap;
911  node_get_pref_orport(node, &ap);
912  log_notice(LD_CONFIG,
913  "Bridge '%s' has both an IPv4 and an IPv6 address. "
914  "Will prefer using its %s address (%s) based on %s.",
915  rs->nickname,
916  node->ipv6_preferred ? "IPv6" : "IPv4",
917  fmt_addrport(&ap.addr, ap.port),
918  options->ClientPreferIPv6ORPort == -1 ?
919  "the configured Bridge address" :
920  "ClientPreferIPv6ORPort");
921  }
922  }
923 }
924 
925 /** We just learned a descriptor for a bridge. See if that
926  * digest is in our entry guard list, and add it if not. */
927 void
929 {
930  tor_assert(ri);
932  if (get_options()->UseBridges) {
933  /* Retry directory downloads whenever we get a bridge descriptor:
934  * - when bootstrapping, and
935  * - when we aren't sure if any of our bridges are reachable.
936  * Keep on retrying until we have at least one reachable bridge. */
937  int first = num_bridges_usable(0) < 1;
939  time_t now = time(NULL);
940  router_set_status(ri->cache_info.identity_digest, 1);
941 
942  if (bridge) { /* if we actually want to use this one */
943  node_t *node;
944  /* it's here; schedule its re-fetch for a long time from now. */
945  if (!from_cache) {
946  /* This schedules the re-fetch at a constant interval, which produces
947  * a pattern of bridge traffic. But it's better than trying all
948  * configured bridges several times in the first few minutes. */
950  }
951 
952  node = node_get_mutable_by_id(ri->cache_info.identity_digest);
953  tor_assert(node);
954  rewrite_node_address_for_bridge(bridge, node);
955  if (tor_digest_is_zero(bridge->identity)) {
956  memcpy(bridge->identity,ri->cache_info.identity_digest, DIGEST_LEN);
957  log_notice(LD_DIR, "Learned identity %s for bridge at %s:%d",
958  hex_str(bridge->identity, DIGEST_LEN),
959  fmt_and_decorate_addr(&bridge->addr),
960  (int) bridge->port);
961  }
963  (const uint8_t*)ri->cache_info.identity_digest);
964 
965  log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname,
966  from_cache ? "cached" : "fresh", router_describe(ri));
967  /* If we didn't have a reachable bridge before this one, try directory
968  * documents again. */
969  if (first) {
971  }
972  }
973  }
974 }
975 
976 /** Return a smartlist containing all bridge identity digests */
979 {
980  smartlist_t *result = NULL;
981  char *digest_tmp;
982 
983  if (get_options()->UseBridges && bridge_list) {
984  result = smartlist_new();
985 
987  digest_tmp = tor_malloc(DIGEST_LEN);
988  memcpy(digest_tmp, b->identity, DIGEST_LEN);
989  smartlist_add(result, digest_tmp);
990  } SMARTLIST_FOREACH_END(b);
991  }
992 
993  return result;
994 }
995 
996 /** Get the download status for a bridge descriptor given its identity */
998 get_bridge_dl_status_by_id, (const char *digest))
999 {
1000  download_status_t *dl = NULL;
1001 
1002  if (digest && get_options()->UseBridges && bridge_list) {
1004  if (tor_memeq(digest, b->identity, DIGEST_LEN)) {
1005  dl = &(b->fetch_status);
1006  break;
1007  }
1008  } SMARTLIST_FOREACH_END(b);
1009  }
1010 
1011  return dl;
1012 }
1013 
1014 /** Release all storage held in bridges.c */
1015 void
1017 {
1019  smartlist_free(bridge_list);
1020  bridge_list = NULL;
1021 }
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:298
hex_str
const char * hex_str(const char *from, size_t fromlen)
Definition: binascii.c:34
routerinfo.h
Header file for routerinfo.c.
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:449
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:392
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:701
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:499
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:262
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:311
router_get_all_orports
smartlist_t * router_get_all_orports(const routerinfo_t *ri)
Definition: routerinfo.c:68
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:928
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:998
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:197
reachable_addr_allows_addr
int reachable_addr_allows_addr(const tor_addr_t *addr, uint16_t port, firewall_connection_t fw_connection, int pref_only, int pref_ipv6)
Definition: policies.c:533
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:237
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:2315
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:639
list_bridge_identities
smartlist_t * list_bridge_identities(void)
Definition: bridges.c:978
directory.h
Header file for directory.c.
bridget_get_transport_name
const char * bridget_get_transport_name(const bridge_info_t *bridge)
Definition: bridges.c:172
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:586
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:1016
or_options_t::ExcludeNodes
struct routerset_t * ExcludeNodes
Definition: or_options_st.h:120
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:801
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:323
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:704
extend_info_is_a_configured_bridge
int extend_info_is_a_configured_bridge(const extend_info_t *ei)
Definition: bridges.c:279
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:932
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:717
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:211
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:183
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:609
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:137
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:277
launch_direct_bridge_descriptor_fetch
static void launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
Definition: bridges.c:649
BRIDGE_DIRINFO
@ BRIDGE_DIRINFO
Definition: or.h:910
reachable_addr_prefer_ipv6_orport
int reachable_addr_prefer_ipv6_orport(const or_options_t *options)
Definition: policies.c:487
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:516
bridge_list_get
const smartlist_t * bridge_list_get(void)
Definition: bridges.c:135
or_options_t
Definition: or_options_st.h:64
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:365
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:570
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:4763
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:435
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:343