entrynodes.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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-2013, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file entrynodes.h
  8. * \brief Header file for circuitbuild.c.
  9. **/
  10. #ifndef TOR_ENTRYNODES_H
  11. #define TOR_ENTRYNODES_H
  12. #if 1
  13. /* XXXX NM I would prefer that all of this stuff be private to
  14. * entrynodes.c. */
  15. /** An entry_guard_t represents our information about a chosen long-term
  16. * first hop, known as a "helper" node in the literature. We can't just
  17. * use a node_t, since we want to remember these even when we
  18. * don't have any directory info. */
  19. typedef struct entry_guard_t {
  20. char nickname[MAX_NICKNAME_LEN+1];
  21. char identity[DIGEST_LEN];
  22. time_t chosen_on_date; /**< Approximately when was this guard added?
  23. * "0" if we don't know. */
  24. char *chosen_by_version; /**< What tor version added this guard? NULL
  25. * if we don't know. */
  26. unsigned int made_contact : 1; /**< 0 if we have never connected to this
  27. * router, 1 if we have. */
  28. unsigned int can_retry : 1; /**< Should we retry connecting to this entry,
  29. * in spite of having it marked as unreachable?*/
  30. unsigned int path_bias_noticed : 1; /**< Did we alert the user about path
  31. * bias for this node already? */
  32. unsigned int path_bias_warned : 1; /**< Did we alert the user about path bias
  33. * for this node already? */
  34. unsigned int path_bias_extreme : 1; /**< Did we alert the user about path
  35. * bias for this node already? */
  36. unsigned int path_bias_disabled : 1; /**< Have we disabled this node because
  37. * of path bias issues? */
  38. unsigned int path_bias_use_noticed : 1; /**< Did we alert the user about path
  39. * use bias for this node already? */
  40. unsigned int path_bias_use_extreme : 1; /**< Did we alert the user about path
  41. * use bias for this node already? */
  42. unsigned int is_dir_cache : 1; /**< Is this node a directory cache? */
  43. time_t bad_since; /**< 0 if this guard is currently usable, or the time at
  44. * which it was observed to become (according to the
  45. * directory or the user configuration) unusable. */
  46. time_t unreachable_since; /**< 0 if we can connect to this guard, or the
  47. * time at which we first noticed we couldn't
  48. * connect to it. */
  49. time_t last_attempted; /**< 0 if we can connect to this guard, or the time
  50. * at which we last failed to connect to it. */
  51. double circ_attempts; /**< Number of circuits this guard has "attempted" */
  52. double circ_successes; /**< Number of successfully built circuits using
  53. * this guard as first hop. */
  54. double successful_circuits_closed; /**< Number of circuits that carried
  55. * streams successfully. */
  56. double collapsed_circuits; /**< Number of fully built circuits that were
  57. * remotely closed before any streams were
  58. * attempted. */
  59. double unusable_circuits; /**< Number of circuits for which streams were
  60. * attempted, but none succeeded. */
  61. double timeouts; /**< Number of 'right-censored' circuit timeouts for this
  62. * guard. */
  63. double use_attempts; /**< Number of circuits we tried to use with streams */
  64. double use_successes; /**< Number of successfully used circuits using
  65. * this guard as first hop. */
  66. } entry_guard_t;
  67. entry_guard_t *entry_guard_get_by_id_digest(const char *digest);
  68. void entry_guards_changed(void);
  69. const smartlist_t *get_entry_guards(void);
  70. int num_live_entry_guards(int for_directory);
  71. #endif
  72. void remove_all_entry_guards(void);
  73. void entry_guards_compute_status(const or_options_t *options, time_t now);
  74. int entry_guard_register_connect_status(const char *digest, int succeeded,
  75. int mark_relay_status, time_t now);
  76. void entry_nodes_should_be_added(void);
  77. int entry_list_is_constrained(const or_options_t *options);
  78. const node_t *choose_random_entry(cpath_build_state_t *state);
  79. const node_t *choose_random_dirguard(dirinfo_type_t t);
  80. int entry_guards_parse_state(or_state_t *state, int set, char **msg);
  81. void entry_guards_update_state(or_state_t *state);
  82. int getinfo_helper_entry_guards(control_connection_t *conn,
  83. const char *question, char **answer,
  84. const char **errmsg);
  85. void mark_bridge_list(void);
  86. void sweep_bridge_list(void);
  87. int routerinfo_is_a_configured_bridge(const routerinfo_t *ri);
  88. int node_is_a_configured_bridge(const node_t *node);
  89. void learned_router_identity(const tor_addr_t *addr, uint16_t port,
  90. const char *digest);
  91. struct bridge_line_t;
  92. void bridge_add_from_config(struct bridge_line_t *bridge_line);
  93. void retry_bridge_descriptor_fetch_directly(const char *digest);
  94. void fetch_bridge_descriptors(const or_options_t *options, time_t now);
  95. void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
  96. int any_bridge_descriptors_known(void);
  97. int entries_known_but_down(const or_options_t *options);
  98. void entries_retry_all(const or_options_t *options);
  99. int any_bridge_supports_microdescriptors(void);
  100. const smartlist_t *get_socks_args_by_bridge_addrport(const tor_addr_t *addr,
  101. uint16_t port);
  102. int any_bridges_dont_support_microdescriptors(void);
  103. void entry_guards_free_all(void);
  104. const char *find_transport_name_by_bridge_addrport(const tor_addr_t *addr,
  105. uint16_t port);
  106. struct transport_t;
  107. int get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
  108. const struct transport_t **transport);
  109. int transport_is_needed(const char *transport_name);
  110. int validate_pluggable_transports_config(void);
  111. double pathbias_get_close_success_count(entry_guard_t *guard);
  112. double pathbias_get_use_success_count(entry_guard_t *guard);
  113. #endif