Use the IP_FREEBIND socket option, if defined
authorFabian Keil <fk@fabiankeil.de>
Mon, 18 Nov 2019 10:54:17 +0000 (11:54 +0100)
committerFabian Keil <fk@fabiankeil.de>
Mon, 18 Nov 2019 11:20:57 +0000 (12:20 +0100)
This allows Privoxy to bind to not-yet assigned IP addresses
which is useful in failover environments.

Patch by Sam Varshavchik.

jbsockets.c

index 625d830..ab2228a 100644 (file)
@@ -1068,6 +1068,10 @@ int bind_port(const char *hostnam, int portnum, int backlog, jb_socket *pfd)
    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one));
 #endif /* ndef _WIN32 */
 
    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one));
 #endif /* ndef _WIN32 */
 
+#ifdef IP_FREEBIND
+   setsockopt(fd, IPPROTO_IP, IP_FREEBIND, (char *)&one, sizeof(one));
+#endif
+
 #ifdef HAVE_RFC2553
    if (bind(fd, rp->ai_addr, rp->ai_addrlen) < 0)
 #else
 #ifdef HAVE_RFC2553
    if (bind(fd, rp->ai_addr, rp->ai_addrlen) < 0)
 #else