From 3a60e8cecb2967f716e6e1b843c55e7ff424f9d9 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 13 Oct 2010 16:15:26 +0000 Subject: [PATCH] Added service functionality to AuthGPG for load and save of certificates in the background (prepared for more when needed). Added p3disc as service and process the certificats of RsDiscReply with AuthGPG service. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3669 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/authgpg.cc | 80 ++++++++- libretroshare/src/pqi/authgpg.h | 64 ++++++- libretroshare/src/rsserver/rsinit.cc | 6 + libretroshare/src/services/p3disc.cc | 242 ++++++++++++++++----------- libretroshare/src/services/p3disc.h | 18 +- 5 files changed, 301 insertions(+), 109 deletions(-) diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index adc9b4b0e..c4d1b6a03 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -357,6 +357,9 @@ void AuthGPGimpl::run() sleep(1); #endif + /* every second */ + processServices(); + /* every minute */ if (++count >= 60) { storeAllKeys_tick(); @@ -365,6 +368,67 @@ void AuthGPGimpl::run() } } +void AuthGPGimpl::processServices() +{ + AuthGPGOperation *operation = NULL; + AuthGPGService *service = NULL; + + { + RsStackMutex stack(gpgMtxService); /******* LOCKED ******/ + + std::list::iterator serviceIt; + for (serviceIt = services.begin(); serviceIt != services.end(); serviceIt++) { + operation = (*serviceIt)->getGPGOperation(); + if (operation) { + service = *serviceIt; + break; + } + } + } /******* UNLOCKED ******/ + + if (operation == NULL) { + /* nothing to do */ + return; + } + + if (service == NULL) { + /* huh ? */ + delete operation; + return; + } + + AuthGPGOperationLoadOrSave *loadOrSave = dynamic_cast(operation); + if (loadOrSave) { + if (loadOrSave->m_load) { + /* process load operation */ + +#ifdef GPG_DEBUG + std::cerr << "AuthGPGimpl::processServices() Process load operation" << std::endl; +#endif + + /* load the certificate */ + LoadCertificateFromString(loadOrSave->m_certGpg, loadOrSave->m_certGpgId); + } else { + /* process save operation */ + +#ifdef GPG_DEBUG + std::cerr << "AuthGPGimpl::processServices() Process save operation" << std::endl; +#endif + + /* save the certificate to string */ + loadOrSave->m_certGpg = SaveCertificateToString(loadOrSave->m_certGpgId); + } + + service->setGPGOperation(loadOrSave); + } else { +#ifdef GPG_DEBUG + std::cerr << "AuthGPGimpl::processServices() Unknown operation" << std::endl; +#endif + } + + delete operation; +} + bool AuthGPGimpl::storeAllKeys_tick() { #ifdef GPG_DEBUG std::cerr << "AuthGPGimpl::storeAllKeys_tick() called." << std::endl; @@ -892,7 +956,7 @@ bool AuthGPGimpl::DoOwnSignature(const void *data, unsigned int datalen, void *b /* import to GnuPG and other Certificates */ -bool AuthGPGimpl::VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, std::string withfingerprint) +bool AuthGPGimpl::VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const std::string &withfingerprint) { gpgme_data_t gpgmeSig; gpgme_data_t gpgmeData; @@ -1504,7 +1568,7 @@ bool AuthGPGimpl::SignDataBin(const void *data, unsigned int datalen, unsigned c sign, signlen); } -bool AuthGPGimpl::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen, std::string withfingerprint) { +bool AuthGPGimpl::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen, const std::string &withfingerprint) { return VerifySignature(data, datalen, sign, signlen, withfingerprint); } @@ -2314,3 +2378,15 @@ bool AuthGPGimpl::loadList(std::list load) return true; } +bool AuthGPGimpl::addService(AuthGPGService *service) +{ + RsStackMutex stack(gpgMtxService); /********* LOCKED *********/ + + if (std::find(services.begin(), services.end(), service) != services.end()) { + /* it exists already! */ + return false; + } + + services.push_back(service); + return true; +} diff --git a/libretroshare/src/pqi/authgpg.h b/libretroshare/src/pqi/authgpg.h index ba1cb688c..e2fda9f3f 100644 --- a/libretroshare/src/pqi/authgpg.h +++ b/libretroshare/src/pqi/authgpg.h @@ -84,6 +84,48 @@ class gpgcert gpgme_key_t key; }; +class AuthGPGOperation +{ +public: + AuthGPGOperation(void *userdata) + { + m_userdata = userdata; + } + virtual ~AuthGPGOperation() {} + +public: + void *m_userdata; +}; + +class AuthGPGOperationLoadOrSave : public AuthGPGOperation +{ +public: + AuthGPGOperationLoadOrSave(bool load, const std::string &certGpgOrId, void *userdata) : AuthGPGOperation(userdata) + { + m_load = load; + if (m_load) { + m_certGpg = certGpgOrId; + } else { + m_certGpgId = certGpgOrId; + } + } + +public: + bool m_load; + std::string m_certGpgId; // set for save + std::string m_certGpg; // set for load +}; + +class AuthGPGService +{ +public: + AuthGPGService() {}; + ~AuthGPGService() {}; + + virtual AuthGPGOperation *getGPGOperation() = 0; + virtual void setGPGOperation(AuthGPGOperation *operation) = 0; +}; + /*! * The certificate map type */ @@ -135,7 +177,7 @@ virtual bool InitAuth () = 0; virtual int GPGInit(std::string ownId) = 0; virtual bool CloseAuth() = 0; virtual bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString) = 0; - + /*********************************************************************************/ /************************* STAGE 3 ***********************************************/ /*********************************************************************************/ @@ -206,11 +248,13 @@ virtual bool TrustCertificate(std::string id, int trustlvl) = 0; //trustlvl is //virtual bool SignData(const void *data, const uint32_t len, std::string &sign) = 0; //virtual bool SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen) = 0; virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0; -virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, std::string withfingerprint) = 0; +virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const std::string &withfingerprint) = 0; virtual bool decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) = 0; virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) = 0; //END of PGP public functions +/* GPG service */ +virtual bool addService(AuthGPGService *service) = 0; }; @@ -253,7 +297,7 @@ virtual bool InitAuth (); virtual int GPGInit(std::string ownId); virtual bool CloseAuth(); virtual bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString); - + /*********************************************************************************/ /************************* STAGE 3 ***********************************************/ /*********************************************************************************/ @@ -325,11 +369,14 @@ virtual bool TrustCertificate(std::string id, int trustlvl); //trustlvl is 2 fo //virtual bool SignData(const void *data, const uint32_t len, std::string &sign); //virtual bool SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen); virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen); -virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, std::string withfingerprint); +virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const std::string &withfingerprint); virtual bool decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN); virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER); //END of PGP public functions +/* GPG service */ +virtual bool addService(AuthGPGService *service); + protected: /*****************************************************************/ /*********************** p3config ******************************/ @@ -348,7 +395,7 @@ virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER); /* Internal functions */ bool DoOwnSignature(const void *, unsigned int, void *, unsigned int *); - bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, std::string withfingerprint); + bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const std::string &withfingerprint); /* Sign/Trust stuff */ int privateSignCertificate(GPG_id id); @@ -362,6 +409,9 @@ virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER); // Not used anymore // bool updateTrustAllKeys_locked(); + /* GPG service */ + void processServices(); + bool printAllKeys_locked(); bool printOwnKeys_locked(); @@ -393,6 +443,10 @@ private: std::map mAcceptToConnectMap; + RsMutex gpgMtxService; + /* Below is protected via the mutex */ + + std::list services; }; /*! diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 98dd59277..48ecb6454 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -2506,6 +2506,12 @@ int RsServer::StartupRetroShare() //getPqiNotify()->ClearFeedItems(RS_FEED_ITEM_FILES_NEW); + /**************************************************************************/ + /* Add AuthGPG services */ + /**************************************************************************/ + + AuthGPG::getAuthGPG()->addService(ad); + /**************************************************************************/ /* Force Any Last Configuration Options */ /**************************************************************************/ diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index 508607535..a4dbffb61 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -120,42 +120,6 @@ int p3disc::tick() } } - std::string destId; - std::string srcId; - - { - RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ - - while (!sendIdList.empty()) { - std::map >::iterator sendIdIt = sendIdList.begin(); - - if (!sendIdIt->second.empty() && mConnMgr->isOnline(sendIdIt->first)) { - std::string gpgId = sendIdIt->second.front(); - sendIdIt->second.pop_front(); - - destId = sendIdIt->first; - srcId = gpgId; - - /* send only one per tick */ -#ifdef P3DISC_DEBUG - int count = 0; - for (sendIdIt = sendIdList.begin(); sendIdIt != sendIdList.end(); sendIdIt++) { - count += sendIdIt->second.size(); - } - std::cerr << "p3disc::tick() Count of gpg id's " << count << std::endl; -#endif - break; - } else { - /* peer is not online anymore ... try next */ - sendIdList.erase(sendIdIt); - } - } - } - - if (!destId.empty() && !srcId.empty()) { - sendPeerDetails(destId, srcId); - } - return handleIncoming(); } @@ -203,8 +167,20 @@ int p3disc::handleIncoming() // if discovery reply then respond if haven't already. if (NULL != (dri = dynamic_cast (item))) { + RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + + /* search pending item and remove it, when already exist */ + std::list::iterator it; + for (it = pendingDiscReplyInList.begin(); it != pendingDiscReplyInList.end(); it++) { + if ((*it)->PeerId() == dri->PeerId() && (*it)->aboutId == dri->aboutId) { + delete (*it); + pendingDiscReplyInList.erase(it); + break; + } + } + // add item to list for later process - discReplyList.push_back(dri); // no delete + pendingDiscReplyInList.push_back(dri); // no delete } else if (NULL != (dvi = dynamic_cast (item))) { recvPeerVersionMsg(dvi); @@ -232,18 +208,6 @@ int p3disc::handleIncoming() } } - // process one disc item - if (!discReplyList.empty()) { - RsDiscReply *dri = discReplyList.front(); - discReplyList.pop_front(); - recvPeerDetails(dri); - nhandled++; -#ifdef P3DISC_DEBUG - std::cerr << "p3disc::handleIncoming() Count of disc items " << discReplyList.size() << std::endl; -#endif - delete dri; - } - #ifdef P3DISC_DEBUG std::cerr << "p3disc::handleIncoming() finished." << std::endl; #endif @@ -294,7 +258,7 @@ void p3disc::statusChange(const std::list &plist) return; } -void p3disc::sendAllInfoToJustConnectedPeer(std::string id) +void p3disc::sendAllInfoToJustConnectedPeer(const std::string &id) { /* get a peer lists */ @@ -355,7 +319,7 @@ void p3disc::sendAllInfoToJustConnectedPeer(std::string id) #endif } -void p3disc::sendJustConnectedPeerInfoToAllPeer(std::string connectedPeerId) +void p3disc::sendJustConnectedPeerInfoToAllPeer(const std::string &connectedPeerId) { /* get a peer lists */ @@ -383,44 +347,43 @@ void p3disc::sendJustConnectedPeerInfoToAllPeer(std::string connectedPeerId) } /* (dest (to), source (cert)) */ -void p3disc::sendPeerDetails(std::string to, std::string about) +RsDiscReply *p3disc::createDiscReply(const std::string &to, const std::string &about) { - #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() called. Sending details of: " << about << " to: " << to << std::endl; + std::cerr << "p3disc::createDiscReply() called. Sending details of: " << about << " to: " << to << std::endl; #endif RsPeerDetails pd; rsPeers->getPeerDetails(to, pd); if (!pd.accept_connection || !pd.ownsign) { #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() we're not sending the info because the destination gpg key is not signed or not accepted." << std::cerr << std::endl; + std::cerr << "p3disc::createDiscReply() we're not sending the info because the destination gpg key is not signed or not accepted." << std::cerr << std::endl; #endif - return; + return NULL; } // if off discard item. peerConnectState detail; if (!mConnMgr->getOwnNetStatus(detail) || (detail.visState & RS_VIS_STATE_NODISC)) { - return; + return NULL; } std::string aboutGpgId = rsPeers->getGPGId(about); - if (about == "") { + if (aboutGpgId.empty()) { #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() no info about this id" << std::endl; + std::cerr << "p3disc::createDiscReply() no info about this id" << std::endl; #endif - return; + return NULL; } peerConnectState detailAbout; if (mConnMgr->getFriendNetStatus(aboutGpgId, detailAbout) && detailAbout.visState & RS_VIS_STATE_NODISC) { #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() don't send info about this peer because he has no disc enabled." << std::endl; + std::cerr << "p3disc::createDiscReply() don't send info about this peer because he has no disc enabled." << std::endl; #endif - return; + return NULL; } // Construct a message @@ -440,7 +403,7 @@ void p3disc::sendPeerDetails(std::string to, std::string about) for (sslChildIt = sslChilds.begin(); sslChildIt != sslChilds.end(); sslChildIt++) { #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() Found Child SSL Id:" << *sslChildIt; + std::cerr << "p3disc::createDiscReply() Found Child SSL Id:" << *sslChildIt; std::cerr << std::endl; #endif if(to != *sslChildIt) // We don't send info to a peer about itself, but we allow sending info @@ -450,14 +413,14 @@ void p3disc::sendPeerDetails(std::string to, std::string about) || detail.visState & RS_VIS_STATE_NODISC) { #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() Skipping cos No Details or NODISC flag"; + std::cerr << "p3disc::createDiscReply() Skipping cos No Details or NODISC flag"; std::cerr << std::endl; #endif continue; } #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() Adding Child SSL Id Details"; + std::cerr << "p3disc::createDiscReply() Adding Child SSL Id Details"; std::cerr << std::endl; #endif shouldWeSendGPGKey = true; @@ -482,7 +445,7 @@ void p3disc::sendPeerDetails(std::string to, std::string about) else { #ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() Skipping cos \"to == sslChildId\""; + std::cerr << "p3disc::createDiscReply() Skipping cos \"to == sslChildId\""; std::cerr << std::endl; #endif } @@ -517,34 +480,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; + std::cerr << "p3disc::createDiscReply() GPG key should not be send, no friend with disc on found about it." << std::endl; #endif // cleanup! delete di; - return; + return NULL; } - std::string cert = AuthGPG::getAuthGPG()->SaveCertificateToString(about); - if (cert == "") { -#ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() don't send details because the gpg cert is not good" << std::endl; -#endif - // cleanup! - delete di; - return; - } - di -> certGPG = cert; - - // Send off message -#ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() About to Send Message:" << std::endl; - di->print(std::cerr, 5); -#endif - sendItem(di); - -#ifdef P3DISC_DEBUG - std::cerr << "p3disc::sendPeerDetails() discovery reply sent." << std::endl; -#endif + return di; } void p3disc::sendOwnVersion(std::string to) @@ -649,7 +592,7 @@ void p3disc::askInfoToAllPeers(std::string about) #endif } -void p3disc::recvPeerDetails(RsDiscReply *item) +void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId) { // discovery is only disabled for sending, not for receiving. // // if off discard item. @@ -661,8 +604,8 @@ void p3disc::recvPeerDetails(RsDiscReply *item) #ifdef P3DISC_DEBUG std::cerr << "p3disc::recvPeerFriendMsg() From: " << item->PeerId() << " About " << item->aboutId << std::endl; #endif - std::string certGpgId; - if (!AuthGPG::getAuthGPG()->LoadCertificateFromString(item->certGPG, certGpgId)) { + + if (certGpgId.empty()) { #ifdef P3DISC_DEBUG std::cerr << "p3disc::recvPeerFriendMsg() gpg cert is not good, aborting" << std::endl; #endif @@ -816,9 +759,11 @@ void p3disc::recvAskInfo(RsDiscAskInfo *item) { std::cerr << std::endl; #endif - sendPeerDetails(item->PeerId(), item->gpg_id); + std::list &idList = sendIdList[item->PeerId()]; - return; + if (std::find(idList.begin(), idList.end(), item->gpg_id) == idList.end()) { + idList.push_back(item->gpg_id); + } } void p3disc::removeFriend(std::string ssl_id) { @@ -831,7 +776,7 @@ void p3disc::removeFriend(std::string ssl_id) { std::cerr << "p3disc::removeFriend() gpg_id : " << gpg_id << std::endl; #endif if (gpg_id == AuthGPG::getAuthGPG()->getGPGOwnId() || rsPeers->isGPGAccepted(rsPeers->getGPGId(ssl_id))) { - #ifdef P3DISC_DEBUG +#ifdef P3DISC_DEBUG std::cerr << "p3disc::removeFriend() storing the friend deletion." << ssl_id << std::endl; #endif deletedSSLFriendsIds[ssl_id] = time(NULL);//just keep track of the deleted time @@ -839,6 +784,113 @@ void p3disc::removeFriend(std::string ssl_id) { } } +/*************************************************************************************/ +/* AuthGPGService */ +/*************************************************************************************/ +AuthGPGOperation *p3disc::getGPGOperation() +{ + { + RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + + /* process disc reply in list */ + if (pendingDiscReplyInList.empty() == false) { + RsDiscReply *item = pendingDiscReplyInList.front(); + + return new AuthGPGOperationLoadOrSave(true, item->certGPG, item); + } + } + + /* process disc reply out list */ + + std::string destId; + std::string srcId; + + { + RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + + while (!sendIdList.empty()) { + std::map >::iterator sendIdIt = sendIdList.begin(); + + if (!sendIdIt->second.empty() && mConnMgr->isOnline(sendIdIt->first)) { + std::string gpgId = sendIdIt->second.front(); + sendIdIt->second.pop_front(); + + destId = sendIdIt->first; + srcId = gpgId; + + break; + } else { + /* peer is not online anymore ... try next */ + sendIdList.erase(sendIdIt); + } + } + } + + if (!destId.empty() && !srcId.empty()) { + RsDiscReply *item = createDiscReply(destId, srcId); + if (item) { + return new AuthGPGOperationLoadOrSave(false, item->aboutId, item); + } + } + + return NULL; +} + +void p3disc::setGPGOperation(AuthGPGOperation *operation) +{ + AuthGPGOperationLoadOrSave *loadOrSave = dynamic_cast(operation); + if (loadOrSave) { + if (loadOrSave->m_load) { + /* search in pending in list */ + RsDiscReply *item = NULL; + + { + RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + + std::list::iterator it = std::find(pendingDiscReplyInList.begin(), pendingDiscReplyInList.end(), loadOrSave->m_userdata); + if (it != pendingDiscReplyInList.end()) { + item = *it; + pendingDiscReplyInList.erase(it); + } + } + + if (item) { + recvPeerDetails(item, loadOrSave->m_certGpgId); + delete item; + } + } else { + RsDiscReply *item = (RsDiscReply*) loadOrSave->m_userdata; + + if (item) { + if (loadOrSave->m_certGpg.empty()) { +#ifdef P3DISC_DEBUG + std::cerr << "p3disc::setGPGOperation() don't send details because the gpg cert is not good" << std::endl; +#endif + delete item; + return; + } + + // Send off message + item->certGPG = loadOrSave->m_certGpg; + +#ifdef P3DISC_DEBUG + std::cerr << "p3disc::setGPGOperation() About to Send Message:" << std::endl; + item->print(std::cerr, 5); +#endif + + sendItem(item); + +#ifdef P3DISC_DEBUG + std::cerr << "p3disc::cbkGPGOperationSave() discovery reply sent." << std::endl; +#endif + } + } + return; + } + + /* ignore other operations */ +} + /*************************************************************************************/ /* Storing Network Graph */ /*************************************************************************************/ diff --git a/libretroshare/src/services/p3disc.h b/libretroshare/src/services/p3disc.h index 5cb83c997..904e13463 100644 --- a/libretroshare/src/services/p3disc.h +++ b/libretroshare/src/services/p3disc.h @@ -42,6 +42,7 @@ class p3ConnectMgr; #include "pqi/pqimonitor.h" #include "serialiser/rsdiscitems.h" #include "services/p3service.h" +#include "pqi/authgpg.h" class autoserver { @@ -74,7 +75,7 @@ class autoneighbour: public autoserver class p3ConnectMgr; -class p3disc: public p3Service, public pqiMonitor, public p3Config +class p3disc: public p3Service, public pqiMonitor, public p3Config, public AuthGPGService { public: @@ -91,6 +92,10 @@ int tick(); bool potentialproxies(std::string id, std::list &proxyIds); void getversions(std::map &versions); + /************* from AuthGPService ****************/ +virtual AuthGPGOperation *getGPGOperation(); +virtual void setGPGOperation(AuthGPGOperation *operation); + protected: /*****************************************************************/ /*********************** p3config ******************************/ @@ -103,13 +108,13 @@ virtual bool loadList(std::list load); private: -void sendAllInfoToJustConnectedPeer(std::string id); -void sendJustConnectedPeerInfoToAllPeer(std::string id); +void sendAllInfoToJustConnectedPeer(const std::string &id); +void sendJustConnectedPeerInfoToAllPeer(const std::string &id); /* Network Output */ //void sendOwnDetails(std::string to); void sendOwnVersion(std::string to); -void sendPeerDetails(std::string to, std::string about); +RsDiscReply *createDiscReply(const std::string &to, const std::string &about); //void sendPeerIssuer(std::string to, std::string about); void sendHeartbeat(std::string to); void askInfoToAllPeers(std::string about); @@ -117,7 +122,7 @@ void askInfoToAllPeers(std::string about); /* Network Input */ int handleIncoming(); void recvAskInfo(RsDiscAskInfo *item); -void recvPeerDetails(RsDiscReply *item); +void recvPeerDetails(RsDiscReply *item, const std::string &certGpgId); //void recvPeerIssuerMsg(RsDiscIssuer *item); void recvPeerVersionMsg(RsDiscVersion *item); void recvHeartbeatMsg(RsDiscHeartbeat *item); @@ -131,7 +136,6 @@ int addDiscoveryData(std::string fromId, std::string aboutId, int idServers(); - private: p3ConnectMgr *mConnMgr; @@ -147,7 +151,7 @@ int idServers(); std::map versions; std::map > sendIdList; - std::list discReplyList; + std::list pendingDiscReplyInList; };