mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Move all authdir_mode_*() functions into authmode.h
This commit is contained in:
parent
9385b7ec5f
commit
70539e3d5e
@ -138,6 +138,7 @@ LIBTOR_APP_TESTING_A_SOURCES = $(LIBTOR_APP_A_SOURCES)
|
|||||||
|
|
||||||
# The Directory Authority module.
|
# The Directory Authority module.
|
||||||
MODULE_DIRAUTH_SOURCES = \
|
MODULE_DIRAUTH_SOURCES = \
|
||||||
|
src/feature/dirauth/authmode.c \
|
||||||
src/feature/dirauth/dircollate.c \
|
src/feature/dirauth/dircollate.c \
|
||||||
src/feature/dirauth/dirvote.c \
|
src/feature/dirauth/dirvote.c \
|
||||||
src/feature/dirauth/shared_random.c \
|
src/feature/dirauth/shared_random.c \
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
#include "core/or/connection_or.h"
|
#include "core/or/connection_or.h"
|
||||||
#include "feature/control/control.h"
|
#include "feature/control/control.h"
|
||||||
#include "lib/crypt_ops/crypto_util.h"
|
#include "lib/crypt_ops/crypto_util.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
#include "feature/dircommon/directory.h"
|
#include "feature/dircommon/directory.h"
|
||||||
#include "feature/dircache/dirserv.h"
|
#include "feature/dircache/dirserv.h"
|
||||||
#include "feature/relay/dns.h"
|
#include "feature/relay/dns.h"
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#include "lib/crypt_ops/crypto_rand.h"
|
#include "lib/crypt_ops/crypto_rand.h"
|
||||||
#include "feature/dircommon/directory.h"
|
#include "feature/dircommon/directory.h"
|
||||||
#include "feature/dircache/dirserv.h"
|
#include "feature/dircache/dirserv.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
#include "feature/dirauth/reachability.h"
|
#include "feature/dirauth/reachability.h"
|
||||||
#include "feature/relay/dns.h"
|
#include "feature/relay/dns.h"
|
||||||
#include "feature/client/dnsserv.h"
|
#include "feature/client/dnsserv.h"
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "lib/math/fp.h"
|
#include "lib/math/fp.h"
|
||||||
#include "lib/time/tvdiff.h"
|
#include "lib/time/tvdiff.h"
|
||||||
#include "lib/encoding/confline.h"
|
#include "lib/encoding/confline.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
|
|
||||||
#include "core/or/crypt_path_st.h"
|
#include "core/or/crypt_path_st.h"
|
||||||
#include "core/or/origin_circuit_st.h"
|
#include "core/or/origin_circuit_st.h"
|
||||||
|
@ -62,6 +62,7 @@
|
|||||||
#include "core/or/scheduler.h"
|
#include "core/or/scheduler.h"
|
||||||
#include "feature/nodelist/torcert.h"
|
#include "feature/nodelist/torcert.h"
|
||||||
#include "core/or/channelpadding.h"
|
#include "core/or/channelpadding.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
|
|
||||||
#include "core/or/cell_st.h"
|
#include "core/or/cell_st.h"
|
||||||
#include "core/or/cell_queue_st.h"
|
#include "core/or/cell_queue_st.h"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "feature/control/fmt_serverstatus.h"
|
#include "feature/control/fmt_serverstatus.h"
|
||||||
|
|
||||||
#include "app/config/config.h"
|
#include "app/config/config.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
#include "feature/dirauth/voteflags.h"// XXXX remove
|
#include "feature/dirauth/voteflags.h"// XXXX remove
|
||||||
#include "feature/nodelist/nodelist.h"
|
#include "feature/nodelist/nodelist.h"
|
||||||
#include "feature/relay/router.h"
|
#include "feature/relay/router.h"
|
||||||
|
70
src/feature/dirauth/authmode.c
Normal file
70
src/feature/dirauth/authmode.c
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/* Copyright (c) 2001 Matej Pfajfar.
|
||||||
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||||
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||||
|
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||||
|
/* See LICENSE for licensing information */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file authmode.c
|
||||||
|
* \brief What kind of directory authority are we?
|
||||||
|
*
|
||||||
|
* If we're not an authority, these functions are all replaced with 0 in
|
||||||
|
* authmode.h.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "core/or/or.h"
|
||||||
|
#include "app/config/config.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
|
|
||||||
|
#include "feature/nodelist/routerinfo_st.h"
|
||||||
|
|
||||||
|
/** Return true iff we believe ourselves to be an authoritative
|
||||||
|
* directory server.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
authdir_mode(const or_options_t *options)
|
||||||
|
{
|
||||||
|
return options->AuthoritativeDir != 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.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
authdir_mode_handles_descs(const or_options_t *options, int purpose)
|
||||||
|
{
|
||||||
|
if (BUG(purpose < 0)) /* Deprecated. */
|
||||||
|
return authdir_mode(options);
|
||||||
|
else if (purpose == ROUTER_PURPOSE_GENERAL)
|
||||||
|
return authdir_mode_v3(options);
|
||||||
|
else if (purpose == ROUTER_PURPOSE_BRIDGE)
|
||||||
|
return authdir_mode_bridge(options);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/** Return true iff we are an authoritative directory server that
|
||||||
|
* publishes its own network statuses.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
authdir_mode_publishes_statuses(const or_options_t *options)
|
||||||
|
{
|
||||||
|
if (authdir_mode_bridge(options))
|
||||||
|
return 0;
|
||||||
|
return authdir_mode(options);
|
||||||
|
}
|
||||||
|
/** Return true iff we are an authoritative directory server that
|
||||||
|
* tests reachability of the descriptors it learns about.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
authdir_mode_tests_reachability(const or_options_t *options)
|
||||||
|
{
|
||||||
|
return authdir_mode(options);
|
||||||
|
}
|
||||||
|
/** Return true iff we believe ourselves to be a bridge authoritative
|
||||||
|
* directory server.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
authdir_mode_bridge(const or_options_t *options)
|
||||||
|
{
|
||||||
|
return authdir_mode(options) && options->BridgeAuthoritativeDir != 0;
|
||||||
|
}
|
@ -2,16 +2,22 @@
|
|||||||
/* See LICENSE for licensing information */
|
/* See LICENSE for licensing information */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file mode.h
|
* \file authmode.h
|
||||||
* \brief Standalone header file for directory authority mode.
|
* \brief Header file for directory authority mode.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef TOR_DIRAUTH_MODE_H
|
#ifndef TOR_DIRAUTH_MODE_H
|
||||||
#define TOR_DIRAUTH_MODE_H
|
#define TOR_DIRAUTH_MODE_H
|
||||||
|
|
||||||
|
#include "feature/relay/router.h"
|
||||||
|
|
||||||
#ifdef HAVE_MODULE_DIRAUTH
|
#ifdef HAVE_MODULE_DIRAUTH
|
||||||
|
|
||||||
#include "feature/relay/router.h"
|
int authdir_mode(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);
|
||||||
|
int authdir_mode_bridge(const or_options_t *options);
|
||||||
|
|
||||||
/* Return true iff we believe ourselves to be a v3 authoritative directory
|
/* Return true iff we believe ourselves to be a v3 authoritative directory
|
||||||
* server. */
|
* server. */
|
||||||
@ -23,16 +29,14 @@ authdir_mode_v3(const or_options_t *options)
|
|||||||
|
|
||||||
#else /* HAVE_MODULE_DIRAUTH */
|
#else /* HAVE_MODULE_DIRAUTH */
|
||||||
|
|
||||||
/* Without the dirauth module, we can't be a v3 directory authority, ever. */
|
#define authdir_mode(options) (((void)(options)),0)
|
||||||
|
#define authdir_mode_handles_descs(options,purpose) \
|
||||||
static inline int
|
(((void)(options)),((void)(purpose)),0)
|
||||||
authdir_mode_v3(const or_options_t *options)
|
#define authdir_mode_publishes_statuses(options) (((void)(options)),0)
|
||||||
{
|
#define authdir_mode_tests_reachability(options) (((void)(options)),0)
|
||||||
(void) options;
|
#define authdir_mode_bridge(options) (((void)(options)),0)
|
||||||
return 0;
|
#define authdir_mode_v3(options) (((void)(options)),0)
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* HAVE_MODULE_DIRAUTH */
|
#endif /* HAVE_MODULE_DIRAUTH */
|
||||||
|
|
||||||
#endif /* TOR_MODE_H */
|
#endif /* TOR_MODE_H */
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "core/or/channel.h"
|
#include "core/or/channel.h"
|
||||||
#include "core/or/channeltls.h"
|
#include "core/or/channeltls.h"
|
||||||
#include "core/or/command.h"
|
#include "core/or/command.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
#include "feature/nodelist/nodelist.h"
|
#include "feature/nodelist/nodelist.h"
|
||||||
#include "feature/nodelist/routerlist.h"
|
#include "feature/nodelist/routerlist.h"
|
||||||
#include "feature/nodelist/torcert.h"
|
#include "feature/nodelist/torcert.h"
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "core/mainloop/mainloop.h"
|
#include "core/mainloop/mainloop.h"
|
||||||
#include "core/or/policies.h"
|
#include "core/or/policies.h"
|
||||||
#include "feature/client/bridges.h"
|
#include "feature/client/bridges.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
#include "feature/dircommon/directory.h"
|
#include "feature/dircommon/directory.h"
|
||||||
#include "feature/dirclient/dirclient.h"
|
#include "feature/dirclient/dirclient.h"
|
||||||
#include "feature/dirclient/dlstatus.h"
|
#include "feature/dirclient/dlstatus.h"
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "app/config/config.h"
|
#include "app/config/config.h"
|
||||||
#include "core/or/policies.h"
|
#include "core/or/policies.h"
|
||||||
#include "feature/control/control.h"
|
#include "feature/control/control.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
#include "feature/dircommon/directory.h"
|
#include "feature/dircommon/directory.h"
|
||||||
#include "feature/nodelist/dirlist.h"
|
#include "feature/nodelist/dirlist.h"
|
||||||
#include "feature/nodelist/networkstatus.h"
|
#include "feature/nodelist/networkstatus.h"
|
||||||
|
@ -1348,57 +1348,6 @@ net_is_completely_disabled(void)
|
|||||||
return get_options()->DisableNetwork || we_are_fully_hibernating();
|
return get_options()->DisableNetwork || we_are_fully_hibernating();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true iff we believe ourselves to be an authoritative
|
|
||||||
* directory server.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
authdir_mode(const or_options_t *options)
|
|
||||||
{
|
|
||||||
return options->AuthoritativeDir != 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.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
authdir_mode_handles_descs(const or_options_t *options, int purpose)
|
|
||||||
{
|
|
||||||
if (BUG(purpose < 0)) /* Deprecated. */
|
|
||||||
return authdir_mode(options);
|
|
||||||
else if (purpose == ROUTER_PURPOSE_GENERAL)
|
|
||||||
return authdir_mode_v3(options);
|
|
||||||
else if (purpose == ROUTER_PURPOSE_BRIDGE)
|
|
||||||
return authdir_mode_bridge(options);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/** Return true iff we are an authoritative directory server that
|
|
||||||
* publishes its own network statuses.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
authdir_mode_publishes_statuses(const or_options_t *options)
|
|
||||||
{
|
|
||||||
if (authdir_mode_bridge(options))
|
|
||||||
return 0;
|
|
||||||
return authdir_mode(options);
|
|
||||||
}
|
|
||||||
/** Return true iff we are an authoritative directory server that
|
|
||||||
* tests reachability of the descriptors it learns about.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
authdir_mode_tests_reachability(const or_options_t *options)
|
|
||||||
{
|
|
||||||
return authdir_mode(options);
|
|
||||||
}
|
|
||||||
/** Return true iff we believe ourselves to be a bridge authoritative
|
|
||||||
* directory server.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
authdir_mode_bridge(const or_options_t *options)
|
|
||||||
{
|
|
||||||
return authdir_mode(options) && options->BridgeAuthoritativeDir != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return true iff we are trying to be a server.
|
/** Return true iff we are trying to be a server.
|
||||||
*/
|
*/
|
||||||
MOCK_IMPL(int,
|
MOCK_IMPL(int,
|
||||||
|
@ -61,12 +61,6 @@ int dir_server_mode(const or_options_t *options);
|
|||||||
int net_is_disabled(void);
|
int net_is_disabled(void);
|
||||||
int net_is_completely_disabled(void);
|
int net_is_completely_disabled(void);
|
||||||
|
|
||||||
int authdir_mode(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);
|
|
||||||
int authdir_mode_bridge(const or_options_t *options);
|
|
||||||
|
|
||||||
uint16_t router_get_active_listener_port_by_type_af(int listener_type,
|
uint16_t router_get_active_listener_port_by_type_af(int listener_type,
|
||||||
sa_family_t family);
|
sa_family_t family);
|
||||||
uint16_t router_get_advertised_or_port(const or_options_t *options);
|
uint16_t router_get_advertised_or_port(const or_options_t *options);
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
#include "core/or/channelpadding.h"
|
#include "core/or/channelpadding.h"
|
||||||
#include "core/or/connection_or.h"
|
#include "core/or/connection_or.h"
|
||||||
#include "app/config/statefile.h"
|
#include "app/config/statefile.h"
|
||||||
|
#include "feature/dirauth/authmode.h"
|
||||||
|
|
||||||
#include "feature/nodelist/networkstatus_st.h"
|
#include "feature/nodelist/networkstatus_st.h"
|
||||||
#include "core/or/or_circuit_st.h"
|
#include "core/or/or_circuit_st.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user