From abf19c964a878606ab97df421c09d3ccc2d9ef93 Mon Sep 17 00:00:00 2001 From: joss17 Date: Tue, 19 Jan 2010 19:17:21 +0000 Subject: [PATCH] don't send gpg key when all the ssl childs are on no disc or when we got no ssl child of it git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2084 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/serialiser/rsdiscitems.cc | 2 +- libretroshare/src/services/p3disc.cc | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/serialiser/rsdiscitems.cc b/libretroshare/src/serialiser/rsdiscitems.cc index 56a5fcd47..e8a4cf440 100644 --- a/libretroshare/src/serialiser/rsdiscitems.cc +++ b/libretroshare/src/serialiser/rsdiscitems.cc @@ -153,7 +153,7 @@ std::ostream &RsDiscAskInfo::print(std::ostream &out, uint16_t indent) printIndent(out, int_Indent); out << "gpg_id: " << gpg_id << std::endl; - printRsItemEnd(out, "RsDiscOwnItem", indent); + printRsItemEnd(out, "RsDiscAskInfo", indent); return out; } diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index 72f8ce7bb..8bf244dee 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -312,16 +312,17 @@ void p3disc::sendPeerDetails(std::string to, std::string about) { // Set Target as input cert. di -> PeerId(to); di -> aboutId = about; - di -> certGPG = AuthGPG::getAuthGPG()->SaveCertificateToString(about); // set the ip addresse list. std::list sslChilds; rsPeers->getSSLChildListOfGPGId(about, sslChilds); + bool shouldWeSendGPGKey = false;//the GPG key is send only if we've got a valid friend with DISC enabled for (std::list::iterator sslChildIt = sslChilds.begin(); sslChildIt != sslChilds.end(); sslChildIt++) { peerConnectState detail; if (!mConnMgr->getFriendNetStatus(*sslChildIt, detail) || detail.visState & RS_VIS_STATE_NODISC) { continue; } + shouldWeSendGPGKey = true; RsPeerNetItem *rsPeerNetItem = new RsPeerNetItem(); rsPeerNetItem->clear(); @@ -343,6 +344,7 @@ void p3disc::sendPeerDetails(std::string to, std::string about) { if (about == rsPeers->getGPGOwnId()) { peerConnectState detail; if (mConnMgr->getOwnNetStatus(detail)) { + shouldWeSendGPGKey = true; RsPeerNetItem *rsPeerNetItem = new RsPeerNetItem(); rsPeerNetItem->clear(); rsPeerNetItem->pid = detail.id; @@ -359,6 +361,14 @@ void p3disc::sendPeerDetails(std::string to, std::string about) { } } + if (!shouldWeSendGPGKey) { + #ifdef P3DISC_DEBUG + std::cerr << "p3disc::sendPeerDetails() GPG key should not be send, no friend with disc on found about it." << std::endl; + #endif + return; + } + di -> certGPG = AuthGPG::getAuthGPG()->SaveCertificateToString(about); + // Send off message #ifdef P3DISC_DEBUG di->print(std::cerr, 5);