Update to latest Csocket

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1615 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-09-02 17:26:06 +00:00
parent 4415e53001
commit c26141647b
2 changed files with 24 additions and 35 deletions
+21 -31
View File
@@ -28,7 +28,7 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* $Revision: 1.99 $
* $Revision: 1.104 $
*/
#include "Csocket.h"
@@ -619,7 +619,6 @@ void Csock::Copy( const Csock & cCopy )
FREE_CTX(); // be sure to remove anything that was already here
m_ssl = cCopy.m_ssl;
m_ssl_ctx = cCopy.m_ssl_ctx;
m_ssl_method = cCopy.m_ssl_method;
m_pCerVerifyCB = cCopy.m_pCerVerifyCB;
@@ -990,8 +989,8 @@ bool Csock::SSLClientSetup()
switch( m_iMethod )
{
case SSL2:
m_ssl_method = SSLv2_client_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( SSLv2_client_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... SSLv2_client_method failed!" );
return( false );
@@ -999,16 +998,16 @@ bool Csock::SSLClientSetup()
break;
case SSL3:
m_ssl_method = SSLv3_client_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( SSLv3_client_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... SSLv3_client_method failed!" );
return( false );
}
break;
case TLS1:
m_ssl_method = TLSv1_client_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( TLSv1_client_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... TLSv1_client_method failed!" );
return( false );
@@ -1016,8 +1015,8 @@ bool Csock::SSLClientSetup()
break;
case SSL23:
default:
m_ssl_method = SSLv23_client_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( SSLv23_client_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... SSLv23_client_method failed!" );
return( false );
@@ -1025,10 +1024,6 @@ bool Csock::SSLClientSetup()
break;
}
// wrap some warnings in here
m_ssl_ctx = SSL_CTX_new ( m_ssl_method );
if ( !m_ssl_ctx )
return( false );
SSL_CTX_set_default_verify_paths( m_ssl_ctx );
@@ -1079,8 +1074,8 @@ bool Csock::SSLServerSetup()
switch( m_iMethod )
{
case SSL2:
m_ssl_method = SSLv2_server_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( SSLv2_server_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... SSLv2_server_method failed!" );
return( false );
@@ -1088,8 +1083,8 @@ bool Csock::SSLServerSetup()
break;
case SSL3:
m_ssl_method = SSLv3_server_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( SSLv3_server_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... SSLv3_server_method failed!" );
return( false );
@@ -1097,8 +1092,8 @@ bool Csock::SSLServerSetup()
break;
case TLS1:
m_ssl_method = TLSv1_server_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( TLSv1_server_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... TLSv1_server_method failed!" );
return( false );
@@ -1107,8 +1102,8 @@ bool Csock::SSLServerSetup()
case SSL23:
default:
m_ssl_method = SSLv23_server_method();
if ( !m_ssl_method )
m_ssl_ctx = SSL_CTX_new ( SSLv23_server_method() );
if ( !m_ssl_ctx )
{
CS_DEBUG( "WARNING: MakeConnection .... SSLv23_server_method failed!" );
return( false );
@@ -1116,10 +1111,6 @@ bool Csock::SSLServerSetup()
break;
}
// wrap some warnings in here
m_ssl_ctx = SSL_CTX_new ( m_ssl_method );
if ( !m_ssl_ctx )
return( false );
SSL_CTX_set_default_verify_paths( m_ssl_ctx );
// set the pemfile password
@@ -1134,7 +1125,7 @@ bool Csock::SSLServerSetup()
//
// set up the CTX
if ( SSL_CTX_use_certificate_file( m_ssl_ctx, m_sPemFile.c_str() , SSL_FILETYPE_PEM ) <= 0 )
if ( SSL_CTX_use_certificate_chain_file( m_ssl_ctx, m_sPemFile.c_str() ) <= 0 )
{
CS_DEBUG( "Error with PEM file [" << m_sPemFile << "]" );
SSLErrors( __FILE__, __LINE__ );
@@ -1715,7 +1706,7 @@ u_short Csock::GetLocalPort()
if( !GetIPv6() )
{
struct sockaddr_in mLocalAddr;
socklen_t mLocalLen = sizeof( mLocalLen );
socklen_t mLocalLen = sizeof( mLocalAddr );
if ( getsockname( iSock, (struct sockaddr *) &mLocalAddr, &mLocalLen ) == 0 )
m_iLocalPort = ntohs( mLocalAddr.sin_port );
}
@@ -1723,7 +1714,7 @@ u_short Csock::GetLocalPort()
else
{
struct sockaddr_in6 mLocalAddr;
socklen_t mLocalLen = sizeof( mLocalLen );
socklen_t mLocalLen = sizeof( mLocalAddr );
if ( getsockname( iSock, (struct sockaddr *) &mLocalAddr, &mLocalLen ) == 0 )
m_iLocalPort = ntohs( mLocalAddr.sin6_port );
}
@@ -2056,9 +2047,8 @@ int Csock::DNSLookup( EDNSLType eDNSLType )
if( !CreateSocksFD() )
{
m_iDNSTryCount = 0;
return ETIMEDOUT;
return( ETIMEDOUT );
}
if ( m_eConState != CST_OK )
m_eConState = ( ( eDNSLType == DNS_VHOST ) ? CST_BINDVHOST : CST_CONNECT );
m_iDNSTryCount = 0;