From 47b5f62aeb8ddaefbe7d0d48dce74724c69aa8a7 Mon Sep 17 00:00:00 2001 From: joss17 Date: Thu, 25 Feb 2010 22:43:36 +0000 Subject: [PATCH] update implemention for new ssl encryption git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2427 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/pqissltunnel.cc | 48 ++++++++++++++++----------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/libretroshare/src/pqi/pqissltunnel.cc b/libretroshare/src/pqi/pqissltunnel.cc index 109357614..c7bb3320e 100644 --- a/libretroshare/src/pqi/pqissltunnel.cc +++ b/libretroshare/src/pqi/pqissltunnel.cc @@ -300,7 +300,9 @@ int pqissltunnel::tick() // if we are waiting.. continue the connection (only) if (waiting > 0) { - std::cerr << "pqissltunnel::tick() Continuing Connection Attempt!" << std::endl; + #ifdef DEBUG_PQISSL_TUNNEL + std::cerr << "pqissltunnel::tick() Continuing Connection Attempt!" << std::endl; + #endif ConnectAttempt(); return 1; } @@ -342,9 +344,13 @@ int pqissltunnel::ConnectAttempt() case TUNNEL_WAITING_PING_RETURN: if ((time(NULL) - mConnectTS) < TUNNEL_PING_TIMEOUT) { + #ifdef DEBUG_PQISSL_TUNNEL std::cerr << "pqissltunnel::ConnectAttempt() STATE = Waiting for ping reply." << std::endl; + #endif } else { + #ifdef DEBUG_PQISSL_TUNNEL std::cerr << "pqissltunnel::ConnectAttempt() no ping reply during imparing time. Connection failed." << std::endl; + #endif waiting = TUNNEL_WAITING_NOT; active = false; // clean up the streamer @@ -452,36 +458,38 @@ void pqissltunnel::IncommingPingPacket(std::string incRelayPeerId) { int pqissltunnel::senddata(void *data, int len) { #ifdef DEBUG_PQISSL_TUNNEL - std::cout << "pqissltunnel::senddata() called" << std::endl ; + std::cerr << "pqissltunnel::senddata() called" << std::endl ; #endif if (!active) { -#ifdef DEBUG_PQISSL_TUNNEL - std::cout << "pqissltunnel::senddata() connection is not active" << std::endl ; -#endif + #ifdef DEBUG_PQISSL_TUNNEL + std::cerr << "pqissltunnel::senddata() connection is not active" << std::endl ; + #endif return -1; } - //create RsTunnelDataItem - RsTunnelDataItem *item = new RsTunnelDataItem; - item->destPeerId = parent()->PeerId(); - item->relayPeerId = relayPeerId; - item->sourcePeerId = mConnMgr->getOwnId(); - item->PeerId(relayPeerId); - item->connection_accepted = 1; - - int oulen; - if (!AuthSSL::getAuthSSL()->encrypt(item->encoded_data, oulen, data, len, parent()->PeerId())) { + int outlen = 0; + void * out; + if (!AuthSSL::getAuthSSL()->encrypt(out, outlen, data, len, parent()->PeerId())) { std::cerr << "pqissltunnel::readdata() problem while crypting packet, ignoring it." << std::endl; return -1; } - item->encoded_data_len = oulen; + std::cerr << "pqissltunnel::readdata() outlen : " << outlen << std::endl; + //create RsTunnelDataItem + RsTunnelDataItem *item = new RsTunnelDataItem(); + item->destPeerId = parent()->PeerId(); + item->relayPeerId = relayPeerId; + item->sourcePeerId = mConnMgr->getOwnId(); + item->PeerId(relayPeerId); + item->connection_accepted = 1; + item->encoded_data_len = outlen; + item->encoded_data = out; -#ifdef DEBUG_PQISSL_TUNNEL - std::cout << "pqissltunnel::senddata() sending item (Putting it into queue)" << std::endl ; -#endif + #ifdef DEBUG_PQISSL_TUNNEL + std::cerr << "pqissltunnel::senddata() sending item (Putting it into queue)" << std::endl ; + #endif mP3tunnel->sendItem(item); - return oulen; + return len; } int pqissltunnel::readdata(void *data, int len)