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 */
9 * \brief What kind of directory authority are we?
11 * If we're not an authority, these functions are all replaced with 0 in
15 #include "core/or/or.h"
16 #include "app/config/config.h"
17 #include "feature/dirauth/authmode.h"
19 #include "feature/nodelist/routerinfo_st.h"
21 /** Return true iff we believe ourselves to be an authoritative
25 authdir_mode(const or_options_t
*options
)
27 return options
->AuthoritativeDir
!= 0;
30 /* Return true iff we believe ourselves to be a v3 authoritative directory
33 authdir_mode_v3(const or_options_t
*options
)
35 return authdir_mode(options
) && options
->V3AuthoritativeDir
!= 0;
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.
43 authdir_mode_handles_descs(const or_options_t
*options
, int purpose
)
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
);
54 /** Return true iff we are an authoritative directory server that
55 * publishes its own network statuses.
58 authdir_mode_publishes_statuses(const or_options_t
*options
)
60 if (authdir_mode_bridge(options
))
62 return authdir_mode(options
);
64 /** Return true iff we are an authoritative directory server that
65 * tests reachability of the descriptors it learns about.
68 authdir_mode_tests_reachability(const or_options_t
*options
)
70 return authdir_mode(options
);
72 /** Return true iff we believe ourselves to be a bridge authoritative
76 authdir_mode_bridge(const or_options_t
*options
)
78 return authdir_mode(options
) && options
->BridgeAuthoritativeDir
!= 0;