From 12ed04752151185d2306fd68c1fdc7fd7db4db6f Mon Sep 17 00:00:00 2001 From: prozacx Date: Fri, 10 Feb 2006 02:27:34 +0000 Subject: [PATCH] Pulled in bugfix git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@633 726aef4b-f618-498e-8847-2d620e286838 --- Csocket.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Csocket.cpp b/Csocket.cpp index 18a82ce4..c5029f14 100644 --- a/Csocket.cpp +++ b/Csocket.cpp @@ -694,20 +694,17 @@ bool Csock::Listen( u_short iPort, int iMaxConns, const CS_STRING & sBindHost, u m_address.SinFamily(); if ( !sBindHost.empty() ) { -#ifdef HAVE_IPV6 - if( GetIPv6() ) - { - if ( GetHostByName6( sBindHost, m_address.GetAddr6() ) != 0 ) - return( false ); - } - else + if( !GetIPv6() ) { if ( GetHostByName( sBindHost, m_address.GetAddr() ) != 0 ) return( false ); } -#else - if ( GetHostByName( sBindHost, m_address.GetAddr() ) != 0 ) - return( false ); +#ifdef HAVE_IPV6 + else + { + if ( GetHostByName6( sBindHost, m_address.GetAddr6() ) != 0 ) + return( false ); + } #endif /* HAVE_IPV6 */ } m_address.SinPort( iPort ); @@ -1856,9 +1853,7 @@ int Csock::DNSLookup( EDNSLType eDNSLType ) iRet = GetHostByName( m_sBindHost, m_bindhost.GetAddr(), 1 ); #ifdef HAVE_IPV6 else - { iRet = GetHostByName6( m_sBindHost, m_bindhost.GetAddr6(), 1 ); - } #endif /* HAVE_IPV6 */ } else @@ -1903,7 +1898,15 @@ bool Csock::SetupVHost() m_eConState = CST_CONNECT; return( true ); } - if ( bind( m_iReadSock, (struct sockaddr *) &m_bindhost, sizeof( m_bindhost ) ) == 0 ) + int iRet = -1; + if( !GetIPv6() ) + iRet = bind( m_iReadSock, (struct sockaddr *) m_bindhost.GetSockAddr(), m_bindhost.GetSockAddrLen() ); +#ifdef HAVE_IPV6 + else + iRet = bind( m_iReadSock, (struct sockaddr *) m_bindhost.GetSockAddr6(), m_bindhost.GetSockAddrLen6() ); +#endif /* HAVE_IPV6 */ + + if ( iRet == 0 ) { if ( m_eConState != CST_OK ) m_eConState = CST_CONNECT;