From: <ps...@us...> - 2008-08-29 18:58:56
|
Revision: 1179 http://znc.svn.sourceforge.net/znc/?rev=1179&view=rev Author: psychon Date: 2008-08-29 18:59:05 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Update to latest Csocket SockError() is now called with the correct errno if accept() fails. This is some preparation for a later patch which will handle EMFILE. Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2008-08-29 18:51:08 UTC (rev 1178) +++ trunk/Csocket.cpp 2008-08-29 18:59:05 UTC (rev 1179) @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.82 $ +* $Revision: 1.83 $ */ #include "Csocket.h" @@ -851,9 +851,12 @@ struct sockaddr_in client; socklen_t clen = sizeof( client ); iSock = accept( m_iReadSock, (struct sockaddr *) &client, &clen ); - getpeername( iSock, (struct sockaddr *) &client, &clen ); - sHost = inet_ntoa( client.sin_addr ); - iRPort = ntohs( client.sin_port ); + if( iSock != -1 ) + { + getpeername( iSock, (struct sockaddr *) &client, &clen ); + sHost = inet_ntoa( client.sin_addr ); + iRPort = ntohs( client.sin_port ); + } } #ifdef HAVE_IPV6 else @@ -862,11 +865,14 @@ struct sockaddr_in6 client; socklen_t clen = sizeof( client ); iSock = accept( m_iReadSock, (struct sockaddr *) &client, &clen ); - getpeername( iSock, (struct sockaddr *) &client, &clen ); - if( inet_ntop( AF_INET6, &client.sin6_addr, straddr, sizeof(straddr) ) > 0 ) + if( iSock != -1 ) { - sHost = straddr; - iRPort = ntohs( client.sin6_port ); + getpeername( iSock, (struct sockaddr *) &client, &clen ); + if( inet_ntop( AF_INET6, &client.sin6_addr, straddr, sizeof(straddr) ) > 0 ) + { + sHost = straddr; + iRPort = ntohs( client.sin6_port ); + } } } #endif /* HAVE_IPV6 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2009-07-04 13:18:45
|
Revision: 1556 http://znc.svn.sourceforge.net/znc/?rev=1556&view=rev Author: psychon Date: 2009-07-04 12:54:15 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Fix a DNS bug in Csocket with non-blocking resolvers After the first attempt to lookup an address, Csocket already created the socket used for communicating. Since at this point it wasn't yet known whether we will yield a IPv4 or IPv6 address, Csocket just always used IPv4. This would then later fail to connect() with 'Address family not supported by protocol'. This patch fixes this by creating the socket fd only when the DNS lookup completed successfully. Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2009-07-01 09:11:33 UTC (rev 1555) +++ trunk/Csocket.cpp 2009-07-04 12:54:15 UTC (rev 1556) @@ -2051,11 +2051,14 @@ iRet = GetAddrInfo( m_shostname, m_address ); } - if( !CreateSocksFD() ) - iRet = ETIMEDOUT; - if ( iRet == 0 ) { + if( !CreateSocksFD() ) + { + m_iDNSTryCount = 0; + return ETIMEDOUT; + } + if ( m_eConState != CST_OK ) m_eConState = ( ( eDNSLType == DNS_VHOST ) ? CST_BINDVHOST : CST_CONNECT ); m_iDNSTryCount = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2009-09-10 06:30:43
|
Revision: 1621 http://znc.svn.sourceforge.net/znc/?rev=1621&view=rev Author: psychon Date: 2009-09-10 06:30:34 +0000 (Thu, 10 Sep 2009) Log Message: ----------- Update to latest Csocket This fixes a minor bug where a socket's timeout mode was changed when it was copied to another socket. Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2009-09-09 10:15:36 UTC (rev 1620) +++ trunk/Csocket.cpp 2009-09-10 06:30:34 UTC (rev 1621) @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.104 $ +* $Revision: 1.105 $ */ #include "Csocket.h" @@ -574,7 +574,7 @@ m_iLocalPort = cCopy.m_iLocalPort; m_iReadSock = cCopy.m_iReadSock; m_iWriteSock = cCopy.m_iWriteSock; - m_itimeout = cCopy.m_iWriteSock; + m_itimeout = cCopy.m_itimeout; m_iConnType = cCopy.m_iConnType; m_iMethod = cCopy.m_iMethod; m_bssl = cCopy.m_bssl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2009-12-10 21:30:03
|
Revision: 1673 http://znc.svn.sourceforge.net/znc/?rev=1673&view=rev Author: psychon Date: 2009-12-10 21:29:47 +0000 (Thu, 10 Dec 2009) Log Message: ----------- Always use blocking DNS for resolving bind hosts This fixes a bug where ZNC failed to bind to domain names if they weren't mentioned in /etc/hosts. Thanks to alturiak for finding and reporting this. Thanks to Imaginos for finding a quick workaround. Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2009-12-02 18:16:19 UTC (rev 1672) +++ trunk/Csocket.cpp 2009-12-10 21:29:47 UTC (rev 1673) @@ -857,7 +857,9 @@ m_sBindHost = sBindHost; if ( !sBindHost.empty() ) { - if( GetAddrInfo( sBindHost, m_address ) != 0 ) + // forcing this to block regardless of resolver overloading, because listen is not currently setup to + // to handle nonblocking operations. This is used to resolve local ip's for binding anyways and should be instant + if( ::GetAddrInfo( sBindHost, this, m_address ) != 0 ) return( false ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ima...@us...> - 2010-01-12 20:06:05
|
Revision: 1709 http://znc.svn.sourceforge.net/znc/?rev=1709&view=rev Author: imaginos Date: 2010-01-12 20:05:58 +0000 (Tue, 12 Jan 2010) Log Message: ----------- added workaround for older c-ares version, implemented library init calls per KiNgMaR Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-01-12 18:51:31 UTC (rev 1708) +++ trunk/Csocket.cpp 2010-01-12 20:05:58 UTC (rev 1709) @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.117 $ +* $Revision: 1.118 $ */ #include "Csocket.h" @@ -42,6 +42,7 @@ using namespace std; +#define CREATE_ARES_VER( a, b, c ) ((a<<16)|(b<<8)|c) #ifndef _NO_CSOCKET_NS // some people may not want to use a namespace namespace Csocket @@ -386,6 +387,12 @@ if( iResult != NO_ERROR ) return( false ); #endif /* _WIN32 */ +#ifdef HAVE_C_ARES +#if ARES_VERSION >= CREATE_ARES_VER( 1, 6, 1 ) + if( ares_library_init( ARES_LIB_INIT_ALL ) != 0 ) + return( false ); +#endif /* ARES_VERSION >= CREATE_ARES_VER( 1, 6, 1 ) */ +#endif /* HAVE_C_ARES */ #ifdef HAVE_LIBSSL if( !InitSSL() ) return( false ); @@ -398,6 +405,11 @@ #ifdef HAVE_LIBSSL ERR_free_strings(); #endif /* HAVE_LIBSSL */ +#ifdef HAVE_C_ARES +#if ARES_VERSION >= CREATE_ARES_VER( 1, 6, 1 ) + ares_library_cleanup(); +#endif /* ARES_VERSION >= CREATE_ARES_VER( 1, 6, 1 ) */ +#endif /* HAVE_C_ARES */ #ifdef _WIN32 WSACleanup(); #endif /* _WIN32 */ @@ -2121,6 +2133,7 @@ #ifdef HAVE_C_ARES if( GetType() != LISTENER ) { // right now the current function in Listen() is it blocks, the easy way around this at the moment is to use ip + // need to compute this up here if( !m_pARESChannel ) { if( ares_init( &m_pARESChannel ) != ARES_SUCCESS ) @@ -2129,17 +2142,27 @@ return( ETIMEDOUT ); } m_pCurrAddr = &csSockAddr; // flag its starting - int iFamily = AF_INET; #ifdef HAVE_IPV6 // as of ares 1.6.0 if it fails on af_inet6, it falls back to af_inet, this code was here in the previous Csocket version, just adding the comment as a reminder - iFamily = csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ? AF_INET6 : csSockAddr.GetAFRequire(); + int iFamily = csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ? AF_INET6 : csSockAddr.GetAFRequire(); #endif /* HAVE_IPV6 */ ares_gethostbyname( m_pARESChannel, sHostname.c_str(), iFamily, AresHostCallback, this ); } if( !m_pCurrAddr ) { // this means its finished FreeAres(); +#ifdef HAVE_IPV6 +#if ARES_VERSION < CREATE_ARES_VER( 1, 5, 3 ) + if( m_iARESStatus != ARES_SUCCESS && csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY && csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ) + { // this is a workaround for ares < 1.5.3 where the builtin retry on failed AF_INET6 isn't there yet + CS_DEBUG( "Retry for older version of c-ares with AF_INET only" ); + // this means we tried previously with AF_INET6 and failed, so force AF_INET and retry + SetAFRequire( CSSockAddr::RAF_INET ); + return( GetAddrInfo( sHostname, csSockAddr ) ); + } +#endif /* ARES_VERSION < CREATE_ARES_VER( 1, 5, 3 ) */ +#endif /* HAVE_IPV6 */ return( m_iARESStatus == ARES_SUCCESS ? 0 : ETIMEDOUT ); } return( EAGAIN ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ima...@us...> - 2010-01-12 20:47:01
|
Revision: 1710 http://znc.svn.sourceforge.net/znc/?rev=1710&view=rev Author: imaginos Date: 2010-01-12 20:46:52 +0000 (Tue, 12 Jan 2010) Log Message: ----------- cleanup some crosseyed code Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-01-12 20:05:58 UTC (rev 1709) +++ trunk/Csocket.cpp 2010-01-12 20:46:52 UTC (rev 1710) @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.118 $ +* $Revision: 1.119 $ */ #include "Csocket.h" @@ -2143,9 +2143,10 @@ } m_pCurrAddr = &csSockAddr; // flag its starting + int iFamily = AF_INET; #ifdef HAVE_IPV6 // as of ares 1.6.0 if it fails on af_inet6, it falls back to af_inet, this code was here in the previous Csocket version, just adding the comment as a reminder - int iFamily = csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ? AF_INET6 : csSockAddr.GetAFRequire(); + iFamily = csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ? AF_INET6 : csSockAddr.GetAFRequire(); #endif /* HAVE_IPV6 */ ares_gethostbyname( m_pARESChannel, sHostname.c_str(), iFamily, AresHostCallback, this ); } @@ -2154,7 +2155,7 @@ FreeAres(); #ifdef HAVE_IPV6 #if ARES_VERSION < CREATE_ARES_VER( 1, 5, 3 ) - if( m_iARESStatus != ARES_SUCCESS && csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY && csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ) + if( m_iARESStatus != ARES_SUCCESS && csSockAddr.GetAFRequire() == CSSockAddr::RAF_ANY ) { // this is a workaround for ares < 1.5.3 where the builtin retry on failed AF_INET6 isn't there yet CS_DEBUG( "Retry for older version of c-ares with AF_INET only" ); // this means we tried previously with AF_INET6 and failed, so force AF_INET and retry This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2010-02-05 13:13:59
|
Revision: 1735 http://znc.svn.sourceforge.net/znc/?rev=1735&view=rev Author: psychon Date: 2010-02-05 13:13:51 +0000 (Fri, 05 Feb 2010) Log Message: ----------- Update to latest Csocket again Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-02-05 02:03:17 UTC (rev 1734) +++ trunk/Csocket.cpp 2010-02-05 13:13:51 UTC (rev 1735) @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.122 $ +* $Revision: 1.123 $ */ #include "Csocket.h" @@ -636,7 +636,7 @@ CS_CLOSE( m_iReadSock ); if( m_iWriteSock != CS_INVALID_SOCK ) CS_CLOSE( m_iWriteSock ); - } else if( m_iReadSock CS_INVALID_SOCK ) + } else if( m_iReadSock != CS_INVALID_SOCK ) CS_CLOSE( m_iReadSock ); m_iReadSock = CS_INVALID_SOCK; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ima...@us...> - 2010-02-10 23:33:28
|
Revision: 1750 http://znc.svn.sourceforge.net/znc/?rev=1750&view=rev Author: imaginos Date: 2010-02-10 23:33:22 +0000 (Wed, 10 Feb 2010) Log Message: ----------- added workaround for v23 undefined const function before handshake is finished type bug thing Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-02-08 22:55:26 UTC (rev 1749) +++ trunk/Csocket.cpp 2010-02-10 23:33:22 UTC (rev 1750) @@ -2109,7 +2109,18 @@ { #ifdef HAVE_LIBSSL if( m_ssl ) - return( SSL_pending( m_ssl ) ); + { + // in v23 method, the pending function is initialized to ssl_undefined_const_function + // which throws SSL_UNDEFINED_CONST_FUNCTION on to the error stack + // this is one of the more stupid things in openssl, it seems bizarre that even though SSL_pending + // returns an int, they don't bother returning in error to notify us, so basically + // we have to always clear errors here generated by SSL_pending, otherwise the stack could + // have a lame error on it causing SSL_write to fail in certain instances. + ERR_set_mark(); + int iBytes = SSL_pending( m_ssl ); + ERR_pop_to_mark(); + return( iBytes ); + } else return( 0 ); #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ima...@us...> - 2010-02-12 22:59:11
|
Revision: 1751 http://znc.svn.sourceforge.net/znc/?rev=1751&view=rev Author: imaginos Date: 2010-02-12 22:59:04 +0000 (Fri, 12 Feb 2010) Log Message: ----------- keep supporting older versions of openssl Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-02-10 23:33:22 UTC (rev 1750) +++ trunk/Csocket.cpp 2010-02-12 22:59:04 UTC (rev 1751) @@ -2116,10 +2116,15 @@ // returns an int, they don't bother returning in error to notify us, so basically // we have to always clear errors here generated by SSL_pending, otherwise the stack could // have a lame error on it causing SSL_write to fail in certain instances. +#if OPENSSL_VERSION_NUMBER >= 0x00908 ERR_set_mark(); int iBytes = SSL_pending( m_ssl ); ERR_pop_to_mark(); return( iBytes ); +#else + int iBytes = SSL_pending( m_ssl ); + ERR_clear_error(); // to get safer handling, upgrade your openssl version! +#endif /* OPENSSL_VERSION_NUMBER */ } else return( 0 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ima...@us...> - 2010-02-12 23:06:25
|
Revision: 1752 http://znc.svn.sourceforge.net/znc/?rev=1752&view=rev Author: imaginos Date: 2010-02-12 23:06:19 +0000 (Fri, 12 Feb 2010) Log Message: ----------- <---- i'm with stupid Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-02-12 22:59:04 UTC (rev 1751) +++ trunk/Csocket.cpp 2010-02-12 23:06:19 UTC (rev 1752) @@ -2116,7 +2116,7 @@ // returns an int, they don't bother returning in error to notify us, so basically // we have to always clear errors here generated by SSL_pending, otherwise the stack could // have a lame error on it causing SSL_write to fail in certain instances. -#if OPENSSL_VERSION_NUMBER >= 0x00908 +#if OPENSSL_VERSION_NUMBER >= 0x009080000 ERR_set_mark(); int iBytes = SSL_pending( m_ssl ); ERR_pop_to_mark(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ima...@us...> - 2010-02-12 23:29:21
|
Revision: 1753 http://znc.svn.sourceforge.net/znc/?rev=1753&view=rev Author: imaginos Date: 2010-02-12 23:29:15 +0000 (Fri, 12 Feb 2010) Log Message: ----------- commiting the commit i should have comitted prior to the previous commit. (accidently turned the const L into a 0), also allow for missing openssl version Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-02-12 23:06:19 UTC (rev 1752) +++ trunk/Csocket.cpp 2010-02-12 23:29:15 UTC (rev 1753) @@ -2116,7 +2116,7 @@ // returns an int, they don't bother returning in error to notify us, so basically // we have to always clear errors here generated by SSL_pending, otherwise the stack could // have a lame error on it causing SSL_write to fail in certain instances. -#if OPENSSL_VERSION_NUMBER >= 0x009080000 +#if defined( OPENSSL_VERSION_NUMBER ) && OPENSSL_VERSION_NUMBER >= 0x00908000 ERR_set_mark(); int iBytes = SSL_pending( m_ssl ); ERR_pop_to_mark(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ps...@us...> - 2010-09-27 18:52:02
|
Revision: 2148 http://znc.svn.sourceforge.net/znc/?rev=2148&view=rev Author: psychon Date: 2010-09-27 18:51:55 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Csocket: Clear the buffer in DisableReadLine() This clears the internal read buffer in DisableReadLine(). This fixes "accidental bugs" where CHTTPSock does DisableReadLine() and then reads the post data via ReadData(). The problem is when we do DisableReadLine() in ReadLine() and then return from it. All the stuff is still in the read buffer which triggers a MaxBufferReached() call which causes us to drop the connection. Modified Paths: -------------- trunk/Csocket.cpp Modified: trunk/Csocket.cpp =================================================================== --- trunk/Csocket.cpp 2010-09-27 14:45:42 UTC (rev 2147) +++ trunk/Csocket.cpp 2010-09-27 18:51:55 UTC (rev 2148) @@ -2147,7 +2147,10 @@ } void Csock::EnableReadLine() { m_bEnableReadLine = true; } -void Csock::DisableReadLine() { m_bEnableReadLine = false; } +void Csock::DisableReadLine() { + m_bEnableReadLine = false; + m_sbuffer.clear(); +} void Csock::ReachedMaxBuffer() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |