From 1f58b0ca262f16c76b25c8cb39250f14a1ab4fc1 Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 20 Dec 2019 14:31:49 +1000 Subject: [PATCH 1/2] router: Authorities add their own IPv6 to trusted dir servers Authorities currently add themselves to the trusted dir servers list, but if they have an IPv6 ORPort, they leave it out. This commit makes authorities add their own IPv6 ORPort to the trusted dir servers list. Closes ticket 32822. --- changes/ticket32822 | 5 +++++ src/feature/nodelist/dirlist.c | 2 +- src/feature/relay/router.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changes/ticket32822 diff --git a/changes/ticket32822 b/changes/ticket32822 new file mode 100644 index 0000000000..ca62f0cc53 --- /dev/null +++ b/changes/ticket32822 @@ -0,0 +1,5 @@ + o Minor features (directory authorities, IPv6): + - Make authorities add their IPv6 ORPort (if any) to the trusted dir + servers list. Authorities currently add themselves to the trusted dir + servers list, but they only add their IPv4 address and ports to the list. + Closes ticket 32822. diff --git a/src/feature/nodelist/dirlist.c b/src/feature/nodelist/dirlist.c index f49d991f9b..bd647ab530 100644 --- a/src/feature/nodelist/dirlist.c +++ b/src/feature/nodelist/dirlist.c @@ -294,7 +294,7 @@ dir_server_new(int is_authority, ent->is_authority = is_authority; ent->type = type; ent->weight = weight; - if (addrport_ipv6) { + if (addrport_ipv6 && tor_addr_port_is_valid_ap(addrport_ipv6, 0)) { if (tor_addr_family(&addrport_ipv6->addr) != AF_INET6) { log_warn(LD_BUG, "Hey, I got a non-ipv6 addr as addrport_ipv6."); tor_addr_make_unspec(&ent->ipv6_addr); diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 5e00e4cb32..57da735e87 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -1148,10 +1148,12 @@ init_keys(void) ds = router_get_trusteddirserver_by_digest(digest); if (!ds) { + tor_addr_port_t ipv6_orport; + router_get_advertised_ipv6_or_ap(options, &ipv6_orport); ds = trusted_dir_server_new(options->Nickname, NULL, router_get_advertised_dir_port(options, 0), router_get_advertised_or_port(options), - NULL, + &ipv6_orport, digest, v3_digest, type, 0.0); From 82010b0e2e995b3a4c7030c5f2339480a7f1e48e Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 15 Jan 2020 21:20:57 +1000 Subject: [PATCH 2/2] parseconf: Add an authority IPv6 ORPort test These tests don't actually exercise the authority IPv6 ORPort self-add feature in 32822, but they do improve coverage of the related config code. Part of 32822. --- src/test/conf_examples/dirauth_3/error_no_dirauth | 1 + .../conf_examples/dirauth_3/error_no_dirauth_relay | 1 + src/test/conf_examples/dirauth_3/expected | 9 +++++++++ src/test/conf_examples/dirauth_3/expected_log | 1 + src/test/conf_examples/dirauth_3/torrc | 13 +++++++++++++ 5 files changed, 25 insertions(+) create mode 100644 src/test/conf_examples/dirauth_3/error_no_dirauth create mode 100644 src/test/conf_examples/dirauth_3/error_no_dirauth_relay create mode 100644 src/test/conf_examples/dirauth_3/expected create mode 100644 src/test/conf_examples/dirauth_3/expected_log create mode 100644 src/test/conf_examples/dirauth_3/torrc diff --git a/src/test/conf_examples/dirauth_3/error_no_dirauth b/src/test/conf_examples/dirauth_3/error_no_dirauth new file mode 100644 index 0000000000..e6bd5db69c --- /dev/null +++ b/src/test/conf_examples/dirauth_3/error_no_dirauth @@ -0,0 +1 @@ +This tor was built with dirauth mode disabled. diff --git a/src/test/conf_examples/dirauth_3/error_no_dirauth_relay b/src/test/conf_examples/dirauth_3/error_no_dirauth_relay new file mode 100644 index 0000000000..e6bd5db69c --- /dev/null +++ b/src/test/conf_examples/dirauth_3/error_no_dirauth_relay @@ -0,0 +1 @@ +This tor was built with dirauth mode disabled. diff --git a/src/test/conf_examples/dirauth_3/expected b/src/test/conf_examples/dirauth_3/expected new file mode 100644 index 0000000000..23eac3a5f8 --- /dev/null +++ b/src/test/conf_examples/dirauth_3/expected @@ -0,0 +1,9 @@ +Address 192.0.2.1 +AuthoritativeDirectory 1 +ContactInfo tor_parse_test@example.net +DirPort 192.0.2.1:2 +DownloadExtraInfo 1 +Nickname Unnamed +ORPort 192.0.2.1:1 +ORPort [2001:DB8::1]:3 +V3AuthoritativeDirectory 1 diff --git a/src/test/conf_examples/dirauth_3/expected_log b/src/test/conf_examples/dirauth_3/expected_log new file mode 100644 index 0000000000..3127c9b125 --- /dev/null +++ b/src/test/conf_examples/dirauth_3/expected_log @@ -0,0 +1 @@ +Read configuration file .*dirauth_3[./]*torrc diff --git a/src/test/conf_examples/dirauth_3/torrc b/src/test/conf_examples/dirauth_3/torrc new file mode 100644 index 0000000000..9663a9bc0c --- /dev/null +++ b/src/test/conf_examples/dirauth_3/torrc @@ -0,0 +1,13 @@ +# Authority with IPv6 address + +AuthoritativeDirectory 1 +V3AuthoritativeDirectory 1 + +ContactInfo tor_parse_test@example.net + +Address 192.0.2.1 + +ORPort 192.0.2.1:1 +DirPort 192.0.2.1:2 + +ORPort [2001:DB8::1]:3