Disable feature/dircache files when dircache module is disabled.

To make Tor still work, we define a minimal dircache_stub.c file
that defines the entry points to the module that can actually be
seen by the compiler when we're building with dircache and relay
disabled.
This commit is contained in:
Nick Mathewson 2020-01-08 21:13:29 -05:00
parent 6e12a8f047
commit 8a0c739467
2 changed files with 166 additions and 4 deletions

View file

@ -91,10 +91,6 @@ LIBTOR_APP_A_SOURCES = \
src/feature/control/control_proto.c \
src/feature/control/fmt_serverstatus.c \
src/feature/control/getinfo_geoip.c \
src/feature/dircache/conscache.c \
src/feature/dircache/consdiffmgr.c \
src/feature/dircache/dircache.c \
src/feature/dircache/dirserv.c \
src/feature/dirclient/dirclient.c \
src/feature/dirclient/dlstatus.c \
src/feature/dircommon/consdiff.c \
@ -183,6 +179,13 @@ MODULE_RELAY_SOURCES = \
src/feature/relay/relay_sys.c \
src/feature/relay/transport_config.c
# The Directory Cache module.
MODULE_DIRCACHE_SOURCES = \
src/feature/dircache/conscache.c \
src/feature/dircache/consdiffmgr.c \
src/feature/dircache/dircache.c \
src/feature/dircache/dirserv.c
# The Directory Authority module.
MODULE_DIRAUTH_SOURCES = \
src/feature/dirauth/authmode.c \
@ -209,6 +212,12 @@ else
LIBTOR_APP_A_STUB_SOURCES += src/feature/relay/relay_stub.c
endif
if BUILD_MODULE_DIRCACHE
LIBTOR_APP_A_SOURCES += $(MODULE_DIRCACHE_SOURCES)
else
LIBTOR_APP_A_STUB_SOURCES += src/feature/dircache/dircache_stub.c
endif
if BUILD_MODULE_DIRAUTH
LIBTOR_APP_A_SOURCES += $(MODULE_DIRAUTH_SOURCES)
else
@ -222,6 +231,7 @@ if UNITTESTS_ENABLED
# Add the sources of the modules that are needed for tests to work here.
LIBTOR_APP_TESTING_A_SOURCES += $(MODULE_RELAY_SOURCES)
LIBTOR_APP_TESTING_A_SOURCES += $(MODULE_DIRCACHE_SOURCES)
LIBTOR_APP_TESTING_A_SOURCES += $(MODULE_DIRAUTH_SOURCES)
src_core_libtor_app_testing_a_SOURCES = $(LIBTOR_APP_TESTING_A_SOURCES)

View file

@ -0,0 +1,152 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* @file dircache_stub.c
* @brief Stub declarations for use when dircache module is disabled.
**/
#include "core/or/or.h"
#include "feature/dircache/consdiffmgr.h"
#include "feature/dircache/dircache.h"
#include "feature/dircache/dirserv.h"
#include "feature/dircommon/dir_connection_st.h"
int
directory_handle_command(dir_connection_t *conn)
{
(void) conn;
tor_assert_nonfatal_unreached_once();
return -1;
}
int
connection_dirserv_flushed_some(dir_connection_t *conn)
{
(void) conn;
tor_assert_nonfatal_unreached_once();
return -1;
}
int
directory_fetches_from_authorities(const or_options_t *options)
{
(void) options;
return 0;
}
int
directory_fetches_dir_info_early(const or_options_t *options)
{
(void) options;
return 0;
}
int
directory_fetches_dir_info_later(const or_options_t *options)
{
(void) options;
return 0;
}
int
directory_caches_unknown_auth_certs(const or_options_t *options)
{
(void) options;
return 0;
}
int
directory_caches_dir_info(const or_options_t *options)
{
(void) options;
return 0;
}
int
directory_permits_begindir_requests(const or_options_t *options)
{
(void) options;
return 0;
}
int
directory_too_idle_to_fetch_descriptors(const or_options_t *options,
time_t now)
{
(void)options;
(void)now;
return 0;
}
cached_dir_t *
dirserv_get_consensus(const char *flavor_name)
{
(void) flavor_name;
return NULL;
}
void
dir_conn_clear_spool(dir_connection_t *conn)
{
if (!conn)
return;
tor_assert_nonfatal_once(conn->spool == NULL);
}
void
consdiffmgr_enable_background_compression(void)
{
}
void
dirserv_set_cached_consensus_networkstatus(const char *networkstatus,
size_t networkstatus_len,
const char *flavor_name,
const common_digests_t *digests,
const uint8_t *sha3_as_signed,
time_t published)
{
(void)networkstatus;
(void)networkstatus_len;
(void)flavor_name;
(void)digests;
(void)sha3_as_signed;
(void)published;
}
int
consdiffmgr_add_consensus(const char *consensus,
size_t consensus_len,
const networkstatus_t *as_parsed)
{
(void)consensus;
(void)consensus_len;
(void)as_parsed;
return 0;
}
int
consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem_t **cfg)
{
(void)cfg;
return 0;
}
int
consdiffmgr_cleanup(void)
{
return 0;
}
void
consdiffmgr_free_all(void)
{
}
void
dirserv_free_all(void)
{
}