mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Extract node_t into its own header.
This commit is contained in:
parent
8b7df72359
commit
d2942d127d
@ -27,6 +27,8 @@
|
||||
#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. */
|
||||
|
@ -67,6 +67,7 @@
|
||||
|
||||
#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"
|
||||
|
||||
|
@ -100,6 +100,7 @@
|
||||
#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"
|
||||
|
@ -84,6 +84,7 @@
|
||||
#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"
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "dirauth/shared_random_state.h"
|
||||
|
||||
#include "dir_server_st.h"
|
||||
#include "node_st.h"
|
||||
#include "vote_timing_st.h"
|
||||
|
||||
/**
|
||||
|
@ -57,6 +57,7 @@
|
||||
#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"
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "dirauth/dirvote.h"
|
||||
|
||||
#include "dir_connection_st.h"
|
||||
#include "node_st.h"
|
||||
#include "tor_version_st.h"
|
||||
|
||||
/**
|
||||
|
@ -139,6 +139,7 @@
|
||||
#include "transports.h"
|
||||
#include "statefile.h"
|
||||
|
||||
#include "node_st.h"
|
||||
#include "origin_circuit_st.h"
|
||||
|
||||
/** A list of existing guard selection contexts. */
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#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
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "dirauth/shared_random_state.h"
|
||||
|
||||
#include "edge_connection_st.h"
|
||||
#include "node_st.h"
|
||||
#include "origin_circuit_st.h"
|
||||
|
||||
/* Trunnel */
|
||||
|
@ -15,6 +15,8 @@
|
||||
#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
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "dir_connection_st.h"
|
||||
#include "edge_connection_st.h"
|
||||
#include "node_st.h"
|
||||
#include "origin_circuit_st.h"
|
||||
|
||||
/* Trunnel */
|
||||
|
@ -248,6 +248,7 @@ ORHEADERS = \
|
||||
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 \
|
||||
|
@ -22,6 +22,8 @@
|
||||
#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
|
||||
|
@ -76,6 +76,7 @@
|
||||
|
||||
#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. */
|
||||
|
100
src/or/node_st.h
Normal file
100
src/or/node_st.h
Normal file
@ -0,0 +1,100 @@
|
||||
/* 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
|
||||
|
@ -69,6 +69,7 @@
|
||||
#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) \
|
||||
@ -634,6 +635,14 @@ nodelist_set_consensus(networkstatus_t *ns)
|
||||
}
|
||||
}
|
||||
|
||||
/** 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)
|
||||
|
@ -46,6 +46,7 @@ void node_get_verbose_nickname(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);
|
||||
|
97
src/or/or.h
97
src/or/or.h
@ -1857,94 +1857,7 @@ typedef struct microdesc_t {
|
||||
|
||||
} 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.
|
||||
@ -2385,14 +2298,6 @@ typedef enum {
|
||||
/** 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 */
|
||||
|
@ -31,6 +31,7 @@
|
||||
#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. */
|
||||
|
@ -42,6 +42,7 @@
|
||||
#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"
|
||||
|
||||
|
@ -127,6 +127,7 @@
|
||||
|
||||
#include "dir_connection_st.h"
|
||||
#include "dir_server_st.h"
|
||||
#include "node_st.h"
|
||||
|
||||
// #define DEBUG_ROUTERLIST
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "routerparse.h"
|
||||
#include "routerset.h"
|
||||
|
||||
#include "node_st.h"
|
||||
|
||||
/** Return a new empty routerset. */
|
||||
routerset_t *
|
||||
routerset_new(void)
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "dir_connection_st.h"
|
||||
#include "entry_connection_st.h"
|
||||
#include "node_st.h"
|
||||
#include "or_connection_st.h"
|
||||
#include "socks_request_st.h"
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#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"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "routerlist.h"
|
||||
|
||||
#include "connection_st.h"
|
||||
#include "node_st.h"
|
||||
#include "origin_circuit_st.h"
|
||||
|
||||
#include "test.h"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "routerset.h"
|
||||
#include "circuitbuild.h"
|
||||
|
||||
#include "node_st.h"
|
||||
#include "rend_encoded_v2_service_descriptor_st.h"
|
||||
#include "rend_intro_point_st.h"
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
#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)
|
||||
|
@ -7,10 +7,6 @@
|
||||
**/
|
||||
|
||||
#define CONTROL_PRIVATE
|
||||
#define CIRCUITBUILD_PRIVATE
|
||||
#define RENDCOMMON_PRIVATE
|
||||
#define RENDSERVICE_PRIVATE
|
||||
#define HS_SERVICE_PRIVATE
|
||||
|
||||
#include "or.h"
|
||||
#include "test.h"
|
||||
@ -19,10 +15,9 @@
|
||||
#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 */
|
||||
|
@ -55,6 +55,7 @@
|
||||
|
||||
#include "cpath_build_state_st.h"
|
||||
#include "crypt_path_st.h"
|
||||
#include "node_st.h"
|
||||
#include "origin_circuit_st.h"
|
||||
|
||||
/* Trunnel */
|
||||
|
@ -11,6 +11,9 @@
|
||||
#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,
|
||||
|
@ -10,6 +10,7 @@
|
||||
#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,
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "statefile.h"
|
||||
|
||||
#include "dir_connection_st.h"
|
||||
#include "node_st.h"
|
||||
|
||||
#include "test.h"
|
||||
#include "test_dir_common.h"
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include "routerparse.h"
|
||||
#include "policies.h"
|
||||
#include "nodelist.h"
|
||||
|
||||
#include "node_st.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#define NS_MODULE routerset
|
||||
|
Loading…
Reference in New Issue
Block a user