tor

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

dirlist.h (3805B)


      1 /* Copyright (c) 2001-2004, Roger Dingledine.
      2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
      3 * Copyright (c) 2007-2021, The Tor Project, Inc. */
      4 /* See LICENSE for licensing information */
      5 
      6 /**
      7 * \file dirlist.h
      8 * \brief Header file for dirlist.c
      9 **/
     10 
     11 #ifndef TOR_DIRLIST_H
     12 #define TOR_DIRLIST_H
     13 
     14 typedef struct auth_dirport_t auth_dirport_t;
     15 /**
     16 * Different usages for an authority's HTTP directory port.
     17 *
     18 * Historically, only legacy ports existed; proposal 330 added multiple types
     19 * of dirport to better enable authorities to offload work and resist DoS
     20 * attacks.
     21 **/
     22 typedef enum auth_dirport_usage_t {
     23  /** Flag for an authority's dirport that is intended for misc/legacy
     24   * usage. May be used when no other dirport is available. */
     25  AUTH_USAGE_LEGACY,
     26  /** Flag for an authority's dirport that is intended for descriptor uploads
     27   * only. */
     28  AUTH_USAGE_UPLOAD,
     29  /** Flag for an authority's dirport that is intended for voting only */
     30  AUTH_USAGE_VOTING,
     31  /** Flag for an authority's dirport that is intended for relay downloads
     32   * only. */
     33  AUTH_USAGE_DOWNLOAD,
     34 } auth_dirport_usage_t;
     35 
     36 int get_n_authorities(dirinfo_type_t type);
     37 const smartlist_t *router_get_trusted_dir_servers(void);
     38 const smartlist_t *router_get_fallback_dir_servers(void);
     39 smartlist_t *router_get_trusted_dir_servers_mutable(void);
     40 smartlist_t *router_get_fallback_dir_servers_mutable(void);
     41 void mark_all_dirservers_up(smartlist_t *server_list);
     42 
     43 auth_dirport_usage_t auth_dirport_usage_for_purpose(int purpose);
     44 
     45 dir_server_t *router_get_trusteddirserver_by_digest(const char *d);
     46 dir_server_t *router_get_fallback_dirserver_by_digest(
     47                                                   const char *digest);
     48 int router_digest_is_fallback_dir(const char *digest);
     49 MOCK_DECL(dir_server_t *, trusteddirserver_get_by_v3_auth_digest,
     50          (const char *d));
     51 
     52 MOCK_DECL(int, router_digest_is_trusted_dir_type,
     53        (const char *digest, dirinfo_type_t type));
     54 
     55 const tor_addr_port_t *trusted_dir_server_get_dirport(const dir_server_t *ds,
     56                                                  auth_dirport_usage_t usage,
     57                                                  int addr_family);
     58 const tor_addr_port_t *trusted_dir_server_get_dirport_exact(
     59                                                  const dir_server_t *ds,
     60                                                  auth_dirport_usage_t usage,
     61                                                  int addr_family);
     62 
     63 bool router_addr_is_trusted_dir_type(const tor_addr_t *addr,
     64                                     dirinfo_type_t type);
     65 #define router_addr_is_trusted_dir(d) \
     66  router_addr_is_trusted_dir_type((d), NO_DIRINFO)
     67 
     68 #define router_digest_is_trusted_dir(d) \
     69  router_digest_is_trusted_dir_type((d), NO_DIRINFO)
     70 
     71 dir_server_t *trusted_dir_server_new(const char *nickname, const char *address,
     72                       uint16_t dir_port, uint16_t or_port,
     73                       const tor_addr_port_t *addrport_ipv6,
     74                       const char *digest, const char *v3_auth_digest,
     75                       dirinfo_type_t type, double weight);
     76 void trusted_dir_server_add_dirport(dir_server_t *ds,
     77                                    auth_dirport_usage_t usage,
     78                                    const tor_addr_port_t *dirport);
     79 dir_server_t *fallback_dir_server_new(const tor_addr_t *addr,
     80                                      uint16_t dir_port, uint16_t or_port,
     81                                      const tor_addr_port_t *addrport_ipv6,
     82                                      const char *id_digest, double weight);
     83 void dir_server_add(dir_server_t *ent);
     84 
     85 void clear_dir_servers(void);
     86 void dirlist_free_all(void);
     87 
     88 MOCK_DECL(void, dirlist_add_trusted_dir_addresses, (void));
     89 
     90 #endif /* !defined(TOR_DIRLIST_H) */