aboutsummaryrefslogtreecommitdiff
path: root/src/app/config/config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2021-01-19 15:21:07 -0500
committerNick Mathewson <nickm@torproject.org>2021-01-19 15:21:07 -0500
commit9a0a91dc23ac465d8e834c0c200eea46db3cdf02 (patch)
treedd5109017cd6e140079741c65e88f50608064041 /src/app/config/config.c
parentb0af4ddc7c2fe80a79e41e31b7050d949561e044 (diff)
parent18654b629f5fdc3f40ca64e41d0e61ea4c7dc6ef (diff)
downloadtor-9a0a91dc23ac465d8e834c0c200eea46db3cdf02.tar.gz
tor-9a0a91dc23ac465d8e834c0c200eea46db3cdf02.zip
Merge branch 'maint-0.4.5'
Diffstat (limited to 'src/app/config/config.c')
-rw-r--r--src/app/config/config.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index bf2f49ead4..4c0c57af47 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -6674,20 +6674,28 @@ get_first_listener_addrport_string(int listener_type)
static const port_cfg_t *
portconf_get_first_advertised(int listener_type, int address_family)
{
+ const port_cfg_t *first_port = NULL;
+ const port_cfg_t *first_port_explicit_addr = NULL;
+
if (address_family == AF_UNSPEC)
return NULL;
const smartlist_t *conf_ports = get_configured_ports();
SMARTLIST_FOREACH_BEGIN(conf_ports, const port_cfg_t *, cfg) {
- if (cfg->type == listener_type &&
- !cfg->server_cfg.no_advertise) {
+ if (cfg->type == listener_type && !cfg->server_cfg.no_advertise) {
if ((address_family == AF_INET && port_binds_ipv4(cfg)) ||
(address_family == AF_INET6 && port_binds_ipv6(cfg))) {
- return cfg;
+ if (cfg->explicit_addr && !first_port_explicit_addr) {
+ first_port_explicit_addr = cfg;
+ } else if (!first_port) {
+ first_port = cfg;
+ }
}
}
} SMARTLIST_FOREACH_END(cfg);
- return NULL;
+
+ /* Prefer the port with the explicit address if any. */
+ return (first_port_explicit_addr) ? first_port_explicit_addr : first_port;
}
/** Return the first advertised port of type <b>listener_type</b> in