diff options
author | David Goulet <dgoulet@torproject.org> | 2021-02-12 12:54:52 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-02-12 12:54:52 -0500 |
commit | 73bedcaf4db3688c5720fb078e584d5b2a73f052 (patch) | |
tree | 75ac431480d1ea2939b624a298e4ccf243b45d94 /src | |
parent | d24a6b2f75caf7ba6e155d5b21516ce00dd9d30a (diff) | |
parent | ae5800cd9faccd8c1319601cac7f6c76c4beb288 (diff) | |
download | tor-73bedcaf4db3688c5720fb078e584d5b2a73f052.tar.gz tor-73bedcaf4db3688c5720fb078e584d5b2a73f052.zip |
Merge branch 'tor-gitlab/mr/303' into maint-0.4.5
Diffstat (limited to 'src')
-rw-r--r-- | src/app/config/resolve_addr.c | 14 | ||||
-rw-r--r-- | src/test/test_config.c | 17 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/app/config/resolve_addr.c b/src/app/config/resolve_addr.c index 080cb967bc..86db6ba680 100644 --- a/src/app/config/resolve_addr.c +++ b/src/app/config/resolve_addr.c @@ -193,7 +193,19 @@ address_can_be_used(const tor_addr_t *addr, const or_options_t *options, goto allow; } - /* We have a private IP address. It is allowed only if we set custom + /* We allow internal addresses to be used if the PublishServerDescriptor is + * unset and AssumeReachable (or for IPv6) is set. + * + * This is to cover the case where a relay/bridge might be run behind a + * firewall on a local network to users can reach the network through it + * using Tor Browser for instance. */ + if (options->PublishServerDescriptor_ == NO_DIRINFO && + (options->AssumeReachable || + (tor_addr_family(addr) == AF_INET6 && options->AssumeReachableIPv6))) { + goto allow; + } + + /* We have a private IP address. This is also allowed if we set custom * directory authorities. */ if (using_default_dir_authorities(options)) { log_fn(warn_severity, LD_CONFIG, diff --git a/src/test/test_config.c b/src/test/test_config.c index 4eb4ac9cf5..eacf12a25f 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -1460,6 +1460,7 @@ test_config_find_my_address(void *arg) options = options_new(); options_init(options); + options->PublishServerDescriptor_ = V3_DIRINFO; /* * Case 0: @@ -1782,6 +1783,22 @@ test_config_find_my_address(void *arg) VALIDATE_FOUND_ADDRESS(true, RESOLVED_ADDR_INTERFACE, NULL); CLEANUP_FOUND_ADDRESS; + /* + * Case 15: Address is a local address (internal) but we unset + * PublishServerDescriptor_ so we are allowed to hold it. + */ + options->PublishServerDescriptor_ = NO_DIRINFO; + if (p->family == AF_INET) { + options->AssumeReachable = 1; + } + config_line_append(&options->Address, "Address", p->internal_ip); + + tor_addr_parse(&test_addr, p->internal_ip); + retval = find_my_address(options, p->family, LOG_NOTICE, &resolved_addr, + &method_used, &hostname_out); + VALIDATE_FOUND_ADDRESS(true, RESOLVED_ADDR_CONFIGURED, NULL); + CLEANUP_FOUND_ADDRESS; + UNMOCK(get_interface_address6); UNMOCK(tor_gethostname); UNMOCK(tor_addr_lookup); |