Tor  0.4.8.0-alpha-dev
node_st.h
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-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * @file node_st.h
9  * @brief Node information structure.
10  **/
11 
12 #ifndef NODE_ST_H
13 #define NODE_ST_H
14 
17 #include "ext/ht.h"
18 
19 /** A node_t represents a Tor router.
20  *
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.
25  *
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.
30  *
31  * [*] Actually, there is some leftover information in each that is mutable.
32  * We should try to excise that.
33  */
34 struct node_t {
35  /* Indexing information */
36 
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 */
43 
44  /** The identity digest of this node_t. No more than one node_t per
45  * identity may exist at a time. */
47 
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.
52  */
54 
55  microdesc_t *md;
56  routerinfo_t *ri;
57  routerstatus_t *rs;
58 
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. */
62 
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  /** Is this unsuitable for use as anything besides a middle relay? */
74  unsigned int is_middle_only:1;
75  unsigned int is_hs_dir:1; /**< True iff this router is a hidden service
76  * directory according to the authorities. */
77 
78  /* Local info: warning state. */
79 
80  unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
81  * to this (unnamed) router by nickname?
82  */
83 
84  /** Local info: we treat this node as if it rejects everything */
85  unsigned int rejects_all:1;
86 
87  /* Local info: derived. */
88 
89  /** True if the IPv6 OR port is preferred over the IPv4 OR port. */
90  unsigned int ipv6_preferred:1;
91 
92  /** According to the geoip db what country is this router in? */
93  /* IPv6: what is this supposed to mean with multiple OR ports? */
95 
96  /* The below items are used only by authdirservers for
97  * reachability testing. */
98 
99  /** When was the last time we could reach this OR? */
100  time_t last_reachable; /* IPv4. */
101  time_t last_reachable6; /* IPv6. */
102 
103  /* Hidden service directory index data. This is used by a service or client
104  * in order to know what's the hs directory index for this node at the time
105  * the consensus is set. */
106  struct hsdir_index_t hsdir_index;
107 };
108 
109 #endif /* !defined(NODE_ST_H) */
int16_t country_t
Definition: country.h:17
Header for crypto_ed25519.c.
#define DIGEST_LEN
Definition: digest_sizes.h:20
HS directory index structure.
Definition: node_st.h:34
unsigned int is_bad_exit
Definition: node_st.h:71
country_t country
Definition: node_st.h:94
unsigned int is_running
Definition: node_st.h:63
int nodelist_idx
Definition: node_st.h:42
HT_ENTRY(node_t) ed_ht_ent
unsigned int rejects_all
Definition: node_st.h:85
unsigned int is_hs_dir
Definition: node_st.h:75
unsigned int is_valid
Definition: node_st.h:65
ed25519_public_key_t ed25519_id
Definition: node_st.h:53
char identity[DIGEST_LEN]
Definition: node_st.h:46
unsigned int is_possible_guard
Definition: node_st.h:69
unsigned int is_stable
Definition: node_st.h:68
unsigned int is_exit
Definition: node_st.h:70
unsigned int is_middle_only
Definition: node_st.h:74
time_t last_reachable
Definition: node_st.h:100
unsigned int ipv6_preferred
Definition: node_st.h:90
unsigned int name_lookup_warned
Definition: node_st.h:80
HT_ENTRY(node_t) ht_ent