aboutsummaryrefslogtreecommitdiff
path: root/src/lib/net/address.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/net/address.c')
-rw-r--r--src/lib/net/address.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index e968d8a7f7..7b24e406a4 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -817,7 +817,8 @@ tor_addr_is_loopback(const tor_addr_t *addr)
/* Is addr valid?
* Checks that addr is non-NULL and not tor_addr_is_null().
- * If for_listening is true, IPv4 addr 0.0.0.0 is allowed.
+ * If for_listening is true, addr is allowed in either case if
+ * addr is 0.0.0.0 (for IPv4) or :: (for IPv6).
* It means "bind to all addresses on the local machine". */
int
tor_addr_is_valid(const tor_addr_t *addr, int for_listening)
@@ -833,6 +834,10 @@ tor_addr_is_valid(const tor_addr_t *addr, int for_listening)
return 1;
}
+ if (for_listening && addr->family == AF_INET6) {
+ return 1;
+ }
+
/* Otherwise, the address is valid if it's not tor_addr_is_null() */
return !tor_addr_is_null(addr);
}