Improve support for IPv4 vs IPv6 virtual hosts (fixes SF bugs #1087699, #1087668).
[ircu2.10.12-pk.git] / ircd / ircd_auth.c
index bcaac31d56b16015314d9c2a46a396f50c7135b3..4a59e677f1c86fe19028115762399ee63e1da38a 100644 (file)
@@ -17,7 +17,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-/* @file
+/** @file
  * @brief IAuth client implementation for an IRC server.
  * @version $Id$
  */
 #include "s_user.h"
 #include "send.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <errno.h>
 #include <netdb.h>
 #include <string.h>
 #include <unistd.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif
@@ -446,6 +445,7 @@ static void iauth_schedule_reconnect(struct IAuth *iauth)
  */
 static void iauth_reconnect(struct IAuth *iauth)
 {
+  struct irc_sockaddr *local;
   IOResult result;
   int fd;
 
@@ -457,7 +457,8 @@ static void iauth_reconnect(struct IAuth *iauth)
     gethost_byname(i_host(iauth), &i_query(iauth));
     return;
   }
-  fd = os_socket(&VirtualHost, SOCK_STREAM, "IAuth");
+  local = irc_in_addr_is_ipv4(&i_addr(iauth).addr) ? &VirtualHost_v4 : &VirtualHost_v6;
+  fd = os_socket(local, SOCK_STREAM, "IAuth");
   if (fd < 0)
     return;
   if (!os_set_sockbufs(fd, SERVER_TCP_WINDOW, SERVER_TCP_WINDOW)) {