mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-14 09:05:48 -04:00
ID cleaning. Unfinished yet.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7096 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c4c8414a79
commit
effbf8f683
18 changed files with 166 additions and 157 deletions
|
@ -348,7 +348,7 @@ bool p3BitDht::dropPeer(std::string pid)
|
|||
|
||||
|
||||
/* extract current peer status */
|
||||
bool p3BitDht::getPeerStatus(std::string id,
|
||||
bool p3BitDht::getPeerStatus(const RsPeerId& id,
|
||||
struct sockaddr_storage &/*laddr*/, struct sockaddr_storage &/*raddr*/,
|
||||
uint32_t &/*type*/, uint32_t &/*mode*/)
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ int p3BitDht::getDhtPeers(int lvl, std::list<RsDhtPeer> &peers)
|
|||
return (int_peers.entries.size() > 0);
|
||||
}
|
||||
|
||||
int p3BitDht::getNetPeerList(std::list<std::string> &peerIds)
|
||||
int p3BitDht::getNetPeerList(std::list<RsPeerId> &peerIds)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /*********** LOCKED **********/
|
||||
std::map<bdNodeId, DhtPeerDetails>::iterator it;
|
||||
|
@ -78,7 +78,7 @@ int p3BitDht::getNetPeerList(std::list<std::string> &peerIds)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int p3BitDht::getNetPeerStatus(std::string peerId, RsDhtNetPeer &status)
|
||||
int p3BitDht::getNetPeerStatus(const RsPeerId& peerId, RsDhtNetPeer &status)
|
||||
{
|
||||
|
||||
RsStackMutex stack(dhtMtx); /*********** LOCKED **********/
|
||||
|
|
|
@ -143,7 +143,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mProxyStunner->addStunPeer(id->addr, "");
|
||||
mProxyStunner->addStunPeer(id->addr, NULL);
|
||||
}
|
||||
/* else */ // removed else until we have lots of peers.
|
||||
|
||||
|
@ -154,7 +154,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mDhtStunner->addStunPeer(id->addr, "");
|
||||
mDhtStunner->addStunPeer(id->addr, NULL);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -632,7 +632,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
|
|||
/* if we get here, we are an endpoint (peer specified in peerId) */
|
||||
|
||||
/* translate id into string for exclusive mode */
|
||||
RsPeerId pid;
|
||||
std::string pid;
|
||||
bdStdPrintNodeId(pid, &(peerId.id), false);
|
||||
|
||||
switch(cbtype)
|
||||
|
@ -1178,7 +1178,7 @@ int p3BitDht::doActions()
|
|||
bool grabbedExclusivePort = false;
|
||||
|
||||
/* translate id into string for exclusive mode */
|
||||
RsPeerId pid;
|
||||
std::string pid;
|
||||
bdStdPrintNodeId(pid, &(action.mDestId.id), false);
|
||||
|
||||
|
||||
|
@ -2382,7 +2382,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
|
|||
std::cerr << std::endl;
|
||||
|
||||
/* translate id into string for exclusive mode */
|
||||
RsPeerId pid;
|
||||
std::string pid;
|
||||
bdStdPrintNodeId(pid, &(dpd->mDhtId.id), false);
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#define USE_OLD_DHT_INTERFACE 1
|
||||
|
||||
|
||||
bool p3BitDht::findPeer(std::string pid)
|
||||
bool p3BitDht::findPeer(const RsPeerId& pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT
|
||||
std::cerr << "p3BitDht::findPeer(" << pid << ")";
|
||||
|
@ -133,7 +133,7 @@ bool p3BitDht::findPeer(std::string pid)
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool p3BitDht::dropPeer(std::string pid)
|
||||
bool p3BitDht::dropPeer(const RsPeerId& pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT
|
||||
std::cerr << "p3BitDht::dropPeer(" << pid << ")";
|
||||
|
@ -216,7 +216,7 @@ int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::addKnownPeer(const std::string &pid, const struct sockaddr_storage &addr, uint32_t flags)
|
||||
int p3BitDht::addKnownPeer(const RsPeerId &pid, const struct sockaddr_storage &addr, uint32_t flags)
|
||||
{
|
||||
struct sockaddr_in addrv4;
|
||||
|
||||
|
@ -389,7 +389,7 @@ int p3BitDht::addOther(const std::string pid)
|
|||
#endif
|
||||
|
||||
|
||||
int p3BitDht::removePeer(const std::string pid)
|
||||
int p3BitDht::removePeer(const RsPeerId& pid)
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********* LOCKED *********/
|
||||
|
||||
|
@ -401,7 +401,7 @@ int p3BitDht::removePeer(const std::string pid)
|
|||
********************************* Basic Peer Details *************************************
|
||||
******************************************************************************************/
|
||||
|
||||
DhtPeerDetails *p3BitDht::addInternalPeer_locked(const std::string pid, uint32_t type)
|
||||
DhtPeerDetails *p3BitDht::addInternalPeer_locked(const RsPeerId& pid, uint32_t type)
|
||||
{
|
||||
/* create the data structure */
|
||||
if (!havePeerTranslation_locked(pid))
|
||||
|
@ -435,7 +435,7 @@ DhtPeerDetails *p3BitDht::addInternalPeer_locked(const std::string pid, uint32_t
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::removeInternalPeer_locked(const std::string pid)
|
||||
int p3BitDht::removeInternalPeer_locked(const RsPeerId& pid)
|
||||
{
|
||||
bdNodeId id;
|
||||
if (!lookupNodeId_locked(pid, &id))
|
||||
|
@ -478,7 +478,7 @@ DhtPeerDetails *p3BitDht::findInternalDhtPeer_locked(const bdNodeId *id, uint32_
|
|||
|
||||
|
||||
/* interface to get with alt id */
|
||||
DhtPeerDetails *p3BitDht::findInternalRsPeer_locked(const std::string &pid)
|
||||
DhtPeerDetails *p3BitDht::findInternalRsPeer_locked(const RsPeerId &pid)
|
||||
{
|
||||
/* create the data structure */
|
||||
if (!havePeerTranslation_locked(pid))
|
||||
|
@ -502,14 +502,14 @@ DhtPeerDetails *p3BitDht::findInternalRsPeer_locked(const std::string &pid)
|
|||
*************************** Fundamental Node Translation *********************************
|
||||
******************************************************************************************/
|
||||
|
||||
bool p3BitDht::havePeerTranslation_locked(const std::string &pid)
|
||||
bool p3BitDht::havePeerTranslation_locked(const RsPeerId &pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::havePeerTranslation_locked() for : " << pid;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, bdNodeId>::iterator it;
|
||||
std::map<RsPeerId, bdNodeId>::iterator it;
|
||||
it = mTransToNodeId.find(pid);
|
||||
if (it == mTransToNodeId.end())
|
||||
{
|
||||
|
@ -531,14 +531,14 @@ bool p3BitDht::havePeerTranslation_locked(const std::string &pid)
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::lookupNodeId_locked(const std::string pid, bdNodeId *id)
|
||||
int p3BitDht::lookupNodeId_locked(const RsPeerId& pid, bdNodeId *id)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::lookupNodeId_locked() for : " << pid;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, bdNodeId>::iterator it;
|
||||
std::map<RsPeerId, bdNodeId>::iterator it;
|
||||
it = mTransToNodeId.find(pid);
|
||||
if (it == mTransToNodeId.end())
|
||||
{
|
||||
|
@ -562,7 +562,7 @@ int p3BitDht::lookupNodeId_locked(const std::string pid, bdNodeId *id)
|
|||
}
|
||||
|
||||
|
||||
int p3BitDht::lookupRsId_locked(const bdNodeId *id, std::string &pid)
|
||||
int p3BitDht::lookupRsId_locked(const bdNodeId *id, RsPeerId&pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::lookupRsId_locked() for : ";
|
||||
|
@ -570,7 +570,7 @@ int p3BitDht::lookupRsId_locked(const bdNodeId *id, std::string &pid)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<bdNodeId, std::string>::iterator nit;
|
||||
std::map<bdNodeId, RsPeerId>::iterator nit;
|
||||
nit = mTransToRsId.find(*id);
|
||||
if (nit == mTransToRsId.end())
|
||||
{
|
||||
|
@ -592,7 +592,7 @@ int p3BitDht::lookupRsId_locked(const bdNodeId *id, std::string &pid)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int p3BitDht::storeTranslation_locked(const std::string pid)
|
||||
int p3BitDht::storeTranslation_locked(const RsPeerId& pid)
|
||||
{
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
std::cerr << "p3BitDht::storeTranslation_locked(" << pid << ")";
|
||||
|
@ -619,7 +619,7 @@ int p3BitDht::storeTranslation_locked(const std::string pid)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int p3BitDht::removeTranslation_locked(const std::string pid)
|
||||
int p3BitDht::removeTranslation_locked(const RsPeerId& pid)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
|
@ -627,7 +627,7 @@ int p3BitDht::removeTranslation_locked(const std::string pid)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string, bdNodeId>::iterator it = mTransToNodeId.find(pid);
|
||||
std::map<RsPeerId, bdNodeId>::iterator it = mTransToNodeId.find(pid);
|
||||
it = mTransToNodeId.find(pid);
|
||||
if (it == mTransToNodeId.end())
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ int p3BitDht::removeTranslation_locked(const std::string pid)
|
|||
#endif
|
||||
|
||||
|
||||
std::map<bdNodeId, std::string>::iterator nit;
|
||||
std::map<bdNodeId, RsPeerId>::iterator nit;
|
||||
nit = mTransToRsId.find(nid);
|
||||
if (nit == mTransToRsId.end())
|
||||
{
|
||||
|
@ -676,7 +676,7 @@ const uint8_t RS_DHT_VERSION_LEN = 17;
|
|||
const uint8_t rs_dht_version_data[RS_DHT_VERSION_LEN] = "RS_VERSION_0.5.1";
|
||||
|
||||
/******************** Conversion Functions **************************/
|
||||
int p3BitDht::calculateNodeId(const std::string pid, bdNodeId *id)
|
||||
int p3BitDht::calculateNodeId(const RsPeerId& pid, bdNodeId *id)
|
||||
{
|
||||
/* generate node id from pid */
|
||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||
|
@ -691,7 +691,7 @@ int p3BitDht::calculateNodeId(const std::string pid, bdNodeId *id)
|
|||
SHA1_Init(sha_ctx);
|
||||
|
||||
SHA1_Update(sha_ctx, rs_dht_version_data, RS_DHT_VERSION_LEN);
|
||||
SHA1_Update(sha_ctx, pid.c_str(), pid.length());
|
||||
SHA1_Update(sha_ctx, pid.toByteArray(), RsPeerId::SIZE_IN_BYTES);
|
||||
SHA1_Final(sha_hash, sha_ctx);
|
||||
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH && (i < BITDHT_KEY_LEN); i++)
|
||||
|
|
|
@ -2083,24 +2083,18 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
RsDirUtil::removeTopDir(fit->second->mDestination, rft->file.path); /* remove fname */
|
||||
rft->flags = fit->second->mFlags.toUInt32();
|
||||
rft->state = fit->second->mState;
|
||||
fit->second->mTransfer->getFileSources(rft->allPeerIds.ids);
|
||||
|
||||
rft->transferred = fit->second->mCreator->getRecvd();
|
||||
std::list<RsPeerId> lst ;
|
||||
fit->second->mTransfer->getFileSources(lst);
|
||||
|
||||
// Remove turtle peers from sources, as they are not supposed to survive a reboot of RS, since they are dynamic sources.
|
||||
// Otherwize, such sources are unknown from the turtle router, at restart, and never get removed.
|
||||
//
|
||||
for(std::list<std::string>::iterator sit(rft->allPeerIds.ids.begin());sit!=rft->allPeerIds.ids.end();)
|
||||
if(mTurtle->isTurtlePeer(*sit))
|
||||
{
|
||||
std::list<std::string>::iterator sittmp(sit) ;
|
||||
++sittmp ;
|
||||
rft->allPeerIds.ids.erase(sit) ;
|
||||
sit = sittmp ;
|
||||
}
|
||||
else
|
||||
++sit ;
|
||||
for(std::list<RsPeerId>::const_iterator it(lst.begin());it!=lst.end();++it)
|
||||
if(!mTurtle->isTurtlePeer(*it))
|
||||
rft->allPeerIds.ids.push_back((*it).toStdString()) ;
|
||||
|
||||
rft->transferred = fit->second->mCreator->getRecvd();
|
||||
fit->second->mCreator->getAvailabilityMap(rft->compressed_chunk_map) ;
|
||||
rft->chunk_strategy = fit->second->mCreator->getChunkStrategy() ;
|
||||
|
||||
|
@ -2132,14 +2126,18 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
RsDirUtil::removeTopDir(pit->mDest, rft->file.path); /* remove fname */
|
||||
rft->flags = pit->mFlags.toUInt32();
|
||||
rft->state = pit->mState;
|
||||
rft->allPeerIds.ids = pit->mSrcIds;
|
||||
|
||||
rft->allPeerIds.ids.clear() ;
|
||||
for(std::list<RsPeerId>::const_iterator it(pit->mSrcIds.begin());it!=pit->mSrcIds.end();++it)
|
||||
rft->allPeerIds.ids.push_back( (*it).toStdString() ) ;
|
||||
}
|
||||
|
||||
// Remove turtle peers from sources, as they are not supposed to survive a reboot of RS, since they are dynamic sources.
|
||||
// Otherwize, such sources are unknown from the turtle router, at restart, and never get removed.
|
||||
// Otherwize, such sources are unknown from the turtle router, at restart, and never get removed. We do that in post
|
||||
// process since the rft object may have been created from mPendingChunkMaps
|
||||
//
|
||||
for(std::list<RsPeerId>::iterator sit(rft->allPeerIds.ids.begin());sit!=rft->allPeerIds.ids.end();)
|
||||
if(mTurtle->isTurtlePeer(*sit))
|
||||
for(std::list<std::string>::iterator sit(rft->allPeerIds.ids.begin());sit!=rft->allPeerIds.ids.end();)
|
||||
if(mTurtle->isTurtlePeer(RsPeerId(*sit)))
|
||||
{
|
||||
std::list<std::string>::iterator sittmp(sit) ;
|
||||
sit = rft->allPeerIds.ids.erase(sit) ;
|
||||
|
@ -2201,7 +2199,11 @@ bool ftController::loadList(std::list<RsItem *>& load)
|
|||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::loadList(): requesting " << rsft->file.name << ", " << rsft->file.hash << ", " << rsft->file.filesize << std::endl ;
|
||||
#endif
|
||||
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, TransferRequestFlags(rsft->flags), rsft->allPeerIds.ids, rsft->state);
|
||||
std::list<RsPeerId> src_lst ;
|
||||
for(std::list<std::string>::const_iterator it(rsft->allPeerIds.ids.begin());it!=rsft->allPeerIds.ids.end();++it)
|
||||
src_lst.push_back(RsPeerId(*it)) ;
|
||||
|
||||
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, TransferRequestFlags(rsft->flags), src_lst, rsft->state);
|
||||
|
||||
{
|
||||
RsStackMutex mtx(ctrlMutex) ;
|
||||
|
|
|
@ -80,10 +80,10 @@ int RsGxsNetService::tick(){
|
|||
void RsGxsNetService::syncWithPeers()
|
||||
{
|
||||
|
||||
std::set<std::string> peers;
|
||||
std::set<RsPeerId> peers;
|
||||
mNetMgr->getOnlineList(peers);
|
||||
|
||||
std::set<std::string>::iterator sit = peers.begin();
|
||||
std::set<RsPeerId>::iterator sit = peers.begin();
|
||||
|
||||
if(mGrpAutoSync)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ void RsGxsNetService::syncWithPeers()
|
|||
for(; sit != peers.end(); sit++)
|
||||
{
|
||||
|
||||
const std::string peerId = *sit;
|
||||
const RsPeerId peerId = *sit;
|
||||
|
||||
ClientGrpMap::const_iterator cit = mClientGrpUpdateMap.find(peerId);
|
||||
uint32_t updateTS = 0;
|
||||
|
@ -154,7 +154,7 @@ void RsGxsNetService::syncWithPeers()
|
|||
uint32_t updateTS = 0;
|
||||
if(mui)
|
||||
{
|
||||
std::map<std::string, uint32_t>::const_iterator cit2 = mui->msgUpdateTS.find(*vit);
|
||||
std::map<RsPeerId, uint32_t>::const_iterator cit2 = mui->msgUpdateTS.find(*vit);
|
||||
|
||||
if(cit2 != mui->msgUpdateTS.end())
|
||||
{
|
||||
|
@ -427,7 +427,7 @@ void RsGxsNetService::locked_createTransactionFromPending(MsgCircleIdsRequestVet
|
|||
}
|
||||
|
||||
bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta,
|
||||
const std::string& peerId)
|
||||
const RsPeerId& peerId)
|
||||
{
|
||||
|
||||
double timeDelta = 0.2;
|
||||
|
@ -720,7 +720,7 @@ bool RsGxsNetService::handleTransaction(RsNxsItem* item)
|
|||
|
||||
RsStackMutex stack(mNxsMutex);
|
||||
|
||||
const std::string& peer = item->PeerId();
|
||||
const RsPeerId& peer = item->PeerId();
|
||||
|
||||
RsNxsTransac* transItem = dynamic_cast<RsNxsTransac*>(item);
|
||||
|
||||
|
@ -783,7 +783,7 @@ bool RsGxsNetService::locked_processTransac(RsNxsTransac* item)
|
|||
* For ending a transaction the
|
||||
*/
|
||||
|
||||
std::string peer;
|
||||
RsPeerId peer;
|
||||
|
||||
// for outgoing transaction use own id
|
||||
if(item->transactFlag & (RsNxsTransac::FLAG_BEGIN_P2 | RsNxsTransac::FLAG_END_SUCCESS))
|
||||
|
@ -1228,7 +1228,7 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
|
|||
mObserver->notifyNewGroups(grps);
|
||||
|
||||
// now note this as the latest you've received from this peer
|
||||
std::string peerFrom = tr->mTransaction->PeerId();
|
||||
RsPeerId peerFrom = tr->mTransaction->PeerId();
|
||||
uint32_t updateTS = tr->mTransaction->updateTS;
|
||||
|
||||
ClientGrpMap::iterator it = mClientGrpUpdateMap.find(peerFrom);
|
||||
|
@ -1311,7 +1311,7 @@ void RsGxsNetService::locked_doMsgUpdateWork(const RsNxsTransac *nxsTrans, const
|
|||
{
|
||||
|
||||
// firts check if peer exists
|
||||
const std::string& peerFrom = nxsTrans->PeerId();
|
||||
const RsPeerId& peerFrom = nxsTrans->PeerId();
|
||||
|
||||
ClientMsgMap::iterator it = mClientMsgUpdateMap.find(peerFrom);
|
||||
|
||||
|
@ -1401,7 +1401,7 @@ void RsGxsNetService::locked_processCompletedOutgoingTrans(NxsTransaction* tr)
|
|||
|
||||
|
||||
void RsGxsNetService::locked_pushMsgTransactionFromList(
|
||||
std::list<RsNxsItem*>& reqList, const std::string& peerId, const uint32_t& transN)
|
||||
std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN)
|
||||
{
|
||||
RsNxsTransac* transac = new RsNxsTransac(mServType);
|
||||
transac->transactFlag = RsNxsTransac::FLAG_TYPE_MSG_LIST_REQ
|
||||
|
@ -1507,11 +1507,11 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
std::list<RsNxsSyncMsgItem*>::iterator llit = msgItemL.begin();
|
||||
std::list<RsNxsItem*> reqList;
|
||||
|
||||
const std::string peerFrom = tr->mTransaction->PeerId();
|
||||
const RsPeerId peerFrom = tr->mTransaction->PeerId();
|
||||
|
||||
MsgAuthorV toVet;
|
||||
|
||||
std::list<std::string> peers;
|
||||
std::list<RsPeerId> peers;
|
||||
peers.push_back(tr->mTransaction->PeerId());
|
||||
|
||||
for(; llit != msgItemL.end(); llit++)
|
||||
|
@ -1570,7 +1570,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
}
|
||||
|
||||
void RsGxsNetService::locked_pushGrpTransactionFromList(
|
||||
std::list<RsNxsItem*>& reqList, const std::string& peerId, const uint32_t& transN)
|
||||
std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN)
|
||||
{
|
||||
RsNxsTransac* transac = new RsNxsTransac(mServType);
|
||||
transac->transactFlag = RsNxsTransac::FLAG_TYPE_GRP_LIST_REQ
|
||||
|
@ -1627,8 +1627,8 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
}
|
||||
}
|
||||
|
||||
std::map<std::string, RsGxsGrpMetaData*> grpMetaMap;
|
||||
std::map<std::string, RsGxsGrpMetaData*>::const_iterator metaIter;
|
||||
std::map<RsPeerId, RsGxsGrpMetaData*> grpMetaMap;
|
||||
std::map<RsPeerId, RsGxsGrpMetaData*>::const_iterator metaIter;
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||
|
||||
// now do compare and add loop
|
||||
|
@ -1638,7 +1638,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
uint32_t transN = locked_getTransactionId();
|
||||
|
||||
GrpAuthorV toVet;
|
||||
std::list<std::string> peers;
|
||||
std::list<RsPeerId> peers;
|
||||
peers.push_back(tr->mTransaction->PeerId());
|
||||
|
||||
for(; llit != grpItemL.end(); llit++)
|
||||
|
@ -1692,7 +1692,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
|
||||
if(!toVet.empty())
|
||||
{
|
||||
std::string peerId = tr->mTransaction->PeerId();
|
||||
RsPeerId peerId = tr->mTransaction->PeerId();
|
||||
GrpRespPending* grp = new GrpRespPending(mReputations, peerId, toVet);
|
||||
mPendingResp.push_back(grp);
|
||||
}
|
||||
|
@ -1705,7 +1705,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
}
|
||||
|
||||
// clean up meta data
|
||||
std::map<std::string, RsGxsGrpMetaData*>::iterator mit = grpMetaMap.begin();
|
||||
std::map<RsPeerId, RsGxsGrpMetaData*>::iterator mit = grpMetaMap.begin();
|
||||
|
||||
for(; mit != grpMetaMap.end(); mit++)
|
||||
delete mit->second;
|
||||
|
@ -1756,7 +1756,7 @@ void RsGxsNetService::locked_genSendGrpsTransaction(NxsTransaction* tr)
|
|||
|
||||
// store grp items to send in transaction
|
||||
std::map<std::string, RsNxsGrp*>::iterator mit = grps.begin();
|
||||
std::string peerId = tr->mTransaction->PeerId();
|
||||
RsPeerId peerId = tr->mTransaction->PeerId();
|
||||
for(;mit != grps.end(); mit++)
|
||||
{
|
||||
mit->second->PeerId(peerId); // set so it gets sent to right peer
|
||||
|
@ -1923,7 +1923,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr)
|
|||
|
||||
// store msg items to send in transaction
|
||||
GxsMsgResult::iterator mit = msgs.begin();
|
||||
std::string peerId = tr->mTransaction->PeerId();
|
||||
RsPeerId peerId = tr->mTransaction->PeerId();
|
||||
uint32_t msgSize = 0;
|
||||
|
||||
for(;mit != msgs.end(); mit++)
|
||||
|
@ -1992,7 +1992,7 @@ uint32_t RsGxsNetService::locked_getTransactionId()
|
|||
}
|
||||
bool RsGxsNetService::locked_addTransaction(NxsTransaction* tr)
|
||||
{
|
||||
const std::string& peer = tr->mTransaction->PeerId();
|
||||
const RsPeerId& peer = tr->mTransaction->PeerId();
|
||||
uint32_t transN = tr->mTransaction->transactionNumber;
|
||||
TransactionIdMap& transMap = mTransactions[peer];
|
||||
bool transNumExist = transMap.find(transN)
|
||||
|
@ -2025,7 +2025,7 @@ void RsGxsNetService::cleanTransactionItems(NxsTransaction* tr) const
|
|||
}
|
||||
|
||||
void RsGxsNetService::locked_pushGrpRespFromList(std::list<RsNxsItem*>& respList,
|
||||
const std::string& peer, const uint32_t& transN)
|
||||
const RsPeerId& peer, const uint32_t& transN)
|
||||
{
|
||||
NxsTransaction* tr = new NxsTransaction();
|
||||
tr->mItems = respList;
|
||||
|
@ -2069,7 +2069,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||
if(!locked_CanReceiveUpdate(item))
|
||||
return;
|
||||
|
||||
std::string peer = item->PeerId();
|
||||
RsPeerId peer = item->PeerId();
|
||||
|
||||
|
||||
|
||||
|
@ -2128,7 +2128,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||
|
||||
|
||||
|
||||
bool RsGxsNetService::canSendGrpId(const std::string& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet)
|
||||
bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet)
|
||||
{
|
||||
// first do the simple checks
|
||||
uint8_t circleType = grpMeta.mCircleType;
|
||||
|
@ -2208,7 +2208,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
|
|||
if(!locked_CanReceiveUpdate(item))
|
||||
return;
|
||||
|
||||
const std::string& peer = item->PeerId();
|
||||
const RsPeerId& peer = item->PeerId();
|
||||
|
||||
GxsMsgMetaResult metaResult;
|
||||
GxsMsgReq req;
|
||||
|
@ -2266,7 +2266,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
|
|||
delete(grpMeta);
|
||||
}
|
||||
|
||||
void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const std::string& sslId,
|
||||
void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId,
|
||||
const uint32_t& transN)
|
||||
{
|
||||
NxsTransaction* tr = new NxsTransaction();
|
||||
|
@ -2294,7 +2294,7 @@ void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, c
|
|||
}
|
||||
|
||||
bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMetas,
|
||||
const RsGxsGrpMetaData& grpMeta, const std::string& sslId)
|
||||
const RsGxsGrpMetaData& grpMeta, const RsPeerId& sslId)
|
||||
{
|
||||
// first do the simple checks
|
||||
uint8_t circleType = grpMeta.mCircleType;
|
||||
|
@ -2389,7 +2389,7 @@ void RsGxsNetService::setSyncAge(uint32_t age)
|
|||
|
||||
}
|
||||
|
||||
int RsGxsNetService::requestGrp(const std::list<RsGxsGroupId>& grpId, const std::string& peerId)
|
||||
int RsGxsNetService::requestGrp(const std::list<RsGxsGroupId>& grpId, const RsPeerId& peerId)
|
||||
{
|
||||
RsStackMutex stack(mNxsMutex);
|
||||
mExplicitRequest[peerId].assign(grpId.begin(), grpId.end());
|
||||
|
@ -2400,11 +2400,11 @@ void RsGxsNetService::processExplicitGroupRequests()
|
|||
{
|
||||
RsStackMutex stack(mNxsMutex);
|
||||
|
||||
std::map<std::string, std::list<RsGxsGroupId> >::const_iterator cit = mExplicitRequest.begin();
|
||||
std::map<RsPeerId, std::list<RsGxsGroupId> >::const_iterator cit = mExplicitRequest.begin();
|
||||
|
||||
for(; cit != mExplicitRequest.end(); cit++)
|
||||
{
|
||||
const std::string& peerId = cit->first;
|
||||
const RsPeerId& peerId = cit->first;
|
||||
const std::list<RsGxsGroupId>& groupIdList = cit->second;
|
||||
|
||||
std::list<RsNxsItem*> grpSyncItems;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
typedef std::map<uint32_t, NxsTransaction*> TransactionIdMap;
|
||||
|
||||
/// to keep track of peers active transactions
|
||||
typedef std::map<std::string, TransactionIdMap > TransactionsPeerMap;
|
||||
typedef std::map<RsPeerId, TransactionIdMap > TransactionsPeerMap;
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
* Circumvents polling of peers for message
|
||||
* @param peerId id of peer
|
||||
*/
|
||||
void requestGroupsOfPeer(const std::string& peerId){ return;}
|
||||
void requestGroupsOfPeer(const RsPeerId& peerId){ return;}
|
||||
|
||||
/*!
|
||||
* get messages of a peer for a given group id, this circumvents the normal
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
* @param peerId Id of peer
|
||||
* @param grpId id of group to request messages for
|
||||
*/
|
||||
void requestMessagesOfPeer(const std::string& peerId, const std::string& grpId){ return; }
|
||||
void requestMessagesOfPeer(const RsPeerId& peerId, const std::string& grpId){ return; }
|
||||
|
||||
/*!
|
||||
* pauses synchronisation of subscribed groups and request for group id
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
* @param enabled set to false to disable pause, and true otherwise
|
||||
* @return request token to be redeemed
|
||||
*/
|
||||
int requestGrp(const std::list<RsGxsGroupId>& grpId, const std::string& peerId);
|
||||
int requestGrp(const std::list<RsGxsGroupId>& grpId, const RsPeerId& peerId);
|
||||
|
||||
/* p3Config methods */
|
||||
|
||||
|
@ -302,26 +302,26 @@ private:
|
|||
* @param toVet groupid/peer to vet are stored here if their circle id is not cached
|
||||
* @return false, if you cannot send to this peer, true otherwise
|
||||
*/
|
||||
bool canSendGrpId(const std::string& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet);
|
||||
bool canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet);
|
||||
|
||||
|
||||
bool canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const std::string& sslId);
|
||||
bool canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMetas, const RsGxsGrpMetaData&, const RsPeerId& sslId);
|
||||
|
||||
void locked_createTransactionFromPending(MsgRespPending* grpPend);
|
||||
void locked_createTransactionFromPending(GrpRespPending* msgPend);
|
||||
void locked_createTransactionFromPending(GrpCircleIdRequestVetting* grpPend);
|
||||
void locked_createTransactionFromPending(MsgCircleIdsRequestVetting* grpPend);
|
||||
|
||||
void locked_pushMsgTransactionFromList(std::list<RsNxsItem*>& reqList, const std::string& peerId, const uint32_t& transN);
|
||||
void locked_pushGrpTransactionFromList(std::list<RsNxsItem*>& reqList, const std::string& peerId, const uint32_t& transN);
|
||||
void locked_pushGrpRespFromList(std::list<RsNxsItem*>& respList, const std::string& peer, const uint32_t& transN);
|
||||
void locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const std::string& sslId, const uint32_t& transN);
|
||||
void locked_pushMsgTransactionFromList(std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN);
|
||||
void locked_pushGrpTransactionFromList(std::list<RsNxsItem*>& reqList, const RsPeerId& peerId, const uint32_t& transN);
|
||||
void locked_pushGrpRespFromList(std::list<RsNxsItem*>& respList, const RsPeerId& peer, const uint32_t& transN);
|
||||
void locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, const RsPeerId& sslId, const uint32_t& transN);
|
||||
void syncWithPeers();
|
||||
void addGroupItemToList(NxsTransaction*& tr,
|
||||
const std::string& grpId, uint32_t& transN,
|
||||
std::list<RsNxsItem*>& reqList);
|
||||
|
||||
bool locked_canReceive(const RsGxsGrpMetaData * const grpMeta, const std::string& peerId);
|
||||
bool locked_canReceive(const RsGxsGrpMetaData * const grpMeta, const RsPeerId& peerId);
|
||||
|
||||
void processExplicitGroupRequests();
|
||||
|
||||
|
@ -415,7 +415,7 @@ private:
|
|||
uint32_t mTransactionTimeOut;
|
||||
|
||||
|
||||
std::string mOwnId;
|
||||
RsPeerId mOwnId;
|
||||
|
||||
RsNxsNetMgr* mNetMgr;
|
||||
|
||||
|
@ -434,7 +434,7 @@ private:
|
|||
std::vector<AuthorPending*> mPendingResp;
|
||||
std::vector<GrpCircleVetting*> mPendingCircleVets;
|
||||
|
||||
std::map<std::string, std::list<RsGxsGroupId> > mExplicitRequest;
|
||||
std::map<RsPeerId, std::list<RsGxsGroupId> > mExplicitRequest;
|
||||
|
||||
// nxs sync optimisation
|
||||
// can pull dynamically the latest timestamp for each message
|
||||
|
|
|
@ -1545,10 +1545,10 @@ bool PGPHandler::getGPGFilteredList(std::list<PGPIdType>& list,bool (*filter)(co
|
|||
return true ;
|
||||
}
|
||||
|
||||
//bool PGPHandler::isGPGId(const std::string &id)
|
||||
//{
|
||||
// return _public_keyring_map.find(id) != _public_keyring_map.end() ;
|
||||
//}
|
||||
bool PGPHandler::isGPGId(const PGPIdType &id)
|
||||
{
|
||||
return _public_keyring_map.find(id) != _public_keyring_map.end() ;
|
||||
}
|
||||
|
||||
bool PGPHandler::isGPGSigned(const PGPIdType &id)
|
||||
{
|
||||
|
|
|
@ -122,7 +122,7 @@ class PGPHandler
|
|||
|
||||
const PGPCertificateInfo *getCertificateInfo(const PGPIdType& id) const ;
|
||||
|
||||
bool isGPGId(const std::string &id);
|
||||
bool isGPGId(const PGPIdType &id);
|
||||
bool isGPGSigned(const PGPIdType &id);
|
||||
bool isGPGAccepted(const PGPIdType &id);
|
||||
|
||||
|
|
|
@ -139,18 +139,18 @@ AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& pa
|
|||
*
|
||||
* returns false if GnuPG is not available.
|
||||
*/
|
||||
bool AuthGPG::availableGPGCertificatesWithPrivateKeys(std::list<std::string> &ids)
|
||||
{
|
||||
std::list<PGPIdType> pids ;
|
||||
|
||||
PGPHandler::availableGPGCertificatesWithPrivateKeys(pids) ;
|
||||
|
||||
for(std::list<PGPIdType>::const_iterator it(pids.begin());it!=pids.end();++it)
|
||||
ids.push_back( (*it).toStdString() ) ;
|
||||
|
||||
/* return false if there are no private keys */
|
||||
return !ids.empty();
|
||||
}
|
||||
//bool AuthGPG::availableGPGCertificatesWithPrivateKeys(std::list<std::string> &ids)
|
||||
//{
|
||||
// std::list<PGPIdType> pids ;
|
||||
//
|
||||
// PGPHandler::availableGPGCertificatesWithPrivateKeys(pids) ;
|
||||
//
|
||||
// for(std::list<PGPIdType>::const_iterator it(pids.begin());it!=pids.end();++it)
|
||||
// ids.push_back( (*it).toStdString() ) ;
|
||||
//
|
||||
// /* return false if there are no private keys */
|
||||
// return !ids.empty();
|
||||
//}
|
||||
|
||||
/* You can initialise Retroshare with
|
||||
* (a) load existing certificate.
|
||||
|
@ -265,7 +265,7 @@ void AuthGPG::processServices()
|
|||
std::string error_string ;
|
||||
PGPIdType pgp_id ;
|
||||
LoadCertificateFromString(loadOrSave->m_certGpg, pgp_id,error_string);
|
||||
loadOrSave->m_certGpgId = pgp_id.toStdString() ;
|
||||
loadOrSave->m_certGpgId = pgp_id;
|
||||
}
|
||||
|
||||
|
||||
|
@ -648,9 +648,10 @@ int AuthGPG::privateSignCertificate(const PGPIdType &id)
|
|||
}
|
||||
|
||||
/* revoke the signature on Certificate */
|
||||
int AuthGPG::privateRevokeCertificate(const std::string &/*id*/)
|
||||
int AuthGPG::privateRevokeCertificate(const PGPIdType &/*id*/)
|
||||
{
|
||||
//RsStackMutex stack(gpgMtx); /******* LOCKED ******/
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -687,7 +688,7 @@ bool AuthGPG::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
|||
#ifdef GPG_DEBUG
|
||||
std::cerr << "AuthGPG::saveList() called" << std::endl ;
|
||||
#endif
|
||||
std::list<std::string> ids ;
|
||||
std::list<PGPIdType> ids ;
|
||||
getGPGAcceptedList(ids) ; // needs to be done before the lock
|
||||
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
|
@ -697,11 +698,11 @@ bool AuthGPG::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
|||
// Now save config for network digging strategies
|
||||
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
||||
|
||||
for (std::list<std::string>::const_iterator it(ids.begin()); it != ids.end(); ++it)
|
||||
if((*it) != mOwnGpgId.toStdString()) // skip our own id.
|
||||
for (std::list<PGPIdType>::const_iterator it(ids.begin()); it != ids.end(); ++it)
|
||||
if((*it) != mOwnGpgId) // skip our own id.
|
||||
{
|
||||
RsTlvKeyValue kv;
|
||||
kv.key = *it ;
|
||||
kv.key = (*it).toStdString() ;
|
||||
#ifdef GPG_DEBUG
|
||||
std::cerr << "AuthGPG::saveList() called (it->second) : " << (it->second) << std::endl ;
|
||||
#endif
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
class AuthGPGOperationLoadOrSave : public AuthGPGOperation
|
||||
{
|
||||
public:
|
||||
AuthGPGOperationLoadOrSave(bool load, const PGPIdType &gpgId, const PGPIdType &gpgCert, void *userdata)
|
||||
AuthGPGOperationLoadOrSave(bool load, const PGPIdType &gpgId, const std::string &gpgCert, void *userdata)
|
||||
: AuthGPGOperation(userdata)
|
||||
{
|
||||
m_load = load;
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
public:
|
||||
bool m_load;
|
||||
PGPIdType m_certGpgId; // set for save & load.
|
||||
PGPIdType m_certGpg; // set for load
|
||||
std::string m_certGpg; // set for load
|
||||
};
|
||||
|
||||
class AuthGPGService
|
||||
|
@ -111,7 +111,7 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
|||
/**
|
||||
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
||||
*/
|
||||
virtual bool availableGPGCertificatesWithPrivateKeys(std::list<PGPIdType> &ids);
|
||||
//virtual bool availableGPGCertificatesWithPrivateKeys(std::list<PGPIdType> &ids);
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 1 ***********************************************/
|
||||
|
@ -176,10 +176,10 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
|||
*
|
||||
****/
|
||||
virtual bool LoadCertificateFromString(const std::string &pem, PGPIdType& gpg_id,std::string& error_string);
|
||||
virtual std::string SaveCertificateToString(const RsPeerId &id,bool include_signatures) ;
|
||||
virtual std::string SaveCertificateToString(const PGPIdType &id,bool include_signatures) ;
|
||||
|
||||
// Cached certificates.
|
||||
bool getCachedGPGCertificate(const std::string &id, std::string &certificate);
|
||||
bool getCachedGPGCertificate(const PGPIdType &id, std::string &certificate);
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 6 ***********************************************/
|
||||
|
|
|
@ -477,8 +477,8 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||
p3Notify *notify = RsServer::notify();
|
||||
if (notify)
|
||||
{
|
||||
notify->AddPopupMessage(RS_POPUP_CONNECT, peer.id,"", "Online: ");
|
||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_CONNECT, peer.id, "", "");
|
||||
notify->AddPopupMessage(RS_POPUP_CONNECT, peer.id.toStdString(),"", "Online: ");
|
||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_CONNECT, peer.id.toStdString(), "", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -576,9 +576,9 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||
}
|
||||
|
||||
|
||||
const RsPeerId p3LinkMgrIMPL::getOwnId()
|
||||
const RsPeerId& p3LinkMgrIMPL::getOwnId()
|
||||
{
|
||||
return AuthSSL::getAuthSSL()->OwnId();
|
||||
return AuthSSL::getAuthSSL()->OwnId();
|
||||
}
|
||||
|
||||
|
||||
|
@ -623,7 +623,7 @@ bool p3LinkMgrIMPL::connectAttempt(const RsPeerId &id, struct sockaddr_storage &
|
|||
|
||||
}
|
||||
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectAttempt() called id: " + id);
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgrIMPL::connectAttempt() called id: " + id.toStdString());
|
||||
|
||||
it->second.lastattempt = time(NULL);
|
||||
it->second.inConnAttempt = true;
|
||||
|
@ -786,7 +786,7 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, uint32_t fla
|
|||
|
||||
if (id == getOwnId())
|
||||
{
|
||||
rslog(RSL_ALERT, p3connectzone, "p3LinkMgrIMPL::connectResult() ERROR Trying to Connect to OwnId: " + id);
|
||||
rslog(RSL_ALERT, p3connectzone, "p3LinkMgrIMPL::connectResult() ERROR Trying to Connect to OwnId: " + id.toStdString());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -795,7 +795,7 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, uint32_t fla
|
|||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
rslog(RSL_ALERT, p3connectzone, "p3LinkMgrIMPL::connectResult() ERROR Missing Friend: " + id);
|
||||
rslog(RSL_ALERT, p3connectzone, "p3LinkMgrIMPL::connectResult() ERROR Missing Friend: " + id.toStdString());
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() ERROR, missing Friend " << " id: " << id << std::endl;
|
||||
|
@ -1098,7 +1098,7 @@ void p3LinkMgrIMPL::peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
|||
|
||||
{
|
||||
/* Log */
|
||||
std::string out = "p3LinkMgrIMPL::peerStatus() id: " + id;
|
||||
std::string out = "p3LinkMgrIMPL::peerStatus() id: " + id.toStdString();
|
||||
rs_sprintf_append(out, " type: %lu flags: %lu source: %lu\n", type, flags, source);
|
||||
addrs.printAddrs(out);
|
||||
|
||||
|
@ -1360,7 +1360,7 @@ void p3LinkMgrIMPL::peerConnectRequest(const RsPeerId& id, const struct socka
|
|||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::string out = "p3LinkMgrIMPL::peerConnectRequest() id: " + id;
|
||||
std::string out = "p3LinkMgrIMPL::peerConnectRequest() id: " + id.toStdString();
|
||||
out += " raddr: ";
|
||||
out += sockaddr_storage_tostring(raddr);
|
||||
out += " proxyaddr: ";
|
||||
|
@ -2127,7 +2127,7 @@ bool p3LinkMgrIMPL::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
|||
|
||||
int p3LinkMgrIMPL::addFriend(const RsPeerId &id, bool isVisible)
|
||||
{
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::addFriend() id: " + id);
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::addFriend() id: " + id.toStdString());
|
||||
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -2168,7 +2168,7 @@ int p3LinkMgrIMPL::addFriend(const RsPeerId &id, bool isVisible)
|
|||
|
||||
int p3LinkMgrIMPL::removeFriend(const RsPeerId &id)
|
||||
{
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::removeFriend() id: " + id);
|
||||
rslog(RSL_WARNING, p3connectzone, "p3LinkMgr::removeFriend() id: " + id.toStdString());
|
||||
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
|
|
@ -110,7 +110,7 @@ std::string textPeerConnectState(peerState &state)
|
|||
}
|
||||
|
||||
|
||||
p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const PGPIdType& gpg_own_id, const PGPIdType& gpg_own_name, const RsPeerId& ssl_own_location)
|
||||
p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const PGPIdType& gpg_own_id, const std::string& gpg_own_name, const std::string& ssl_own_location)
|
||||
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
|
||||
{
|
||||
|
||||
|
@ -756,7 +756,7 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
|||
std::cerr << "p3PeerMgrIMPL::removeFriend() mFriendList.size() : " << mFriendList.size() << std::endl;
|
||||
#endif
|
||||
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id);
|
||||
rslog(RSL_WARNING, p3peermgrzone, "p3PeerMgr::removeFriend() id: " + id.toStdString());
|
||||
|
||||
std::list<RsPeerId> sslid_toRemove; // This is a list of SSLIds.
|
||||
std::list<PGPIdType> pgpid_toRemove; // This is a list of SSLIds.
|
||||
|
@ -770,7 +770,8 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
|||
//remove ssl and gpg_ids
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); it++)
|
||||
{
|
||||
if (it->second.id == id || it->second.gpg_id == id) {
|
||||
if (it->second.id == id)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::removeFriend() friend found in the list." << id << std::endl;
|
||||
#endif
|
||||
|
@ -787,14 +788,13 @@ bool p3PeerMgrIMPL::removeFriend(const RsPeerId &id, bool removePgpId)
|
|||
}
|
||||
}
|
||||
|
||||
std::list<RsPeerId>::iterator rit;
|
||||
for(rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); rit++)
|
||||
for(std::list<RsPeerId>::iterator rit = sslid_toRemove.begin(); rit != sslid_toRemove.end(); rit++)
|
||||
if (mFriendList.end() != (it = mFriendList.find(*rit)))
|
||||
mFriendList.erase(it);
|
||||
|
||||
std::map<PGPIdType,ServicePermissionFlags>::iterator it2 ;
|
||||
|
||||
for(rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); rit++)
|
||||
for(std::list<PGPIdType>::iterator rit = pgpid_toRemove.begin(); rit != pgpid_toRemove.end(); rit++)
|
||||
if (mFriendsPermissionFlags.end() != (it2 = mFriendsPermissionFlags.find(*rit)))
|
||||
mFriendsPermissionFlags.erase(it2);
|
||||
|
||||
|
@ -1290,7 +1290,7 @@ bool p3PeerMgrIMPL::setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_
|
|||
{
|
||||
{
|
||||
std::string out;
|
||||
rs_sprintf(out, "p3PeerMgr::setVisState(%s, %u, %u)", id.c_str(), vs_disc, vs_dht);
|
||||
rs_sprintf(out, "p3PeerMgr::setVisState(%s, %u, %u)", id.toStdString().c_str(), vs_disc, vs_dht);
|
||||
rslog(RSL_WARNING, p3peermgrzone, out);
|
||||
}
|
||||
|
||||
|
@ -1408,9 +1408,9 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
RsPeerNetItem *item = new RsPeerNetItem();
|
||||
item->clear();
|
||||
|
||||
item->pid = getOwnId();
|
||||
item->gpg_id = mOwnState.gpg_id;
|
||||
item->location = mOwnState.location;
|
||||
item->pid = getOwnId().toStdString();
|
||||
item->gpg_id = mOwnState.gpg_id.toStdString();
|
||||
item->location = mOwnState.location;
|
||||
#if 0
|
||||
if (mOwnState.netMode & RS_NET_MODE_TRY_EXT)
|
||||
{
|
||||
|
@ -1459,8 +1459,8 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
item = new RsPeerNetItem();
|
||||
item->clear();
|
||||
|
||||
item->pid = it->first;
|
||||
item->gpg_id = (it->second).gpg_id;
|
||||
item->pid = it->first.toStdString();
|
||||
item->gpg_id = (it->second).gpg_id.toStdString();
|
||||
item->location = (it->second).location;
|
||||
item->netMode = (it->second).netMode;
|
||||
item->vs_disc = (it->second).vs_disc;
|
||||
|
@ -1576,7 +1576,10 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
RsPeerNetItem *pitem = dynamic_cast<RsPeerNetItem *>(*it);
|
||||
if (pitem)
|
||||
{
|
||||
if (pitem->pid == ownId)
|
||||
RsPeerId peer_id(pitem->pid) ;
|
||||
PGPIdType peer_pgp_id(pitem->gpg_id) ;
|
||||
|
||||
if (peer_id == ownId)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Own Config Item:" << std::endl;
|
||||
|
@ -1598,29 +1601,29 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* ************* */
|
||||
addFriend(pitem->pid, pitem->gpg_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_SERVICE_PERM_ALL);
|
||||
setLocation(pitem->pid, pitem->location);
|
||||
addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_SERVICE_PERM_ALL);
|
||||
setLocation(RsPeerId(pitem->pid), pitem->location);
|
||||
}
|
||||
|
||||
if (pitem->netMode == RS_NET_MODE_HIDDEN)
|
||||
{
|
||||
/* set only the hidden stuff & localAddress */
|
||||
setLocalAddress(pitem->pid, pitem->localAddrV4.addr);
|
||||
setHiddenDomainPort(pitem->pid, pitem->domain_addr, pitem->domain_port);
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setHiddenDomainPort(peer_id, pitem->domain_addr, pitem->domain_port);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setLocalAddress(pitem->pid, pitem->localAddrV4.addr);
|
||||
setExtAddress(pitem->pid, pitem->extAddrV4.addr);
|
||||
setDynDNS (pitem->pid, pitem->dyndns);
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setExtAddress(peer_id, pitem->extAddrV4.addr);
|
||||
setDynDNS (peer_id, pitem->dyndns);
|
||||
|
||||
/* convert addresses */
|
||||
pqiIpAddrSet addrs;
|
||||
addrs.mLocal.extractFromTlv(pitem->localAddrList);
|
||||
addrs.mExt.extractFromTlv(pitem->extAddrList);
|
||||
|
||||
updateAddressList(pitem->pid, addrs);
|
||||
updateAddressList(peer_id, addrs);
|
||||
}
|
||||
|
||||
delete(*it);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
class pqiloopback: public PQInterface
|
||||
{
|
||||
public:
|
||||
pqiloopback(std::string id);
|
||||
pqiloopback(const RsPeerId& id);
|
||||
virtual ~pqiloopback();
|
||||
|
||||
// search Interface.
|
||||
|
|
|
@ -44,7 +44,7 @@ pqiConnectCbDummy::~pqiConnectCbDummy()
|
|||
return;
|
||||
}
|
||||
|
||||
void pqiConnectCbDummy::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
void pqiConnectCbDummy::peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t mode, uint32_t source)
|
||||
{
|
||||
std::cerr << "pqiConnectCbDummy::peerStatus()";
|
||||
|
@ -61,7 +61,7 @@ void pqiConnectCbDummy::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
|||
std::cerr << out << std::endl;
|
||||
}
|
||||
|
||||
void pqiConnectCbDummy::peerConnectRequest(std::string id,
|
||||
void pqiConnectCbDummy::peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source)
|
||||
{
|
||||
std::cerr << "pqiConnectCbDummy::peerConnectRequest()";
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <string>
|
||||
#include <list>
|
||||
#include "pqi/pqiipset.h"
|
||||
#include "retroshare/rsids.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
/************** Define Type/Mode/Source ***************/
|
||||
|
||||
|
@ -154,10 +154,10 @@ class pqiConnectCb
|
|||
{
|
||||
public:
|
||||
virtual ~pqiConnectCb() { return; }
|
||||
virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
virtual void peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t flags, uint32_t source) = 0;
|
||||
|
||||
virtual void peerConnectRequest(std::string id, const struct sockaddr_storage &raddr,
|
||||
virtual void peerConnectRequest(const RsPeerId& id, const struct sockaddr_storage &raddr,
|
||||
const struct sockaddr_storage &proxyaddr, const struct sockaddr_storage &srcaddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth) = 0;
|
||||
|
||||
|
@ -171,10 +171,10 @@ class pqiConnectCbDummy: public pqiConnectCb
|
|||
public:
|
||||
pqiConnectCbDummy();
|
||||
virtual ~pqiConnectCbDummy();
|
||||
virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
virtual void peerStatus(const RsPeerId& id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t mode, uint32_t source);
|
||||
|
||||
virtual void peerConnectRequest(std::string id,
|
||||
virtual void peerConnectRequest(const RsPeerId& id,
|
||||
const struct sockaddr_storage &raddr, uint32_t source);
|
||||
|
||||
//virtual void stunStatus(std::string id, const struct sockaddr_storage &raddr, uint32_t type, uint32_t flags);
|
||||
|
|
|
@ -110,7 +110,7 @@ class RsDhtNetPeer
|
|||
RsDhtNetPeer();
|
||||
|
||||
std::string mDhtId;
|
||||
std::string mRsId;
|
||||
RsPeerId mRsId;
|
||||
|
||||
uint32_t mPeerType;
|
||||
uint32_t mDhtState;
|
||||
|
|
|
@ -151,7 +151,10 @@ template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType
|
|||
|
||||
template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const unsigned char *mem)
|
||||
{
|
||||
memcpy(bytes,mem,ID_SIZE_IN_BYTES) ;
|
||||
if(mem == NULL)
|
||||
memset(bytes,0,ID_SIZE_IN_BYTES) ;
|
||||
else
|
||||
memcpy(bytes,mem,ID_SIZE_IN_BYTES) ;
|
||||
}
|
||||
|
||||
static const int SSL_ID_SIZE = 16 ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue