[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] dirauth: Move authdir_mode_v3() to module
commit 1f739e9b06974566685c662c3526384efd68ed32
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Wed May 2 13:42:24 2018 -0400
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@xxxxxxxxxxxxxx>
---
src/or/config.c | 1 +
src/or/dirauth/dirvote.c | 6 ++++--
src/or/dirauth/mode.h | 38 ++++++++++++++++++++++++++++++++++++++
src/or/dirauth/shared_random.c | 1 +
src/or/directory.c | 3 ++-
src/or/include.am | 1 +
src/or/main.c | 3 ++-
src/or/networkstatus.c | 3 ++-
src/or/nodelist.c | 2 ++
src/or/router.c | 10 ++--------
src/or/router.h | 1 -
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 a2b84991a..aa32b0aa2 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 66a530b6d..cbc3ff782 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 000000000..8a0d3142f
--- /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 f7ff5c58b..0a89fa8d2 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 2c5ee23f3..76caab6a3 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 9cae7d003..bc0b9d2bf 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 cf0df9ba7..e98432160 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 ac3e94e88..a7a76b236 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 675cbb005..bc9a79940 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 93b61b69e..cc1979bcc 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 e5efe577e..03eca9c65 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 7eb9ec799..914cf4ef1 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
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits