tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

node_st.h (4472B)


      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 
     15 #include "feature/hs/hsdir_index_st.h"
     16 #include "lib/crypt_ops/crypto_ed25519.h"
     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 */
     42  int nodelist_idx;
     43 
     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];
     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   */
     53  ed25519_public_key_t ed25519_id;
     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  unsigned int strip_guard:1; /**< True iff we should strip the Guard flag. */
     78  unsigned int strip_hsdir:1; /**< True iff we should strip the HSDir flag. */
     79  unsigned int strip_v2dir:1; /**< True iff we should strip the V2Dir flag. */
     80 
     81  /* Local info: warning state. */
     82 
     83  unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
     84                                      * to this (unnamed) router by nickname?
     85                                      */
     86 
     87  /** Local info: we treat this node as if it rejects everything */
     88  unsigned int rejects_all:1;
     89 
     90  /* Local info: derived. */
     91 
     92  /** True if the IPv6 OR port is preferred over the IPv4 OR port. */
     93  unsigned int ipv6_preferred:1;
     94 
     95  /** According to the geoip db what country is this router in? */
     96  /* IPv6: what is this supposed to mean with multiple OR ports? */
     97  country_t country;
     98 
     99  /* The below items are used only by authdirservers for
    100   * reachability testing. */
    101 
    102  /** When was the last time we could reach this OR? */
    103  time_t last_reachable;        /* IPv4. */
    104  time_t last_reachable6;       /* IPv6. */
    105 
    106  /* Hidden service directory index data. This is used by a service or client
    107   * in order to know what's the hs directory index for this node at the time
    108   * the consensus is set. */
    109  struct hsdir_index_t hsdir_index;
    110 };
    111 
    112 #endif /* !defined(NODE_ST_H) */