Update copyrights to 2021, using "make update-copyright"
[tor.git] / src / feature / nodelist / node_st.h
blobb15e7154c485c62749d8b4e47a29dc8faee88556
1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * @file node_st.h
9 * @brief Node information structure.
10 **/
12 #ifndef NODE_ST_H
13 #define NODE_ST_H
15 #include "feature/hs/hsdir_index_st.h"
16 #include "lib/crypt_ops/crypto_ed25519.h"
17 #include "ext/ht.h"
19 /** A node_t represents a Tor router.
21 * Specifically, a node_t is a Tor router as we are using it: a router that
22 * we are considering for circuits, connections, and so on. A node_t is a
23 * thin wrapper around the routerstatus, routerinfo, and microdesc for a
24 * single router, and provides a consistent interface for all of them.
26 * Also, a node_t has mutable state. While a routerinfo, a routerstatus,
27 * and a microdesc have[*] only the information read from a router
28 * descriptor, a consensus entry, and a microdescriptor (respectively)...
29 * a node_t has flags based on *our own current opinion* of the node.
31 * [*] Actually, there is some leftover information in each that is mutable.
32 * We should try to excise that.
34 struct node_t {
35 /* Indexing information */
37 /** Used to look up the node_t by its identity digest. */
38 HT_ENTRY(node_t) ht_ent;
39 /** Used to look up the node_t by its ed25519 identity digest. */
40 HT_ENTRY(node_t) ed_ht_ent;
41 /** Position of the node within the list of nodes */
42 int nodelist_idx;
44 /** The identity digest of this node_t. No more than one node_t per
45 * identity may exist at a time. */
46 char identity[DIGEST_LEN];
48 /** The ed25519 identity of this node_t. This field is nonzero iff we
49 * currently have an ed25519 identity for this node in either md or ri,
50 * _and_ this node has been inserted to the ed25519-to-node map in the
51 * nodelist.
53 ed25519_public_key_t ed25519_id;
55 microdesc_t *md;
56 routerinfo_t *ri;
57 routerstatus_t *rs;
59 /* local info: copied from routerstatus, then possibly frobbed based
60 * on experience. Authorities set this stuff directly. Note that
61 * these reflect knowledge of the primary (IPv4) OR port only. */
63 unsigned int is_running:1; /**< As far as we know, is this OR currently
64 * running? */
65 unsigned int is_valid:1; /**< Has a trusted dirserver validated this OR?
66 * (For Authdir: Have we validated this OR?) */
67 unsigned int is_fast:1; /** Do we think this is a fast OR? */
68 unsigned int is_stable:1; /** Do we think this is a stable OR? */
69 unsigned int is_possible_guard:1; /**< Do we think this is an OK guard? */
70 unsigned int is_exit:1; /**< Do we think this is an OK exit? */
71 unsigned int is_bad_exit:1; /**< Do we think this exit is censored, borked,
72 * or otherwise nasty? */
73 unsigned int is_hs_dir:1; /**< True iff this router is a hidden service
74 * directory according to the authorities. */
76 /* Local info: warning state. */
78 unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
79 * to this (unnamed) router by nickname?
82 /** Local info: we treat this node as if it rejects everything */
83 unsigned int rejects_all:1;
85 /* Local info: derived. */
87 /** True if the IPv6 OR port is preferred over the IPv4 OR port. */
88 unsigned int ipv6_preferred:1;
90 /** According to the geoip db what country is this router in? */
91 /* IPv6: what is this supposed to mean with multiple OR ports? */
92 country_t country;
94 /* The below items are used only by authdirservers for
95 * reachability testing. */
97 /** When was the last time we could reach this OR? */
98 time_t last_reachable; /* IPv4. */
99 time_t last_reachable6; /* IPv6. */
101 /* Hidden service directory index data. This is used by a service or client
102 * in order to know what's the hs directory index for this node at the time
103 * the consensus is set. */
104 struct hsdir_index_t hsdir_index;
107 #endif /* !defined(NODE_ST_H) */