summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 76b2bcb479..c9320f48fe 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5907,18 +5907,23 @@ get_configured_ports(void)
return configured_ports;
}
-/** DOCDOC */
+/** Return the first advertised port of type <b>listener_type</b> in
+ <b>address_family</b>. */
int
-get_first_advertised_v4_port_by_type(int listener_type)
+get_first_advertised_port_by_type_af(int listener_type, int address_family)
{
if (!configured_ports)
return 0;
SMARTLIST_FOREACH_BEGIN(configured_ports, const port_cfg_t *, cfg) {
if (cfg->type == listener_type &&
!cfg->no_advertise &&
- (tor_addr_family(&cfg->addr) == AF_INET ||
- (tor_addr_family(&cfg->addr) == AF_UNSPEC && !cfg->ipv6_only))) {
- return cfg->port;
+ (tor_addr_family(&cfg->addr) == address_family ||
+ tor_addr_family(&cfg->addr) == AF_UNSPEC)) {
+ if (tor_addr_family(&cfg->addr) != AF_UNSPEC ||
+ (address_family == AF_INET && !cfg->ipv6_only) ||
+ (address_family == AF_INET6 && !cfg->ipv4_only)) {
+ return cfg->port;
+ }
}
} SMARTLIST_FOREACH_END(cfg);
return 0;