From 1f739e9b06974566685c662c3526384efd68ed32 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 2 May 2018 13:42:24 -0400 Subject: 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 --- src/or/dirauth/dirvote.c | 6 ++++-- src/or/dirauth/mode.h | 38 ++++++++++++++++++++++++++++++++++++++ src/or/dirauth/shared_random.c | 1 + 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/or/dirauth/mode.h (limited to 'src/or/dirauth') 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"; -- cgit v1.2.3-54-g00ecf