diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-01-08 21:13:29 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-01-16 07:48:17 -0500 |
commit | 8a0c739467c87c6d7358d112bd1400250ad6e5c4 (patch) | |
tree | 573712476bafa3d8bda112b1c084fa0696343a88 | |
parent | 6e12a8f04714aa56308b06c691066cc3d4b0090b (diff) | |
download | tor-8a0c739467c87c6d7358d112bd1400250ad6e5c4.tar.gz tor-8a0c739467c87c6d7358d112bd1400250ad6e5c4.zip |
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.
-rw-r--r-- | src/core/include.am | 18 | ||||
-rw-r--r-- | src/feature/dircache/dircache_stub.c | 152 |
2 files changed, 166 insertions, 4 deletions
diff --git a/src/core/include.am b/src/core/include.am index bd36d01f21..1861f6cd41 100644 --- a/src/core/include.am +++ b/src/core/include.am @@ -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) diff --git a/src/feature/dircache/dircache_stub.c b/src/feature/dircache/dircache_stub.c new file mode 100644 index 0000000000..dcab3bbbb9 --- /dev/null +++ b/src/feature/dircache/dircache_stub.c @@ -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) +{ +} |