Ejemplo n.º 1
0
int
ConnSSL_Connect( CONNECTION *c )
{
	assert(c != NULL);
#ifdef HAVE_LIBSSL
	assert(c->ssl_state.ssl);
#endif
	assert(Conn_OPTION_ISSET(c, CONN_SSL));
	return ConnectAccept(c, true);
}
Ejemplo n.º 2
0
void QListenerThread::StartServer( QThreadEvent *pEvent )
{
    quint16 nPort = pEvent->GetListenPort( );
    qint32 nMaxConn = pEvent->GetMaxPendingConnection( );

    pTcpServer->setMaxPendingConnections( nMaxConn );
    bool bRet = pTcpServer->listen( QHostAddress::Any, nPort );

    QString strLog = QString( "Start server port %1 %2" ).arg( QString::number( nPort ),
                                                               bRet ? "Successfully." :
                                                                      QString( "Unsuccessfully. %1" ).arg( pTcpServer->errorString( ) ) );

    SendLog( strLog, true );
    ConnectAccept( true );
}
Ejemplo n.º 3
0
void QListenerThread::StopServer( )
{
    if ( !pTcpServer->isListening( ) ) {
        return;
    }

    quint16 nPort = pTcpServer->serverPort( );

    pTcpServer->close( );

    QString strLog = QString( "Stop server port %1." ).arg( nPort );

    SendLog( strLog, true );
    ConnectAccept( false );
}
Ejemplo n.º 4
0
/*
 Accept incoming SSL connection.
 Return Values:
	 1: SSL Connection established
	 0: try again
	-1: SSL Connection not established due to fatal error.
*/
int
ConnSSL_Accept( CONNECTION *c )
{
	assert(c != NULL);
	if (!Conn_OPTION_ISSET(c, CONN_SSL)) {
#ifdef HAVE_LIBGNUTLS
		int err = gnutls_init(&c->ssl_state.gnutls_session, GNUTLS_SERVER);
		if (err) {
			Log(LOG_ERR, "Failed to initialize new SSL session: %s",
			    gnutls_strerror(err));
			return false;
		}
#endif
		if (!ConnSSL_Init_SSL(c))
			return -1;
	}
	return ConnectAccept(c, false );
}