From d0732f9adeb523422e755bfc11d03e9cbccc99f6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 8 Nov 2013 11:50:57 +0100 Subject: [BB#81] allow listening on multiple families when no Listen is provided in config This is achieved by not stopping at the first result of getaddrinfo that we managed to listen on: Without "Listen" in the config, we call getraddrinfo with NULL address. With AI_PASSIVE, this gives results for both IPv4 and IPv6 wildcard addresses (if both are supported). This lets tinyproxy listen on both IPv4 and IPv6 wildcard if the system supports them. Signed-off-by: Michael Adam --- src/sock.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sock.c b/src/sock.c index d0151c4..e7bd450 100644 --- a/src/sock.c +++ b/src/sock.c @@ -281,9 +281,16 @@ int listen_sock (const char *addr, uint16_t port, vector_t listen_fds) vector_append (listen_fds, &listenfd, sizeof(int)); - /* success, don't continue */ + /* success */ ret = 0; - break; + + if (addr != NULL) { + /* + * Unless wildcard is requested, only listen + * on the first result that works. + */ + break; + } } if (ret != 0) { -- cgit v1.2.3