Mercurial > dovecot > core-2.2
diff src/lib/net.c @ 19312:c5c34c02fda3
lib: net_gethostbyname() now supports [ipv6] style bracketed addresses.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 19 Oct 2015 14:05:26 +0300 |
parents | 9e120590e0ef |
children | 25e892203e2b |
line wrap: on
line diff
--- a/src/lib/net.c Mon Oct 19 14:04:46 2015 +0300 +++ b/src/lib/net.c Mon Oct 19 14:05:26 2015 +0300 @@ -628,6 +628,7 @@ #ifdef HAVE_IPV6 union sockaddr_union *so; struct addrinfo hints, *ai, *origai; + struct ip_addr ip; int host_error; #else struct hostent *hp; @@ -638,6 +639,14 @@ *ips_count = 0; #ifdef HAVE_IPV6 + /* support [ipv6] style addresses here so they work globally */ + if (addr[0] == '[' && net_addr2ip(addr, &ip) == 0) { + *ips_count = 1; + *ips = t_new(struct ip_addr, 1); + **ips = ip; + return 0; + } + memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_socktype = SOCK_STREAM;