#include "routerset.h"
#include "transports.h"
+#include "node_st.h"
+
/** Information about a configured bridge. Currently this just matches the
* ones in the torrc file, but one day we may be able to learn about new
* bridges on our own, and remember them in the state file. */
#include "cpath_build_state_st.h"
#include "entry_connection_st.h"
+#include "node_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
#include "cpath_build_state_st.h"
#include "dir_connection_st.h"
#include "entry_connection_st.h"
+#include "node_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
#include "socks_request_st.h"
#include "control_connection_st.h"
#include "cpath_build_state_st.h"
#include "entry_connection_st.h"
+#include "node_st.h"
#include "or_connection_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
#include "dirauth/shared_random_state.h"
#include "dir_server_st.h"
+#include "node_st.h"
#include "vote_timing_st.h"
/**
#include "dir_connection_st.h"
#include "dir_server_st.h"
#include "entry_connection_st.h"
+#include "node_st.h"
#include "rend_service_descriptor_st.h"
/**
#include "dirauth/dirvote.h"
#include "dir_connection_st.h"
+#include "node_st.h"
#include "tor_version_st.h"
/**
#include "transports.h"
#include "statefile.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
/** A list of existing guard selection contexts. */
#include "cpath_build_state_st.h"
#include "crypt_path_st.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
/* A circuit is about to become an e2e rendezvous circuit. Check
#include "dirauth/shared_random_state.h"
#include "edge_connection_st.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
/* Trunnel */
#include "hs_service.h"
#include "nodelist.h"
+#include "node_st.h"
+
/* Send on the control port the "HS_DESC REQUESTEDÂ [...]" event.
*
* The onion_pk is the onion service public key, base64_blinded_pk is the
#include "dir_connection_st.h"
#include "edge_connection_st.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
/* Trunnel */
src/or/microdesc.h \
src/or/networkstatus.h \
src/or/nodelist.h \
+ src/or/node_st.h \
src/or/ntmain.h \
src/or/onion.h \
src/or/onion_fast.h \
#include "routerlist.h"
#include "routerparse.h"
+#include "node_st.h"
+
/** A data structure to hold a bunch of cached microdescriptors. There are
* two active files in the cache: a "cache file" that we mmap, and a "journal
* file" that we append to. Periodically, we rebuild the cache file to hold
#include "dir_connection_st.h"
#include "dir_server_st.h"
+#include "node_st.h"
/** Most recently received and validated v3 "ns"-flavored consensus network
* status. */
--- /dev/null
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef NODE_ST_H
+#define NODE_ST_H
+
+/** A node_t represents a Tor router.
+ *
+ * Specifically, a node_t is a Tor router as we are using it: a router that
+ * we are considering for circuits, connections, and so on. A node_t is a
+ * thin wrapper around the routerstatus, routerinfo, and microdesc for a
+ * single router, and provides a consistent interface for all of them.
+ *
+ * Also, a node_t has mutable state. While a routerinfo, a routerstatus,
+ * and a microdesc have[*] only the information read from a router
+ * descriptor, a consensus entry, and a microdescriptor (respectively)...
+ * a node_t has flags based on *our own current opinion* of the node.
+ *
+ * [*] Actually, there is some leftover information in each that is mutable.
+ * We should try to excise that.
+ */
+struct node_t {
+ /* Indexing information */
+
+ /** Used to look up the node_t by its identity digest. */
+ HT_ENTRY(node_t) ht_ent;
+ /** Used to look up the node_t by its ed25519 identity digest. */
+ HT_ENTRY(node_t) ed_ht_ent;
+ /** Position of the node within the list of nodes */
+ int nodelist_idx;
+
+ /** The identity digest of this node_t. No more than one node_t per
+ * identity may exist at a time. */
+ char identity[DIGEST_LEN];
+
+ /** The ed25519 identity of this node_t. This field is nonzero iff we
+ * currently have an ed25519 identity for this node in either md or ri,
+ * _and_ this node has been inserted to the ed25519-to-node map in the
+ * nodelist.
+ */
+ ed25519_public_key_t ed25519_id;
+
+ microdesc_t *md;
+ routerinfo_t *ri;
+ routerstatus_t *rs;
+
+ /* local info: copied from routerstatus, then possibly frobbed based
+ * on experience. Authorities set this stuff directly. Note that
+ * these reflect knowledge of the primary (IPv4) OR port only. */
+
+ unsigned int is_running:1; /**< As far as we know, is this OR currently
+ * running? */
+ unsigned int is_valid:1; /**< Has a trusted dirserver validated this OR?
+ * (For Authdir: Have we validated this OR?) */
+ unsigned int is_fast:1; /** Do we think this is a fast OR? */
+ unsigned int is_stable:1; /** Do we think this is a stable OR? */
+ unsigned int is_possible_guard:1; /**< Do we think this is an OK guard? */
+ unsigned int is_exit:1; /**< Do we think this is an OK exit? */
+ unsigned int is_bad_exit:1; /**< Do we think this exit is censored, borked,
+ * or otherwise nasty? */
+ unsigned int is_hs_dir:1; /**< True iff this router is a hidden service
+ * directory according to the authorities. */
+
+ /* Local info: warning state. */
+
+ unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
+ * to this (unnamed) router by nickname?
+ */
+
+ /** Local info: we treat this node as if it rejects everything */
+ unsigned int rejects_all:1;
+
+ /* Local info: derived. */
+
+ /** True if the IPv6 OR port is preferred over the IPv4 OR port.
+ * XX/teor - can this become out of date if the torrc changes? */
+ unsigned int ipv6_preferred:1;
+
+ /** According to the geoip db what country is this router in? */
+ /* XXXprop186 what is this suppose to mean with multiple OR ports? */
+ country_t country;
+
+ /* The below items are used only by authdirservers for
+ * reachability testing. */
+
+ /** When was the last time we could reach this OR? */
+ time_t last_reachable; /* IPv4. */
+ time_t last_reachable6; /* IPv6. */
+
+ /* Hidden service directory index data. This is used by a service or client
+ * in order to know what's the hs directory index for this node at the time
+ * the consensus is set. */
+ struct hsdir_index_t hsdir_index;
+};
+
+#endif
+
#include "dirauth/mode.h"
#include "dir_server_st.h"
+#include "node_st.h"
static void nodelist_drop_node(node_t *node, int remove_from_ht);
#define node_free(val) \
}
}
+/** Return 1 iff <b>node</b> has Exit flag and no BadExit flag.
+ * Otherwise, return 0.
+ */
+int node_is_good_exit(const node_t *node)
+{
+ return node->is_exit && ! node->is_bad_exit;
+}
+
/** Helper: return true iff a node has a usable amount of information*/
static inline int
node_is_usable(const node_t *node)
void node_get_verbose_nickname_by_id(const char *id_digest,
char *verbose_name_out);
int node_is_dir(const node_t *node);
+int node_is_good_exit(const node_t *node);
int node_has_any_descriptor(const node_t *node);
int node_has_preferred_descriptor(const node_t *node,
int for_direct_connect);
} microdesc_t;
-/** A node_t represents a Tor router.
- *
- * Specifically, a node_t is a Tor router as we are using it: a router that
- * we are considering for circuits, connections, and so on. A node_t is a
- * thin wrapper around the routerstatus, routerinfo, and microdesc for a
- * single router, and provides a consistent interface for all of them.
- *
- * Also, a node_t has mutable state. While a routerinfo, a routerstatus,
- * and a microdesc have[*] only the information read from a router
- * descriptor, a consensus entry, and a microdescriptor (respectively)...
- * a node_t has flags based on *our own current opinion* of the node.
- *
- * [*] Actually, there is some leftover information in each that is mutable.
- * We should try to excise that.
- */
-typedef struct node_t {
- /* Indexing information */
-
- /** Used to look up the node_t by its identity digest. */
- HT_ENTRY(node_t) ht_ent;
- /** Used to look up the node_t by its ed25519 identity digest. */
- HT_ENTRY(node_t) ed_ht_ent;
- /** Position of the node within the list of nodes */
- int nodelist_idx;
-
- /** The identity digest of this node_t. No more than one node_t per
- * identity may exist at a time. */
- char identity[DIGEST_LEN];
-
- /** The ed25519 identity of this node_t. This field is nonzero iff we
- * currently have an ed25519 identity for this node in either md or ri,
- * _and_ this node has been inserted to the ed25519-to-node map in the
- * nodelist.
- */
- ed25519_public_key_t ed25519_id;
-
- microdesc_t *md;
- routerinfo_t *ri;
- routerstatus_t *rs;
-
- /* local info: copied from routerstatus, then possibly frobbed based
- * on experience. Authorities set this stuff directly. Note that
- * these reflect knowledge of the primary (IPv4) OR port only. */
-
- unsigned int is_running:1; /**< As far as we know, is this OR currently
- * running? */
- unsigned int is_valid:1; /**< Has a trusted dirserver validated this OR?
- * (For Authdir: Have we validated this OR?) */
- unsigned int is_fast:1; /** Do we think this is a fast OR? */
- unsigned int is_stable:1; /** Do we think this is a stable OR? */
- unsigned int is_possible_guard:1; /**< Do we think this is an OK guard? */
- unsigned int is_exit:1; /**< Do we think this is an OK exit? */
- unsigned int is_bad_exit:1; /**< Do we think this exit is censored, borked,
- * or otherwise nasty? */
- unsigned int is_hs_dir:1; /**< True iff this router is a hidden service
- * directory according to the authorities. */
-
- /* Local info: warning state. */
-
- unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
- * to this (unnamed) router by nickname?
- */
-
- /** Local info: we treat this node as if it rejects everything */
- unsigned int rejects_all:1;
-
- /* Local info: derived. */
-
- /** True if the IPv6 OR port is preferred over the IPv4 OR port.
- * XX/teor - can this become out of date if the torrc changes? */
- unsigned int ipv6_preferred:1;
-
- /** According to the geoip db what country is this router in? */
- /* XXXprop186 what is this suppose to mean with multiple OR ports? */
- country_t country;
-
- /* The below items are used only by authdirservers for
- * reachability testing. */
-
- /** When was the last time we could reach this OR? */
- time_t last_reachable; /* IPv4. */
- time_t last_reachable6; /* IPv6. */
-
- /* Hidden service directory index data. This is used by a service or client
- * in order to know what's the hs directory index for this node at the time
- * the consensus is set. */
- struct hsdir_index_t hsdir_index;
-} node_t;
+typedef struct node_t node_t;
/** Linked list of microdesc hash lines for a single router in a directory
* vote.
/** Convert a circuit subtype to a circuit_t. */
#define TO_CIRCUIT(x) (&((x)->base_))
-/** Return 1 iff <b>node</b> has Exit flag and no BadExit flag.
- * Otherwise, return 0.
- */
-static inline int node_is_good_exit(const node_t *node)
-{
- return node->is_exit && ! node->is_bad_exit;
-}
-
/* limits for TCP send and recv buffer size used for constrained sockets */
#define MIN_CONSTRAINED_TCP_BUFFER 2048
#define MAX_CONSTRAINED_TCP_BUFFER 262144 /* 256k */
#include "ht.h"
#include "dir_server_st.h"
+#include "node_st.h"
#include "port_cfg_st.h"
/** Policy that addresses for incoming SOCKS connections must match. */
#include "crypt_path_st.h"
#include "dir_connection_st.h"
#include "dir_server_st.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
#include "port_cfg_st.h"
#include "dir_connection_st.h"
#include "dir_server_st.h"
+#include "node_st.h"
// #define DEBUG_ROUTERLIST
#include "routerparse.h"
#include "routerset.h"
+#include "node_st.h"
+
/** Return a new empty routerset. */
routerset_t *
routerset_new(void)
#include "dir_connection_st.h"
#include "entry_connection_st.h"
+#include "node_st.h"
#include "or_connection_st.h"
#include "socks_request_st.h"
#include "cpath_build_state_st.h"
#include "crypt_path_st.h"
#include "dir_connection_st.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
#include "test_helpers.h"
#include "routerlist.h"
#include "connection_st.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
#include "test.h"
#include "routerset.h"
#include "circuitbuild.h"
+#include "node_st.h"
#include "rend_encoded_v2_service_descriptor_st.h"
#include "rend_intro_point_st.h"
#include "util.h"
#include "voting_schedule.h"
+#include "node_st.h"
+
/** Test the validation of HS v3 addresses */
static void
test_validate_address(void *arg)
**/
#define CONTROL_PRIVATE
-#define CIRCUITBUILD_PRIVATE
-#define RENDCOMMON_PRIVATE
-#define RENDSERVICE_PRIVATE
-#define HS_SERVICE_PRIVATE
#include "or.h"
#include "test.h"
#include "hs_common.h"
#include "hs_control.h"
#include "nodelist.h"
-//#include "rendcommon.h"
-//#include "rendservice.h"
-//#include "routerset.h"
-//#include "circuitbuild.h"
+
+#include "node_st.h"
+
#include "test_helpers.h"
/* mock ID digest and longname for node that's in nodelist */
#include "cpath_build_state_st.h"
#include "crypt_path_st.h"
+#include "node_st.h"
#include "origin_circuit_st.h"
/* Trunnel */
#include "networkstatus.h"
#include "nodelist.h"
#include "torcert.h"
+
+#include "node_st.h"
+
#include "test.h"
/** Test the case when node_get_by_id() returns NULL,
#include "policies.h"
#include "test.h"
+#include "node_st.h"
#include "port_cfg_st.h"
/* Helper: assert that short_policy parses and writes back out as itself,
#include "statefile.h"
#include "dir_connection_st.h"
+#include "node_st.h"
#include "test.h"
#include "test_dir_common.h"
#include "routerparse.h"
#include "policies.h"
#include "nodelist.h"
+
+#include "node_st.h"
+
#include "test.h"
#define NS_MODULE routerset