From: Fabian Keil Date: Fri, 17 Apr 2009 11:39:52 +0000 (+0000) Subject: If the hostname is 'localhost' or not specified, request an AF_INET address. X-Git-Tag: v_3_0_13~120 X-Git-Url: http://www.privoxy.org/gitweb/%40user-manual%40%40actions-help-prefix%40HIDE-FROM-HEADER?a=commitdiff_plain;h=34f02e7c48e32c11827a9c0e7a1898a68da8d20f;p=privoxy.git If the hostname is 'localhost' or not specified, request an AF_INET address. --- diff --git a/jbsockets.c b/jbsockets.c index 6d4923e4..3bc67563 100644 --- a/jbsockets.c +++ b/jbsockets.c @@ -1,4 +1,4 @@ -const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.51 2009/04/17 11:27:49 fabiankeil Exp $"; +const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.52 2009/04/17 11:34:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $ @@ -35,6 +35,9 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.51 2009/04/17 11:27:49 fabian * * Revisions : * $Log: jbsockets.c,v $ + * Revision 1.52 2009/04/17 11:34:34 fabiankeil + * Style cosmetics for the IPv6 code. + * * Revision 1.51 2009/04/17 11:27:49 fabiankeil * Petr Pisar's privoxy-3.0.12-ipv6-3.diff. * @@ -328,6 +331,7 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.51 2009/04/17 11:27:49 fabian #include "jbsockets.h" #include "filters.h" #include "errlog.h" +#include "miscutil.h" const char jbsockets_h_rcs[] = JBSOCKETS_H_VERSION; @@ -887,7 +891,20 @@ int bind_port(const char *hostnam, int portnum, jb_socket *pfd) } memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; + if ((hostnam == NULL) || !strcmpic(hostnam, "localhost")) + { + /* + * XXX: This is a hack. The right thing to do + * would be to bind to both AF_INET and AF_INET6. + * This will also fail if there is no AF_INET + * version available. + */ + hints.ai_family = AF_INET; + } + else + { + hints.ai_family = AF_UNSPEC; + } hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; hints.ai_protocol = 0; /* Realy any stream protocol or TCP only */