summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-02-17 11:30:44 -0500
committerDavid Goulet <dgoulet@torproject.org>2021-02-22 08:52:15 -0500
commit9541ed63a1af9e7d4632aa261976f053bad12438 (patch)
tree25a0b5c84440cb8690dc633237d820bc09409286 /src
parent38649b4f9522d5fc2b186d2a02cefb9abaefc519 (diff)
downloadtor-9541ed63a1af9e7d4632aa261976f053bad12438.tar.gz
tor-9541ed63a1af9e7d4632aa261976f053bad12438.zip
relay: Only authorities publish a DirPort
Relay will always publish 0 as DirPort value in their descriptor from now on except authorities. Related to #40282 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src')
-rw-r--r--src/feature/relay/router.c4
-rw-r--r--src/test/test_options.c43
2 files changed, 2 insertions, 45 deletions
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index cd3790856b..73e8393761 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -1357,8 +1357,8 @@ decide_to_advertise_dir_impl(const or_options_t *options,
int
router_should_advertise_dirport(const or_options_t *options, uint16_t dir_port)
{
- /* supports_tunnelled_dir_requests is not relevant, pass 0 */
- return decide_to_advertise_dir_impl(options, dir_port, 0) ? dir_port : 0;
+ /* Only authorities should advertise a DirPort now. */
+ return authdir_mode(options) ? dir_port : 0;
}
/** Front-end to decide_to_advertise_dir_impl(): return 0 if we don't want to
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 653b647dfe..e8d480eb19 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -302,8 +302,6 @@ test_options_validate(void *arg)
"ServerTransportOptions did not parse",
LOG_WARN, "\"slingsnappy\" is not a k=v", PH_VALIDATE);
- WANT_ERR("DirPort 8080\nDirCache 0",
- "DirPort configured but DirCache disabled.", PH_VALIDATE);
WANT_ERR("BridgeRelay 1\nDirCache 0",
"We're a bridge but DirCache is disabled.", PH_VALIDATE);
@@ -1932,18 +1930,6 @@ test_options_validate__publish_server_descriptor(void *ignored)
"PublishServerDescriptor line.");
tor_free(msg);
- free_options_test_data(tdata);
- tdata = get_options_test_data("BridgeRelay 1\n"
- "DirPort 999\n");
-
- mock_clean_saved_logs();
- ret = options_validate(NULL, tdata->opt, &msg);
- tt_int_op(ret, OP_EQ, -1);
- expect_log_msg("Can't set a DirPort on a bridge "
- "relay; disabling DirPort\n");
- tt_assert(!tdata->opt->DirPort_lines);
- tt_assert(!tdata->opt->DirPort_set);
-
done:
teardown_capture_of_logs();
policies_free_all();
@@ -3456,35 +3442,6 @@ test_options_validate__constrained_sockets(void *ignored)
"between 2048 and 262144 in 1024 byte increments.");
tor_free(msg);
- free_options_test_data(tdata);
- tdata = get_options_test_data("ConstrainedSockets 1\n"
- "ConstrainedSockSize 2048\n"
- "DirPort 999\n"
- "DirCache 1\n"
- );
- mock_clean_saved_logs();
- ret = options_validate(NULL, tdata->opt, &msg);
- tt_int_op(ret, OP_EQ, 0);
- expect_log_msg("You have requested constrained "
- "socket buffers while also serving directory entries via DirPort."
- " It is strongly suggested that you disable serving directory"
- " requests when system TCP buffer resources are scarce.\n");
- tor_free(msg);
-
- free_options_test_data(tdata);
- tdata = get_options_test_data("ConstrainedSockets 1\n"
- "ConstrainedSockSize 2048\n"
- );
- mock_clean_saved_logs();
- ret = options_validate(NULL, tdata->opt, &msg);
- tt_int_op(ret, OP_EQ, 0);
- expect_no_log_msg(
- "You have requested constrained socket buffers while also serving"
- " directory entries via DirPort. It is strongly suggested that "
- "you disable serving directory requests when system TCP buffer "
- "resources are scarce.\n");
- tor_free(msg);
-
done:
policies_free_all();
teardown_capture_of_logs();