diff options
author | David Goulet <dgoulet@torproject.org> | 2018-05-02 13:42:24 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-05-02 13:42:24 -0400 |
commit | 1f739e9b06974566685c662c3526384efd68ed32 (patch) | |
tree | c2fdb73da5441b405518a5cc404e2af2299959eb /src/or | |
parent | 1ef1ed76d864b6c3147c0444d9114ebcc53c18b5 (diff) | |
download | tor-1f739e9b06974566685c662c3526384efd68ed32.tar.gz tor-1f739e9b06974566685c662c3526384efd68ed32.zip |
dirauth: Move authdir_mode_v3() to module
This function must return false if the module is not compiled in. In order to
do that, we move the authdir_mode_v3() function out of router.c and into the
dirauth module new header file named mode.h.
It is always returning false if we don't have the module.
Closes #25990
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 1 | ||||
-rw-r--r-- | src/or/dirauth/dirvote.c | 6 | ||||
-rw-r--r-- | src/or/dirauth/mode.h | 38 | ||||
-rw-r--r-- | src/or/dirauth/shared_random.c | 1 | ||||
-rw-r--r-- | src/or/directory.c | 3 | ||||
-rw-r--r-- | src/or/include.am | 1 | ||||
-rw-r--r-- | src/or/main.c | 3 | ||||
-rw-r--r-- | src/or/networkstatus.c | 3 | ||||
-rw-r--r-- | src/or/nodelist.c | 2 | ||||
-rw-r--r-- | src/or/router.c | 10 | ||||
-rw-r--r-- | src/or/router.h | 1 | ||||
-rw-r--r-- | src/or/routerlist.c | 1 |
12 files changed, 56 insertions, 14 deletions
diff --git a/src/or/config.c b/src/or/config.c index a2b84991a0..aa32b0aa21 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -112,6 +112,7 @@ #include "procmon.h" #include "dirauth/dirvote.h" +#include "dirauth/mode.h" #ifdef HAVE_SYSTEMD # if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 66a530b6db..cbc3ff7829 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -9,7 +9,6 @@ #include "dircollate.h" #include "directory.h" #include "dirserv.h" -#include "dirvote.h" #include "microdesc.h" #include "networkstatus.h" #include "nodelist.h" @@ -23,9 +22,12 @@ #include "routerparse.h" #include "entrynodes.h" /* needed for guardfraction methods */ #include "torcert.h" -#include "shared_random_state.h" #include "voting_schedule.h" +#include "dirauth/dirvote.h" +#include "dirauth/mode.h" +#include "dirauth/shared_random_state.h" + /** * \file dirvote.c * \brief Functions to compute directory consensus, and schedule voting. diff --git a/src/or/dirauth/mode.h b/src/or/dirauth/mode.h new file mode 100644 index 0000000000..8a0d3142f1 --- /dev/null +++ b/src/or/dirauth/mode.h @@ -0,0 +1,38 @@ +/* Copyright (c) 2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file mode.h + * \brief Standalone header file for directory authority mode. + **/ + +#ifndef TOR_DIRAUTH_MODE_H +#define TOR_DIRAUTH_MODE_H + +#ifdef HAVE_MODULE_DIRAUTH + +#include "router.h" + +/* Return true iff we believe ourselves to be a v3 authoritative directory + * server. */ +static inline int +authdir_mode_v3(const or_options_t *options) +{ + return authdir_mode(options) && options->V3AuthoritativeDir != 0; +} + +#else /* HAVE_MODULE_DIRAUTH */ + +/* Without the dirauth module, we can't be a v3 directory authority, ever. */ + +static inline int +authdir_mode_v3(const or_options_t *options) +{ + (void) options; + return 0; +} + +#endif /* HAVE_MODULE_DIRAUTH */ + +#endif /* TOR_MODE_H */ + diff --git a/src/or/dirauth/shared_random.c b/src/or/dirauth/shared_random.c index f7ff5c58bb..0a89fa8d2d 100644 --- a/src/or/dirauth/shared_random.c +++ b/src/or/dirauth/shared_random.c @@ -101,6 +101,7 @@ #include "voting_schedule.h" #include "dirauth/dirvote.h" +#include "dirauth/mode.h" /* String prefix of shared random values in votes/consensuses. */ static const char previous_srv_str[] = "shared-rand-previous-value"; diff --git a/src/or/directory.c b/src/or/directory.c index 2c5ee23f3a..76caab6a3c 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -40,7 +40,6 @@ #include "routerlist.h" #include "routerparse.h" #include "routerset.h" -#include "dirauth/shared_random.h" #if defined(EXPORTMALLINFO) && defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO) #if !defined(OpenBSD) @@ -49,6 +48,8 @@ #endif #include "dirauth/dirvote.h" +#include "dirauth/mode.h" +#include "dirauth/shared_random.h" /** * \file directory.c diff --git a/src/or/include.am b/src/or/include.am index 9cae7d0039..bc0b9d2bfb 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -279,6 +279,7 @@ ORHEADERS = \ ORHEADERS += \ src/or/dirauth/dircollate.h \ src/or/dirauth/dirvote.h \ + src/or/dirauth/mode.h \ src/or/dirauth/shared_random.h \ src/or/dirauth/shared_random_state.h diff --git a/src/or/main.c b/src/or/main.c index cf0df9ba79..e984321601 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -103,7 +103,6 @@ #include "routerlist.h" #include "routerparse.h" #include "scheduler.h" -#include "dirauth/shared_random.h" #include "statefile.h" #include "status.h" #include "tor_api.h" @@ -119,6 +118,8 @@ #include <event2/event.h> #include "dirauth/dirvote.h" +#include "dirauth/mode.h" +#include "dirauth/shared_random.h" #ifdef HAVE_SYSTEMD # if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index ac3e94e884..a7a76b236c 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -63,13 +63,14 @@ #include "routerlist.h" #include "routerparse.h" #include "scheduler.h" -#include "dirauth/shared_random.h" #include "transports.h" #include "torcert.h" #include "channelpadding.h" #include "voting_schedule.h" #include "dirauth/dirvote.h" +#include "dirauth/mode.h" +#include "dirauth/shared_random.h" /** Most recently received and validated v3 "ns"-flavored consensus network * status. */ diff --git a/src/or/nodelist.c b/src/or/nodelist.c index 675cbb0056..bc9a79940b 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -66,6 +66,8 @@ #include <string.h> +#include "dirauth/mode.h" + static void nodelist_drop_node(node_t *node, int remove_from_ht); #define node_free(val) \ FREE_AND_NULL(node_t, node_free_, (val)) diff --git a/src/or/router.c b/src/or/router.c index 93b61b69ef..cc1979bcc9 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -35,6 +35,8 @@ #include "transports.h" #include "routerset.h" +#include "dirauth/mode.h" + /** * \file router.c * \brief Miscellaneous relay functionality, including RSA key maintenance, @@ -1612,14 +1614,6 @@ authdir_mode(const or_options_t *options) { return options->AuthoritativeDir != 0; } -/** Return true iff we believe ourselves to be a v3 authoritative - * directory server. - */ -int -authdir_mode_v3(const or_options_t *options) -{ - return authdir_mode(options) && options->V3AuthoritativeDir != 0; -} /** Return true iff we are an authoritative directory server that is * authoritative about receiving and serving descriptors of type * <b>purpose</b> on its dirport. diff --git a/src/or/router.h b/src/or/router.h index e5efe577e3..03eca9c65d 100644 --- a/src/or/router.h +++ b/src/or/router.h @@ -55,7 +55,6 @@ void router_perform_bandwidth_test(int num_circs, time_t now); int net_is_disabled(void); int authdir_mode(const or_options_t *options); -int authdir_mode_v3(const or_options_t *options); int authdir_mode_handles_descs(const or_options_t *options, int purpose); int authdir_mode_publishes_statuses(const or_options_t *options); int authdir_mode_tests_reachability(const or_options_t *options); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 7eb9ec7990..914cf4ef16 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -122,6 +122,7 @@ #include "torcert.h" #include "dirauth/dirvote.h" +#include "dirauth/mode.h" // #define DEBUG_ROUTERLIST |