Tor  0.4.7.0-alpha-dev
authmode.c
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 authmode.c
9  * \brief What kind of directory authority are we?
10  *
11  * If we're not an authority, these functions are all replaced with 0 in
12  * authmode.h.
13  **/
14 
15 #include "core/or/or.h"
16 #include "app/config/config.h"
18 
20 
21 /** Return true iff we believe ourselves to be an authoritative
22  * directory server.
23  */
24 int
25 authdir_mode(const or_options_t *options)
26 {
27  return options->AuthoritativeDir != 0;
28 }
29 
30 /* Return true iff we believe ourselves to be a v3 authoritative directory
31  * server. */
32 int
33 authdir_mode_v3(const or_options_t *options)
34 {
35  return authdir_mode(options) && options->V3AuthoritativeDir != 0;
36 }
37 
38 /** Return true iff we are an authoritative directory server that is
39  * authoritative about receiving and serving descriptors of type
40  * <b>purpose</b> on its dirport.
41  */
42 int
43 authdir_mode_handles_descs(const or_options_t *options, int purpose)
44 {
45  if (BUG(purpose < 0)) /* Deprecated. */
46  return authdir_mode(options);
47  else if (purpose == ROUTER_PURPOSE_GENERAL)
48  return authdir_mode_v3(options);
49  else if (purpose == ROUTER_PURPOSE_BRIDGE)
50  return authdir_mode_bridge(options);
51  else
52  return 0;
53 }
54 /** Return true iff we are an authoritative directory server that
55  * publishes its own network statuses.
56  */
57 int
59 {
60  if (authdir_mode_bridge(options))
61  return 0;
62  return authdir_mode(options);
63 }
64 /** Return true iff we are an authoritative directory server that
65  * tests reachability of the descriptors it learns about.
66  */
67 int
69 {
70  return authdir_mode(options);
71 }
72 /** Return true iff we believe ourselves to be a bridge authoritative
73  * directory server.
74  */
75 int
77 {
78  return authdir_mode(options) && options->BridgeAuthoritativeDir != 0;
79 }
int authdir_mode(const or_options_t *options)
Definition: authmode.c:25
int authdir_mode_tests_reachability(const or_options_t *options)
Definition: authmode.c:68
int authdir_mode_handles_descs(const or_options_t *options, int purpose)
Definition: authmode.c:43
int authdir_mode_bridge(const or_options_t *options)
Definition: authmode.c:76
int authdir_mode_publishes_statuses(const or_options_t *options)
Definition: authmode.c:58
Header file for directory authority mode.
Header file for config.c.
Master header file for Tor-specific functionality.
Router descriptor structure.
#define ROUTER_PURPOSE_GENERAL
Definition: routerinfo_st.h:98
#define ROUTER_PURPOSE_BRIDGE
int V3AuthoritativeDir
int BridgeAuthoritativeDir