node_st.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef NODE_ST_H
  7. #define NODE_ST_H
  8. #include "feature/hs/hsdir_index_st.h"
  9. #include "lib/crypt_ops/crypto_ed25519.h"
  10. /** A node_t represents a Tor router.
  11. *
  12. * Specifically, a node_t is a Tor router as we are using it: a router that
  13. * we are considering for circuits, connections, and so on. A node_t is a
  14. * thin wrapper around the routerstatus, routerinfo, and microdesc for a
  15. * single router, and provides a consistent interface for all of them.
  16. *
  17. * Also, a node_t has mutable state. While a routerinfo, a routerstatus,
  18. * and a microdesc have[*] only the information read from a router
  19. * descriptor, a consensus entry, and a microdescriptor (respectively)...
  20. * a node_t has flags based on *our own current opinion* of the node.
  21. *
  22. * [*] Actually, there is some leftover information in each that is mutable.
  23. * We should try to excise that.
  24. */
  25. struct node_t {
  26. /* Indexing information */
  27. /** Used to look up the node_t by its identity digest. */
  28. HT_ENTRY(node_t) ht_ent;
  29. /** Used to look up the node_t by its ed25519 identity digest. */
  30. HT_ENTRY(node_t) ed_ht_ent;
  31. /** Position of the node within the list of nodes */
  32. int nodelist_idx;
  33. /** The identity digest of this node_t. No more than one node_t per
  34. * identity may exist at a time. */
  35. char identity[DIGEST_LEN];
  36. /** The ed25519 identity of this node_t. This field is nonzero iff we
  37. * currently have an ed25519 identity for this node in either md or ri,
  38. * _and_ this node has been inserted to the ed25519-to-node map in the
  39. * nodelist.
  40. */
  41. ed25519_public_key_t ed25519_id;
  42. microdesc_t *md;
  43. routerinfo_t *ri;
  44. routerstatus_t *rs;
  45. /* local info: copied from routerstatus, then possibly frobbed based
  46. * on experience. Authorities set this stuff directly. Note that
  47. * these reflect knowledge of the primary (IPv4) OR port only. */
  48. unsigned int is_running:1; /**< As far as we know, is this OR currently
  49. * running? */
  50. unsigned int is_valid:1; /**< Has a trusted dirserver validated this OR?
  51. * (For Authdir: Have we validated this OR?) */
  52. unsigned int is_fast:1; /** Do we think this is a fast OR? */
  53. unsigned int is_stable:1; /** Do we think this is a stable OR? */
  54. unsigned int is_possible_guard:1; /**< Do we think this is an OK guard? */
  55. unsigned int is_exit:1; /**< Do we think this is an OK exit? */
  56. unsigned int is_bad_exit:1; /**< Do we think this exit is censored, borked,
  57. * or otherwise nasty? */
  58. unsigned int is_hs_dir:1; /**< True iff this router is a hidden service
  59. * directory according to the authorities. */
  60. /* Local info: warning state. */
  61. unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
  62. * to this (unnamed) router by nickname?
  63. */
  64. /** Local info: we treat this node as if it rejects everything */
  65. unsigned int rejects_all:1;
  66. /* Local info: derived. */
  67. /** True if the IPv6 OR port is preferred over the IPv4 OR port.
  68. * XX/teor - can this become out of date if the torrc changes? */
  69. unsigned int ipv6_preferred:1;
  70. /** According to the geoip db what country is this router in? */
  71. /* XXXprop186 what is this suppose to mean with multiple OR ports? */
  72. country_t country;
  73. /* The below items are used only by authdirservers for
  74. * reachability testing. */
  75. /** When was the last time we could reach this OR? */
  76. time_t last_reachable; /* IPv4. */
  77. time_t last_reachable6; /* IPv6. */
  78. /* Hidden service directory index data. This is used by a service or client
  79. * in order to know what's the hs directory index for this node at the time
  80. * the consensus is set. */
  81. struct hsdir_index_t hsdir_index;
  82. };
  83. #endif