mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 09:05:34 -05:00
removed unused code from p3gossipdiscovery
This commit is contained in:
parent
a20ec1a885
commit
bea6769a4e
@ -36,15 +36,11 @@ RsItem *RsDiscSerialiser::create_item(
|
|||||||
switch(static_cast<RsGossipDiscoveryItemType>(item_subtype))
|
switch(static_cast<RsGossipDiscoveryItemType>(item_subtype))
|
||||||
{
|
{
|
||||||
case RsGossipDiscoveryItemType::PGP_LIST: return new RsDiscPgpListItem();
|
case RsGossipDiscoveryItemType::PGP_LIST: return new RsDiscPgpListItem();
|
||||||
// case RsGossipDiscoveryItemType::PGP_CERT: return new RsDiscPgpCertItem();
|
|
||||||
case RsGossipDiscoveryItemType::PGP_CERT_BINARY: return new RsDiscPgpKeyItem();
|
case RsGossipDiscoveryItemType::PGP_CERT_BINARY: return new RsDiscPgpKeyItem();
|
||||||
case RsGossipDiscoveryItemType::CONTACT: return new RsDiscContactItem();
|
case RsGossipDiscoveryItemType::CONTACT: return new RsDiscContactItem();
|
||||||
case RsGossipDiscoveryItemType::IDENTITY_LIST:
|
case RsGossipDiscoveryItemType::IDENTITY_LIST: return new RsDiscIdentityListItem();
|
||||||
return new RsDiscIdentityListItem();
|
default:
|
||||||
case RsGossipDiscoveryItemType::INVITE:
|
return NULL;
|
||||||
return new RsGossipDiscoveryInviteItem();
|
|
||||||
case RsGossipDiscoveryItemType::INVITE_REQUEST:
|
|
||||||
return new RsGossipDiscoveryInviteRequestItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -66,19 +62,6 @@ void RsDiscPgpListItem::serial_process(
|
|||||||
RS_SERIAL_PROCESS(pgpIdSet);
|
RS_SERIAL_PROCESS(pgpIdSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsDiscPgpCertItem::clear()
|
|
||||||
{
|
|
||||||
pgpId.clear();
|
|
||||||
pgpCert.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void RsDiscPgpCertItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
|
||||||
{
|
|
||||||
RsTypeSerializer::serial_process(j,ctx,pgpId,"pgpId") ;
|
|
||||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PGPCERT,pgpCert,"pgpCert") ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RsDiscPgpKeyItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
void RsDiscPgpKeyItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||||
{
|
{
|
||||||
RsTypeSerializer::serial_process(j,ctx,pgpKeyId,"pgpKeyId") ;
|
RsTypeSerializer::serial_process(j,ctx,pgpKeyId,"pgpKeyId") ;
|
||||||
@ -159,17 +142,9 @@ void RsDiscIdentityListItem::serial_process(RsGenericSerializer::SerializeJob j,
|
|||||||
RS_SERIAL_PROCESS(ownIdentityList);
|
RS_SERIAL_PROCESS(ownIdentityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsDiscItem::RsDiscItem(RsGossipDiscoveryItemType subtype)
|
||||||
RsGossipDiscoveryInviteItem::RsGossipDiscoveryInviteItem() :
|
: RsItem( RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DISC, static_cast<uint8_t>(subtype) )
|
||||||
RsDiscItem(RsGossipDiscoveryItemType::INVITE)
|
{
|
||||||
{ setPriorityLevel(QOS_PRIORITY_RS_DISC_ASK_INFO); }
|
}
|
||||||
|
|
||||||
RsGossipDiscoveryInviteRequestItem::RsGossipDiscoveryInviteRequestItem() :
|
|
||||||
RsDiscItem(RsGossipDiscoveryItemType::INVITE_REQUEST)
|
|
||||||
{ setPriorityLevel(QOS_PRIORITY_RS_DISC_REPLY); }
|
|
||||||
|
|
||||||
RsDiscItem::RsDiscItem(RsGossipDiscoveryItemType subtype) :
|
|
||||||
RsItem( RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DISC,
|
|
||||||
static_cast<uint8_t>(subtype) ) {}
|
|
||||||
|
|
||||||
RsDiscItem::~RsDiscItem() {}
|
RsDiscItem::~RsDiscItem() {}
|
||||||
|
@ -38,8 +38,8 @@ enum class RsGossipDiscoveryItemType : uint8_t
|
|||||||
PGP_CERT = 0x2, // deprecated
|
PGP_CERT = 0x2, // deprecated
|
||||||
CONTACT = 0x5,
|
CONTACT = 0x5,
|
||||||
IDENTITY_LIST = 0x6,
|
IDENTITY_LIST = 0x6,
|
||||||
INVITE = 0x7,
|
INVITE = 0x7, // deprecated
|
||||||
INVITE_REQUEST = 0x8,
|
INVITE_REQUEST = 0x8, // deprecated
|
||||||
PGP_CERT_BINARY = 0x9,
|
PGP_CERT_BINARY = 0x9,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,22 +82,6 @@ public:
|
|||||||
RsTlvPgpIdSet pgpIdSet;
|
RsTlvPgpIdSet pgpIdSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsDiscPgpCertItem: public RsDiscItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
RsDiscPgpCertItem() : RsDiscItem(RsGossipDiscoveryItemType::PGP_CERT)
|
|
||||||
{ setPriorityLevel(QOS_PRIORITY_RS_DISC_PGP_CERT); }
|
|
||||||
|
|
||||||
void clear() override;
|
|
||||||
void serial_process(
|
|
||||||
RsGenericSerializer::SerializeJob j,
|
|
||||||
RsGenericSerializer::SerializeContext& ctx) override;
|
|
||||||
|
|
||||||
RsPgpId pgpId;
|
|
||||||
std::string pgpCert;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RsDiscPgpKeyItem: public RsDiscItem
|
class RsDiscPgpKeyItem: public RsDiscItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -174,30 +158,6 @@ public:
|
|||||||
std::list<RsGxsId> ownIdentityList;
|
std::list<RsGxsId> ownIdentityList;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RsGossipDiscoveryInviteItem : RsDiscItem
|
|
||||||
{
|
|
||||||
RsGossipDiscoveryInviteItem();
|
|
||||||
|
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
|
||||||
RsGenericSerializer::SerializeContext& ctx ) override
|
|
||||||
{ RS_SERIAL_PROCESS(mInvite); }
|
|
||||||
void clear() override { mInvite.clear(); }
|
|
||||||
|
|
||||||
std::string mInvite;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RsGossipDiscoveryInviteRequestItem : RsDiscItem
|
|
||||||
{
|
|
||||||
RsGossipDiscoveryInviteRequestItem();
|
|
||||||
|
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
|
||||||
RsGenericSerializer::SerializeContext& ctx ) override
|
|
||||||
{ RS_SERIAL_PROCESS(mInviteId); }
|
|
||||||
void clear() override { mInviteId.clear(); }
|
|
||||||
|
|
||||||
RsPeerId mInviteId;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RsDiscSerialiser: public RsServiceSerializer
|
class RsDiscSerialiser: public RsServiceSerializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -36,9 +36,6 @@
|
|||||||
|
|
||||||
/*extern*/ std::shared_ptr<RsGossipDiscovery> rsGossipDiscovery(nullptr);
|
/*extern*/ std::shared_ptr<RsGossipDiscovery> rsGossipDiscovery(nullptr);
|
||||||
|
|
||||||
RsGossipDiscovery::~RsGossipDiscovery() {};
|
|
||||||
|
|
||||||
|
|
||||||
static bool populateContactInfo( const peerState &detail,
|
static bool populateContactInfo( const peerState &detail,
|
||||||
RsDiscContactItem *pkt,
|
RsDiscContactItem *pkt,
|
||||||
bool include_ip_information )
|
bool include_ip_information )
|
||||||
@ -88,9 +85,9 @@ static bool populateContactInfo( const peerState &detail,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiscPgpInfo::mergeFriendList(const std::set<PGPID> &friends)
|
void DiscPgpInfo::mergeFriendList(const std::set<RsPgpId> &friends)
|
||||||
{
|
{
|
||||||
std::set<PGPID>::const_iterator it;
|
std::set<RsPgpId>::const_iterator it;
|
||||||
for(it = friends.begin(); it != friends.end(); ++it)
|
for(it = friends.begin(); it != friends.end(); ++it)
|
||||||
{
|
{
|
||||||
mFriendSet.insert(*it);
|
mFriendSet.insert(*it);
|
||||||
@ -141,13 +138,13 @@ RsServiceInfo p3discovery2::getServiceInfo()
|
|||||||
p3discovery2::~p3discovery2()
|
p3discovery2::~p3discovery2()
|
||||||
{ rsEvents->unregisterEventsHandler(mRsEventsHandle); }
|
{ rsEvents->unregisterEventsHandler(mRsEventsHandle); }
|
||||||
|
|
||||||
void p3discovery2::addFriend(const SSLID &sslId)
|
void p3discovery2::addFriend(const RsPeerId &sslId)
|
||||||
{
|
{
|
||||||
PGPID pgpId = getPGPId(sslId);
|
RsPgpId pgpId = getPGPId(sslId);
|
||||||
|
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::iterator it;
|
||||||
it = mFriendList.find(pgpId);
|
it = mFriendList.find(pgpId);
|
||||||
if (it == mFriendList.end())
|
if (it == mFriendList.end())
|
||||||
{
|
{
|
||||||
@ -162,9 +159,9 @@ void p3discovery2::addFriend(const SSLID &sslId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* now add SSLID */
|
/* now add RsPeerId */
|
||||||
|
|
||||||
std::map<SSLID, DiscSslInfo>::iterator sit;
|
std::map<RsPeerId, DiscSslInfo>::iterator sit;
|
||||||
sit = it->second.mSslIds.find(sslId);
|
sit = it->second.mSslIds.find(sslId);
|
||||||
if (sit == it->second.mSslIds.end())
|
if (sit == it->second.mSslIds.end())
|
||||||
{
|
{
|
||||||
@ -189,13 +186,13 @@ void p3discovery2::addFriend(const SSLID &sslId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::removeFriend(const SSLID &sslId)
|
void p3discovery2::removeFriend(const RsPeerId &sslId)
|
||||||
{
|
{
|
||||||
PGPID pgpId = getPGPId(sslId);
|
RsPgpId pgpId = getPGPId(sslId);
|
||||||
|
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::iterator it;
|
||||||
it = mFriendList.find(pgpId);
|
it = mFriendList.find(pgpId);
|
||||||
if (it == mFriendList.end())
|
if (it == mFriendList.end())
|
||||||
{
|
{
|
||||||
@ -206,7 +203,7 @@ void p3discovery2::removeFriend(const SSLID &sslId)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<SSLID, DiscSslInfo>::iterator sit;
|
std::map<RsPeerId, DiscSslInfo>::iterator sit;
|
||||||
sit = it->second.mSslIds.find(sslId);
|
sit = it->second.mSslIds.find(sslId);
|
||||||
if (sit == it->second.mSslIds.end())
|
if (sit == it->second.mSslIds.end())
|
||||||
{
|
{
|
||||||
@ -241,9 +238,9 @@ void p3discovery2::removeFriend(const SSLID &sslId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPID p3discovery2::getPGPId(const SSLID &id)
|
RsPgpId p3discovery2::getPGPId(const RsPeerId &id)
|
||||||
{
|
{
|
||||||
PGPID pgpId;
|
RsPgpId pgpId;
|
||||||
mPeerMgr->getGpgId(id, pgpId);
|
mPeerMgr->getGpgId(id, pgpId);
|
||||||
return pgpId;
|
return pgpId;
|
||||||
}
|
}
|
||||||
@ -262,12 +259,9 @@ int p3discovery2::handleIncoming()
|
|||||||
while(nullptr != (item = recvItem()))
|
while(nullptr != (item = recvItem()))
|
||||||
{
|
{
|
||||||
RsDiscPgpListItem* pgplist = nullptr;
|
RsDiscPgpListItem* pgplist = nullptr;
|
||||||
RsDiscPgpCertItem* pgpcert = nullptr; // deprecated
|
|
||||||
RsDiscPgpKeyItem* pgpkey = nullptr;
|
RsDiscPgpKeyItem* pgpkey = nullptr;
|
||||||
RsDiscContactItem* contact = nullptr;
|
RsDiscContactItem* contact = nullptr;
|
||||||
RsDiscIdentityListItem* gxsidlst = nullptr;
|
RsDiscIdentityListItem* gxsidlst = nullptr;
|
||||||
// RsGossipDiscoveryInviteItem* invite = nullptr;
|
|
||||||
// RsGossipDiscoveryInviteRequestItem* inviteReq = nullptr;
|
|
||||||
|
|
||||||
++nhandled;
|
++nhandled;
|
||||||
|
|
||||||
@ -286,8 +280,6 @@ int p3discovery2::handleIncoming()
|
|||||||
recvIdentityList(item->PeerId(),gxsidlst->ownIdentityList);
|
recvIdentityList(item->PeerId(),gxsidlst->ownIdentityList);
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
// else if((pgpcert = dynamic_cast<RsDiscPgpCertItem *>(item)) != nullptr)
|
|
||||||
// recvPGPCertificate(item->PeerId(), pgpcert);
|
|
||||||
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
|
else if((pgpkey = dynamic_cast<RsDiscPgpKeyItem *>(item)) != nullptr)
|
||||||
recvPGPCertificate(item->PeerId(), pgpkey);
|
recvPGPCertificate(item->PeerId(), pgpkey);
|
||||||
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
|
else if((pgplist = dynamic_cast<RsDiscPgpListItem *>(item)) != nullptr)
|
||||||
@ -298,19 +290,10 @@ int p3discovery2::handleIncoming()
|
|||||||
recvPGPCertificateRequest(pgplist->PeerId(), pgplist);
|
recvPGPCertificateRequest(pgplist->PeerId(), pgplist);
|
||||||
else delete item;
|
else delete item;
|
||||||
}
|
}
|
||||||
// else if( (invite = dynamic_cast<RsGossipDiscoveryInviteItem*>(item)) != nullptr )
|
|
||||||
// recvInvite(std::unique_ptr<RsGossipDiscoveryInviteItem>(invite));
|
|
||||||
// else if( (inviteReq =
|
|
||||||
// dynamic_cast<RsGossipDiscoveryInviteRequestItem*>(item))
|
|
||||||
// != nullptr )
|
|
||||||
// {
|
|
||||||
// sendInvite(inviteReq->mInviteId, item->PeerId());
|
|
||||||
// delete item;
|
|
||||||
// }
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RsWarn() << __PRETTY_FUNCTION__ << " Received unknown item type! "
|
RsWarn() << __PRETTY_FUNCTION__ << " Received unknown item type " << (int)item->PacketSubType() << "! " << std::endl ;
|
||||||
<< std::endl << item << std::endl;
|
RsWarn() << item << std::endl;
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,7 +301,7 @@ int p3discovery2::handleIncoming()
|
|||||||
return nhandled;
|
return nhandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::sendOwnContactInfo(const SSLID &sslid)
|
void p3discovery2::sendOwnContactInfo(const RsPeerId &sslid)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
@ -366,7 +349,7 @@ void p3discovery2::sendOwnContactInfo(const SSLID &sslid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::recvOwnContactInfo(const SSLID &fromId, const RsDiscContactItem *item)
|
void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContactItem *item)
|
||||||
{
|
{
|
||||||
std::unique_ptr<const RsDiscContactItem> pitem(item); // ensures that item will be destroyed whichever door we leave through
|
std::unique_ptr<const RsDiscContactItem> pitem(item); // ensures that item will be destroyed whichever door we leave through
|
||||||
|
|
||||||
@ -429,11 +412,11 @@ void p3discovery2::recvOwnContactInfo(const SSLID &fromId, const RsDiscContactIt
|
|||||||
// Update mDiscStatus.
|
// Update mDiscStatus.
|
||||||
RS_STACK_MUTEX(mDiscMtx);
|
RS_STACK_MUTEX(mDiscMtx);
|
||||||
|
|
||||||
PGPID pgpId = getPGPId(fromId);
|
RsPgpId pgpId = getPGPId(fromId);
|
||||||
std::map<PGPID, DiscPgpInfo>::iterator it = mFriendList.find(pgpId);
|
std::map<RsPgpId, DiscPgpInfo>::iterator it = mFriendList.find(pgpId);
|
||||||
if (it != mFriendList.end())
|
if (it != mFriendList.end())
|
||||||
{
|
{
|
||||||
std::map<SSLID, DiscSslInfo>::iterator sit = it->second.mSslIds.find(fromId);
|
std::map<RsPeerId, DiscSslInfo>::iterator sit = it->second.mSslIds.find(fromId);
|
||||||
if (sit != it->second.mSslIds.end())
|
if (sit != it->second.mSslIds.end())
|
||||||
{
|
{
|
||||||
sit->second.mDiscStatus = item->vs_disc;
|
sit->second.mDiscStatus = item->vs_disc;
|
||||||
@ -522,7 +505,7 @@ void p3discovery2::updatePeerAddressList(const RsDiscContactItem *item)
|
|||||||
|
|
||||||
// Starts the Discovery process.
|
// Starts the Discovery process.
|
||||||
// should only be called it DISC2_STATUS_NOT_HIDDEN(OwnInfo.status).
|
// should only be called it DISC2_STATUS_NOT_HIDDEN(OwnInfo.status).
|
||||||
void p3discovery2::sendPGPList(const SSLID &toId)
|
void p3discovery2::sendPGPList(const RsPeerId &toId)
|
||||||
{
|
{
|
||||||
updatePgpFriendList();
|
updatePgpFriendList();
|
||||||
|
|
||||||
@ -537,7 +520,7 @@ void p3discovery2::sendPGPList(const SSLID &toId)
|
|||||||
|
|
||||||
pkt->mode = RsGossipDiscoveryPgpListMode::FRIENDS;
|
pkt->mode = RsGossipDiscoveryPgpListMode::FRIENDS;
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::const_iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::const_iterator it;
|
||||||
for(it = mFriendList.begin(); it != mFriendList.end(); ++it)
|
for(it = mFriendList.begin(); it != mFriendList.end(); ++it)
|
||||||
{
|
{
|
||||||
pkt->pgpIdSet.ids.insert(it->first);
|
pkt->pgpIdSet.ids.insert(it->first);
|
||||||
@ -576,14 +559,14 @@ void p3discovery2::updatePgpFriendList()
|
|||||||
|
|
||||||
mLastPgpUpdate = time(NULL);
|
mLastPgpUpdate = time(NULL);
|
||||||
|
|
||||||
std::list<PGPID> pgpList;
|
std::list<RsPgpId> pgpList;
|
||||||
std::set<PGPID> pgpSet;
|
std::set<RsPgpId> pgpSet;
|
||||||
|
|
||||||
std::set<PGPID>::iterator sit;
|
std::set<RsPgpId>::iterator sit;
|
||||||
std::list<PGPID>::iterator lit;
|
std::list<RsPgpId>::iterator lit;
|
||||||
std::map<PGPID, DiscPgpInfo>::iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::iterator it;
|
||||||
|
|
||||||
PGPID ownPgpId = AuthGPG::getAuthGPG()->getGPGOwnId();
|
RsPgpId ownPgpId = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||||
AuthGPG::getAuthGPG()->getGPGAcceptedList(pgpList);
|
AuthGPG::getAuthGPG()->getGPGAcceptedList(pgpList);
|
||||||
pgpList.push_back(ownPgpId);
|
pgpList.push_back(ownPgpId);
|
||||||
|
|
||||||
@ -593,8 +576,8 @@ void p3discovery2::updatePgpFriendList()
|
|||||||
pgpSet.insert(*lit);
|
pgpSet.insert(*lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<PGPID> pgpToAdd;
|
std::list<RsPgpId> pgpToAdd;
|
||||||
std::list<PGPID> pgpToRemove;
|
std::list<RsPgpId> pgpToRemove;
|
||||||
|
|
||||||
|
|
||||||
sit = pgpSet.begin();
|
sit = pgpSet.begin();
|
||||||
@ -660,7 +643,7 @@ void p3discovery2::updatePgpFriendList()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::processPGPList(const SSLID &fromId, const RsDiscPgpListItem *item)
|
void p3discovery2::processPGPList(const RsPeerId &fromId, const RsDiscPgpListItem *item)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
@ -669,8 +652,8 @@ void p3discovery2::processPGPList(const SSLID &fromId, const RsDiscPgpListItem *
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::iterator it;
|
||||||
PGPID fromPgpId = getPGPId(fromId);
|
RsPgpId fromPgpId = getPGPId(fromId);
|
||||||
it = mFriendList.find(fromPgpId);
|
it = mFriendList.find(fromPgpId);
|
||||||
if (it == mFriendList.end())
|
if (it == mFriendList.end())
|
||||||
{
|
{
|
||||||
@ -703,7 +686,7 @@ void p3discovery2::processPGPList(const SSLID &fromId, const RsDiscPgpListItem *
|
|||||||
|
|
||||||
if (requestUnknownPgpCerts)
|
if (requestUnknownPgpCerts)
|
||||||
{
|
{
|
||||||
std::set<PGPID>::const_iterator fit;
|
std::set<RsPgpId>::const_iterator fit;
|
||||||
for(fit = item->pgpIdSet.ids.begin(); fit != item->pgpIdSet.ids.end(); ++fit)
|
for(fit = item->pgpIdSet.ids.begin(); fit != item->pgpIdSet.ids.end(); ++fit)
|
||||||
{
|
{
|
||||||
if (!AuthGPG::getAuthGPG()->isGPGId(*fit))
|
if (!AuthGPG::getAuthGPG()->isGPGId(*fit))
|
||||||
@ -730,7 +713,7 @@ void p3discovery2::processPGPList(const SSLID &fromId, const RsDiscPgpListItem *
|
|||||||
* -> Update Other Peers about B.
|
* -> Update Other Peers about B.
|
||||||
* -> Update B about Other Peers.
|
* -> Update B about Other Peers.
|
||||||
*/
|
*/
|
||||||
void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
void p3discovery2::updatePeers_locked(const RsPeerId &aboutId)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
@ -738,9 +721,9 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PGPID aboutPgpId = getPGPId(aboutId);
|
RsPgpId aboutPgpId = getPGPId(aboutId);
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::const_iterator ait;
|
std::map<RsPgpId, DiscPgpInfo>::const_iterator ait;
|
||||||
ait = mFriendList.find(aboutPgpId);
|
ait = mFriendList.find(aboutPgpId);
|
||||||
if (ait == mFriendList.end())
|
if (ait == mFriendList.end())
|
||||||
{
|
{
|
||||||
@ -752,12 +735,12 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<PGPID> mutualFriends;
|
std::set<RsPgpId> mutualFriends;
|
||||||
std::set<SSLID> onlineFriends;
|
std::set<RsPeerId> onlineFriends;
|
||||||
std::set<SSLID>::const_iterator sit;
|
std::set<RsPeerId>::const_iterator sit;
|
||||||
|
|
||||||
const std::set<PGPID> &friendSet = ait->second.mFriendSet;
|
const std::set<RsPgpId> &friendSet = ait->second.mFriendSet;
|
||||||
std::set<PGPID>::const_iterator fit;
|
std::set<RsPgpId>::const_iterator fit;
|
||||||
for(fit = friendSet.begin(); fit != friendSet.end(); ++fit)
|
for(fit = friendSet.begin(); fit != friendSet.end(); ++fit)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -766,7 +749,7 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::const_iterator ffit;
|
std::map<RsPgpId, DiscPgpInfo>::const_iterator ffit;
|
||||||
ffit = mFriendList.find(*fit);
|
ffit = mFriendList.find(*fit);
|
||||||
if (ffit == mFriendList.end())
|
if (ffit == mFriendList.end())
|
||||||
{
|
{
|
||||||
@ -775,7 +758,7 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
|||||||
std::cerr << "p3discovery2::updatePeer_locked() Ignoring not our friend";
|
std::cerr << "p3discovery2::updatePeer_locked() Ignoring not our friend";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
// Not our friend, or we have no Locations (SSL) for this PGPID (same difference)
|
// Not our friend, or we have no Locations (SSL) for this RsPgpId (same difference)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,16 +771,16 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
|||||||
#endif
|
#endif
|
||||||
mutualFriends.insert(*fit);
|
mutualFriends.insert(*fit);
|
||||||
|
|
||||||
std::map<SSLID, DiscSslInfo>::const_iterator mit;
|
std::map<RsPeerId, DiscSslInfo>::const_iterator mit;
|
||||||
for(mit = ffit->second.mSslIds.begin();
|
for(mit = ffit->second.mSslIds.begin();
|
||||||
mit != ffit->second.mSslIds.end(); ++mit)
|
mit != ffit->second.mSslIds.end(); ++mit)
|
||||||
{
|
{
|
||||||
SSLID sslid = mit->first;
|
RsPeerId sslid = mit->first;
|
||||||
if (mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, sslid))
|
if (mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, sslid))
|
||||||
{
|
{
|
||||||
// TODO IGNORE if sslid == aboutId, or sslid == ownId.
|
// TODO IGNORE if sslid == aboutId, or sslid == ownId.
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
std::cerr << "p3discovery2::updatePeer_locked() Adding Online SSLID: " << sslid;
|
std::cerr << "p3discovery2::updatePeer_locked() Adding Online RsPeerId: " << sslid;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
onlineFriends.insert(sslid);
|
onlineFriends.insert(sslid);
|
||||||
@ -829,13 +812,13 @@ void p3discovery2::updatePeers_locked(const SSLID &aboutId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::sendContactInfo_locked(const PGPID &aboutId, const SSLID &toId)
|
void p3discovery2::sendContactInfo_locked(const RsPgpId &aboutId, const RsPeerId &toId)
|
||||||
{
|
{
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
std::cerr << "p3discovery2::sendContactInfo_locked() aboutPGPId: " << aboutId << " toId: " << toId;
|
std::cerr << "p3discovery2::sendContactInfo_locked() aboutPGPId: " << aboutId << " toId: " << toId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::map<PGPID, DiscPgpInfo>::const_iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::const_iterator it;
|
||||||
it = mFriendList.find(aboutId);
|
it = mFriendList.find(aboutId);
|
||||||
if (it == mFriendList.end())
|
if (it == mFriendList.end())
|
||||||
{
|
{
|
||||||
@ -846,7 +829,7 @@ void p3discovery2::sendContactInfo_locked(const PGPID &aboutId, const SSLID &toI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<SSLID, DiscSslInfo>::const_iterator sit;
|
std::map<RsPeerId, DiscSslInfo>::const_iterator sit;
|
||||||
for(sit = it->second.mSslIds.begin(); sit != it->second.mSslIds.end(); ++sit)
|
for(sit = it->second.mSslIds.begin(); sit != it->second.mSslIds.end(); ++sit)
|
||||||
{
|
{
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
@ -902,14 +885,14 @@ void p3discovery2::sendContactInfo_locked(const PGPID &aboutId, const SSLID &toI
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
std::cerr << "p3discovery2::sendContactInfo_locked() SSLID Hidden";
|
std::cerr << "p3discovery2::sendContactInfo_locked() RsPeerId Hidden";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::processContactInfo(const SSLID &fromId, const RsDiscContactItem *item)
|
void p3discovery2::processContactInfo(const RsPeerId &fromId, const RsDiscContactItem *item)
|
||||||
{
|
{
|
||||||
(void) fromId; // remove unused parameter warnings, debug only
|
(void) fromId; // remove unused parameter warnings, debug only
|
||||||
|
|
||||||
@ -925,12 +908,12 @@ void p3discovery2::processContactInfo(const SSLID &fromId, const RsDiscContactIt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::iterator it;
|
||||||
it = mFriendList.find(item->pgpId);
|
it = mFriendList.find(item->pgpId);
|
||||||
if (it == mFriendList.end())
|
if (it == mFriendList.end())
|
||||||
{
|
{
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
std::cerr << "p3discovery2::processContactInfo(" << fromId << ") PGPID: ";
|
std::cerr << "p3discovery2::processContactInfo(" << fromId << ") RsPgpId: ";
|
||||||
std::cerr << item->pgpId << " Not Friend.";
|
std::cerr << item->pgpId << " Not Friend.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "p3discovery2::processContactInfo(" << fromId << ") THIS SHOULD NEVER HAPPEN!";
|
std::cerr << "p3discovery2::processContactInfo(" << fromId << ") THIS SHOULD NEVER HAPPEN!";
|
||||||
@ -956,7 +939,7 @@ void p3discovery2::processContactInfo(const SSLID &fromId, const RsDiscContactIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool should_notify_discovery = false;
|
bool should_notify_discovery = false;
|
||||||
std::map<SSLID, DiscSslInfo>::iterator sit;
|
std::map<RsPeerId, DiscSslInfo>::iterator sit;
|
||||||
sit = it->second.mSslIds.find(item->sslId);
|
sit = it->second.mSslIds.find(item->sslId);
|
||||||
if (sit == it->second.mSslIds.end())
|
if (sit == it->second.mSslIds.end())
|
||||||
{
|
{
|
||||||
@ -1005,7 +988,7 @@ void p3discovery2::processContactInfo(const SSLID &fromId, const RsDiscContactIt
|
|||||||
|
|
||||||
/* we explictly request certificates, instead of getting them all the time
|
/* we explictly request certificates, instead of getting them all the time
|
||||||
*/
|
*/
|
||||||
void p3discovery2::requestPGPCertificate(const PGPID &aboutId, const SSLID &toId)
|
void p3discovery2::requestPGPCertificate(const RsPgpId &aboutId, const RsPeerId &toId)
|
||||||
{
|
{
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
std::cerr << "p3discovery2::requestPGPCertificate() aboutId: " << aboutId << " to: " << toId;
|
std::cerr << "p3discovery2::requestPGPCertificate() aboutId: " << aboutId << " to: " << toId;
|
||||||
@ -1044,11 +1027,6 @@ void p3discovery2::recvPGPCertificateRequest(
|
|||||||
|
|
||||||
void p3discovery2::sendPGPCertificate(const RsPgpId &aboutId, const RsPeerId &toId)
|
void p3discovery2::sendPGPCertificate(const RsPgpId &aboutId, const RsPeerId &toId)
|
||||||
{
|
{
|
||||||
//RsDiscPgpCertItem* item = new RsDiscPgpCertItem();
|
|
||||||
//item->pgpId = aboutId;
|
|
||||||
|
|
||||||
//Dbg4() << __PRETTY_FUNCTION__ << " queuing for Cert generation: " << std::endl << *item << std::endl;
|
|
||||||
|
|
||||||
RsDiscPgpKeyItem *pgp_key_item = new RsDiscPgpKeyItem;
|
RsDiscPgpKeyItem *pgp_key_item = new RsDiscPgpKeyItem;
|
||||||
|
|
||||||
pgp_key_item->PeerId(toId);
|
pgp_key_item->PeerId(toId);
|
||||||
@ -1066,12 +1044,6 @@ void p3discovery2::sendPGPCertificate(const RsPgpId &aboutId, const RsPeerId &to
|
|||||||
pgp_key_item->pgpKeyData.bin_len = bin_len;
|
pgp_key_item->pgpKeyData.bin_len = bin_len;
|
||||||
|
|
||||||
sendItem(pgp_key_item);
|
sendItem(pgp_key_item);
|
||||||
|
|
||||||
// (cyril) we shouldn't need to use a queue for that! There's no cost in getting a PGP cert from AuthGPG.
|
|
||||||
// {
|
|
||||||
// RS_STACK_MUTEX(mDiscMtx);
|
|
||||||
// mPendingDiscPgpCertOutList.push_back(item);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::recvPGPCertificate(const RsPeerId& fromId, RsDiscPgpKeyItem* item )
|
void p3discovery2::recvPGPCertificate(const RsPeerId& fromId, RsDiscPgpKeyItem* item )
|
||||||
@ -1190,8 +1162,8 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list<RsPeerId> &proxy
|
|||||||
|
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::const_iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::const_iterator it;
|
||||||
PGPID pgp_id = getPGPId(id);
|
RsPgpId pgp_id = getPGPId(id);
|
||||||
|
|
||||||
it = mFriendList.find(pgp_id);
|
it = mFriendList.find(pgp_id);
|
||||||
if (it == mFriendList.end())
|
if (it == mFriendList.end())
|
||||||
@ -1200,9 +1172,9 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list<RsPeerId> &proxy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For each of their friends that we know, grab that set of SSLIDs.
|
// For each of their friends that we know, grab that set of RsPeerId.
|
||||||
const std::set<PGPID> &friendSet = it->second.mFriendSet;
|
const std::set<RsPgpId> &friendSet = it->second.mFriendSet;
|
||||||
std::set<PGPID>::const_iterator fit;
|
std::set<RsPgpId>::const_iterator fit;
|
||||||
for(fit = friendSet.begin(); fit != friendSet.end(); ++fit)
|
for(fit = friendSet.begin(); fit != friendSet.end(); ++fit)
|
||||||
{
|
{
|
||||||
it = mFriendList.find(*fit);
|
it = mFriendList.find(*fit);
|
||||||
@ -1211,7 +1183,7 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list<RsPeerId> &proxy
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<SSLID, DiscSslInfo>::const_iterator sit;
|
std::map<RsPeerId, DiscSslInfo>::const_iterator sit;
|
||||||
for(sit = it->second.mSslIds.begin();
|
for(sit = it->second.mSslIds.begin();
|
||||||
sit != it->second.mSslIds.end(); ++sit)
|
sit != it->second.mSslIds.end(); ++sit)
|
||||||
{
|
{
|
||||||
@ -1225,51 +1197,13 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list<RsPeerId> &proxy
|
|||||||
bool p3discovery2::getWaitingDiscCount(size_t &sendCount, size_t &recvCount)
|
bool p3discovery2::getWaitingDiscCount(size_t &sendCount, size_t &recvCount)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mDiscMtx);
|
RS_STACK_MUTEX(mDiscMtx);
|
||||||
//sendCount = mPendingDiscPgpCertOutList.size();
|
sendCount = 0;//mPendingDiscPgpCertOutList.size();
|
||||||
recvCount = mPendingDiscPgpCertInList.size();
|
recvCount = 0;//mPendingDiscPgpCertInList.size();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3discovery2::sendInvite(
|
bool p3discovery2::getDiscPgpFriends(const RsPgpId &pgp_id, std::list<RsPgpId> &proxyPgpIds)
|
||||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
|
||||||
std::string& errorMsg )
|
|
||||||
{
|
|
||||||
RsPeers& mPeers = *rsPeers;
|
|
||||||
|
|
||||||
std::string&& invite = mPeers.GetRetroshareInvite(inviteId);
|
|
||||||
|
|
||||||
if(invite.empty())
|
|
||||||
{
|
|
||||||
errorMsg = "Failure generating invite for peer: " +
|
|
||||||
inviteId.toStdString() + " are you sure is a friend?";
|
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " " << errorMsg << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RsGossipDiscoveryInviteItem* item = new RsGossipDiscoveryInviteItem;
|
|
||||||
item->PeerId(toSslId);
|
|
||||||
item->mInvite = mPeers.GetRetroshareInvite(inviteId, true, true);
|
|
||||||
|
|
||||||
return sendItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool p3discovery2::requestInvite(
|
|
||||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
|
||||||
std::string& /*errorMsg*/ )
|
|
||||||
{
|
|
||||||
Dbg2() << __PRETTY_FUNCTION__ << " inviteId: " << inviteId
|
|
||||||
<< " toSslId: " << toSslId << std::endl;
|
|
||||||
|
|
||||||
RsGossipDiscoveryInviteRequestItem* item =
|
|
||||||
new RsGossipDiscoveryInviteRequestItem;
|
|
||||||
item->PeerId(toSslId);
|
|
||||||
item->mInviteId = inviteId;
|
|
||||||
|
|
||||||
return sendItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool p3discovery2::getDiscPgpFriends(const PGPID &pgp_id, std::list<PGPID> &proxyPgpIds)
|
|
||||||
{
|
{
|
||||||
/* find id -> and extract the neighbour_of ids */
|
/* find id -> and extract the neighbour_of ids */
|
||||||
|
|
||||||
@ -1278,7 +1212,7 @@ bool p3discovery2::getDiscPgpFriends(const PGPID &pgp_id, std::list<PGPID> &prox
|
|||||||
|
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo>::const_iterator it;
|
std::map<RsPgpId, DiscPgpInfo>::const_iterator it;
|
||||||
it = mFriendList.find(pgp_id);
|
it = mFriendList.find(pgp_id);
|
||||||
if (it == mFriendList.end())
|
if (it == mFriendList.end())
|
||||||
{
|
{
|
||||||
@ -1286,7 +1220,7 @@ bool p3discovery2::getDiscPgpFriends(const PGPID &pgp_id, std::list<PGPID> &prox
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<PGPID>::const_iterator fit;
|
std::set<RsPgpId>::const_iterator fit;
|
||||||
for(fit = it->second.mFriendSet.begin(); fit != it->second.mFriendSet.end(); ++fit)
|
for(fit = it->second.mFriendSet.begin(); fit != it->second.mFriendSet.end(); ++fit)
|
||||||
{
|
{
|
||||||
proxyPgpIds.push_back(*fit);
|
proxyPgpIds.push_back(*fit);
|
||||||
@ -1294,11 +1228,11 @@ bool p3discovery2::getDiscPgpFriends(const PGPID &pgp_id, std::list<PGPID> &prox
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3discovery2::getPeerVersion(const SSLID &peerId, std::string &version)
|
bool p3discovery2::getPeerVersion(const RsPeerId &peerId, std::string &version)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<SSLID, DiscPeerInfo>::const_iterator it;
|
std::map<RsPeerId, DiscPeerInfo>::const_iterator it;
|
||||||
it = mLocationMap.find(peerId);
|
it = mLocationMap.find(peerId);
|
||||||
if (it == mLocationMap.end())
|
if (it == mLocationMap.end())
|
||||||
{
|
{
|
||||||
@ -1310,11 +1244,11 @@ bool p3discovery2::getPeerVersion(const SSLID &peerId, std::string &version)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3discovery2::setPeerVersion(const SSLID &peerId, const std::string &version)
|
bool p3discovery2::setPeerVersion(const RsPeerId &peerId, const std::string &version)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<SSLID, DiscPeerInfo>::iterator it;
|
std::map<RsPeerId, DiscPeerInfo>::iterator it;
|
||||||
it = mLocationMap.find(peerId);
|
it = mLocationMap.find(peerId);
|
||||||
if (it == mLocationMap.end())
|
if (it == mLocationMap.end())
|
||||||
{
|
{
|
||||||
@ -1326,112 +1260,74 @@ bool p3discovery2::setPeerVersion(const SSLID &peerId, const std::string &versio
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3discovery2::recvInvite(
|
|
||||||
std::unique_ptr<RsGossipDiscoveryInviteItem> inviteItem )
|
|
||||||
{
|
|
||||||
typedef RsGossipDiscoveryFriendInviteReceivedEvent Evt_t;
|
|
||||||
if(rsEvents)
|
|
||||||
rsEvents->postEvent(
|
|
||||||
std::shared_ptr<Evt_t>(new Evt_t(inviteItem->mInvite)) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void p3discovery2::rsEventsHandler(const RsEvent& event)
|
void p3discovery2::rsEventsHandler(const RsEvent& event)
|
||||||
{
|
{
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " " << static_cast<uint32_t>(event.mType)
|
Dbg3() << __PRETTY_FUNCTION__ << " " << static_cast<uint32_t>(event.mType) << std::endl;
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
switch(event.mType)
|
|
||||||
{
|
|
||||||
// case RsEventType::PEER_STATE_CHANGED:
|
|
||||||
// {
|
|
||||||
// const RsPeerId& sslId = static_cast<const RsPeerStateChangedEvent&>(event).mSslId;
|
|
||||||
//
|
|
||||||
// if( rsPeers && rsPeers->isSslOnlyFriend(sslId) && mServiceCtrl->isPeerConnected( getServiceInfo().mServiceType, sslId ) )
|
|
||||||
// {
|
|
||||||
// if(!requestPGPCertificate(sslId, sslId))
|
|
||||||
// RsErr() << __PRETTY_FUNCTION__ << " requestInvite to peer "
|
|
||||||
// << sslId << " failed" << std::endl;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
/* AuthGPGService */
|
/* AuthGPGService */
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
AuthGPGOperation *p3discovery2::getGPGOperation()
|
// AuthGPGOperation *p3discovery2::getGPGOperation()
|
||||||
{
|
// {
|
||||||
{
|
|
||||||
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
|
||||||
|
|
||||||
/* process disc reply in list */
|
|
||||||
if (!mPendingDiscPgpCertInList.empty()) {
|
|
||||||
RsDiscPgpCertItem *item = mPendingDiscPgpCertInList.front();
|
|
||||||
mPendingDiscPgpCertInList.pop_front();
|
|
||||||
|
|
||||||
return new AuthGPGOperationLoadOrSave(true, item->pgpId, item->pgpCert, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
// RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
//
|
//
|
||||||
// /* process disc reply in list */
|
// /* process disc reply in list */
|
||||||
// if (!mPendingDiscPgpCertOutList.empty()) {
|
// if (!mPendingDiscPgpCertInList.empty()) {
|
||||||
// RsDiscPgpCertItem *item = mPendingDiscPgpCertOutList.front();
|
// RsDiscPgpCertItem *item = mPendingDiscPgpCertInList.front();
|
||||||
// mPendingDiscPgpCertOutList.pop_front();
|
// mPendingDiscPgpCertInList.pop_front();
|
||||||
//
|
//
|
||||||
// return new AuthGPGOperationLoadOrSave(false, item->pgpId, "", item);
|
// return new AuthGPGOperationLoadOrSave(true, item->pgpId, item->pgpCert, item);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return NULL;
|
//
|
||||||
}
|
// return NULL;
|
||||||
|
// }
|
||||||
|
|
||||||
void p3discovery2::setGPGOperation(AuthGPGOperation *operation)
|
// void p3discovery2::setGPGOperation(AuthGPGOperation *operation)
|
||||||
{
|
// {
|
||||||
AuthGPGOperationLoadOrSave *loadOrSave = dynamic_cast<AuthGPGOperationLoadOrSave*>(operation);
|
// AuthGPGOperationLoadOrSave *loadOrSave = dynamic_cast<AuthGPGOperationLoadOrSave*>(operation);
|
||||||
if (loadOrSave)
|
// if (loadOrSave)
|
||||||
{
|
// {
|
||||||
RsDiscPgpCertItem *item = (RsDiscPgpCertItem *) loadOrSave->m_userdata;
|
// RsDiscPgpCertItem *item = (RsDiscPgpCertItem *) loadOrSave->m_userdata;
|
||||||
if (!item)
|
// if (!item)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// if (loadOrSave->m_load)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// #ifdef P3DISC_DEBUG
|
||||||
|
// std::cerr << "p3discovery2::setGPGOperation() Loaded Cert" << std::endl;
|
||||||
|
// item->print(std::cerr, 5);
|
||||||
|
// std::cerr << std::endl;
|
||||||
|
// #endif
|
||||||
|
// // It has already been processed by PGP.
|
||||||
|
// delete item;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// // Attaching Certificate.
|
||||||
|
// item->pgpCert = loadOrSave->m_certGpg;
|
||||||
|
//
|
||||||
|
// #ifdef P3DISC_DEBUG
|
||||||
|
// std::cerr << "p3discovery2::setGPGOperation() Sending Message:" << std::endl;
|
||||||
|
// item->print(std::cerr, 5);
|
||||||
|
// #endif
|
||||||
|
//
|
||||||
|
// // Send off message
|
||||||
|
// sendItem(item);
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /* ignore other operations */
|
||||||
|
// }
|
||||||
|
|
||||||
if (loadOrSave->m_load)
|
// (cyril) do we still need this??
|
||||||
{
|
RsGossipDiscoveryFriendInviteReceivedEvent::RsGossipDiscoveryFriendInviteReceivedEvent(const std::string& invite) :
|
||||||
|
|
||||||
#ifdef P3DISC_DEBUG
|
|
||||||
std::cerr << "p3discovery2::setGPGOperation() Loaded Cert" << std::endl;
|
|
||||||
item->print(std::cerr, 5);
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
// It has already been processed by PGP.
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Attaching Certificate.
|
|
||||||
item->pgpCert = loadOrSave->m_certGpg;
|
|
||||||
|
|
||||||
#ifdef P3DISC_DEBUG
|
|
||||||
std::cerr << "p3discovery2::setGPGOperation() Sending Message:" << std::endl;
|
|
||||||
item->print(std::cerr, 5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Send off message
|
|
||||||
sendItem(item);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ignore other operations */
|
|
||||||
}
|
|
||||||
|
|
||||||
RsGossipDiscoveryFriendInviteReceivedEvent::
|
|
||||||
RsGossipDiscoveryFriendInviteReceivedEvent(const std::string& invite) :
|
|
||||||
RsEvent(RsEventType::GOSSIP_DISCOVERY_INVITE_RECEIVED),
|
RsEvent(RsEventType::GOSSIP_DISCOVERY_INVITE_RECEIVED),
|
||||||
mInvite(invite) {}
|
mInvite(invite) {}
|
||||||
|
@ -36,9 +36,6 @@
|
|||||||
|
|
||||||
class p3ServiceControl;
|
class p3ServiceControl;
|
||||||
|
|
||||||
using PGPID RS_DEPRECATED_FOR(RsPgpId) = RsPgpId;
|
|
||||||
using SSLID RS_DEPRECATED_FOR(RsPeerId) = RsPeerId;
|
|
||||||
|
|
||||||
struct DiscSslInfo
|
struct DiscSslInfo
|
||||||
{
|
{
|
||||||
DiscSslInfo() : mDiscStatus(0) {}
|
DiscSslInfo() : mDiscStatus(0) {}
|
||||||
@ -56,16 +53,16 @@ struct DiscPgpInfo
|
|||||||
{
|
{
|
||||||
DiscPgpInfo() {}
|
DiscPgpInfo() {}
|
||||||
|
|
||||||
void mergeFriendList(const std::set<PGPID> &friends);
|
void mergeFriendList(const std::set<RsPgpId> &friends);
|
||||||
|
|
||||||
std::set<PGPID> mFriendSet;
|
std::set<RsPgpId> mFriendSet;
|
||||||
std::map<SSLID, DiscSslInfo> mSslIds;
|
std::map<RsPeerId, DiscSslInfo> mSslIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class p3discovery2 :
|
class p3discovery2 :
|
||||||
public RsGossipDiscovery, public p3Service, public pqiServiceMonitor,
|
public RsGossipDiscovery, public p3Service, public pqiServiceMonitor
|
||||||
public AuthGPGService
|
//public AuthGPGService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -87,57 +84,41 @@ virtual RsServiceInfo getServiceInfo();
|
|||||||
bool getPeerVersion(const RsPeerId &id, std::string &version);
|
bool getPeerVersion(const RsPeerId &id, std::string &version);
|
||||||
bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount);
|
bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount);
|
||||||
|
|
||||||
/// @see RsGossipDiscovery
|
|
||||||
bool sendInvite(
|
|
||||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
|
||||||
std::string& errorMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
|
|
||||||
) override;
|
|
||||||
|
|
||||||
/// @see RsGossipDiscovery
|
|
||||||
bool requestInvite(
|
|
||||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
|
||||||
std::string& errorMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
|
|
||||||
) override;
|
|
||||||
|
|
||||||
/************* from AuthGPService ****************/
|
/************* from AuthGPService ****************/
|
||||||
virtual AuthGPGOperation *getGPGOperation();
|
// virtual AuthGPGOperation *getGPGOperation();
|
||||||
virtual void setGPGOperation(AuthGPGOperation *operation);
|
// virtual void setGPGOperation(AuthGPGOperation *operation);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
PGPID getPGPId(const SSLID &id);
|
RsPgpId getPGPId(const RsPeerId &id);
|
||||||
|
|
||||||
int handleIncoming();
|
int handleIncoming();
|
||||||
void updatePgpFriendList();
|
void updatePgpFriendList();
|
||||||
|
|
||||||
void addFriend(const SSLID &sslId);
|
void addFriend(const RsPeerId &sslId);
|
||||||
void removeFriend(const SSLID &sslId);
|
void removeFriend(const RsPeerId &sslId);
|
||||||
|
|
||||||
void updatePeerAddresses(const RsDiscContactItem *item);
|
void updatePeerAddresses(const RsDiscContactItem *item);
|
||||||
void updatePeerAddressList(const RsDiscContactItem *item);
|
void updatePeerAddressList(const RsDiscContactItem *item);
|
||||||
|
|
||||||
void sendOwnContactInfo(const SSLID &sslid);
|
void sendOwnContactInfo(const RsPeerId &sslid);
|
||||||
void recvOwnContactInfo(const SSLID &fromId, const RsDiscContactItem *item);
|
void recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContactItem *item);
|
||||||
|
|
||||||
void sendPGPList(const SSLID &toId);
|
void sendPGPList(const RsPeerId &toId);
|
||||||
void processPGPList(const SSLID &fromId, const RsDiscPgpListItem *item);
|
void processPGPList(const RsPeerId &fromId, const RsDiscPgpListItem *item);
|
||||||
|
|
||||||
void processContactInfo(const SSLID &fromId, const RsDiscContactItem *info);
|
void processContactInfo(const RsPeerId &fromId, const RsDiscContactItem *info);
|
||||||
|
|
||||||
void requestPGPCertificate(const PGPID &aboutId, const SSLID &toId);
|
// send/recv information
|
||||||
|
|
||||||
void recvPGPCertificateRequest(
|
|
||||||
const RsPeerId& fromId, const RsDiscPgpListItem* item );
|
|
||||||
|
|
||||||
|
void requestPGPCertificate(const RsPgpId &aboutId, const RsPeerId &toId);
|
||||||
|
void recvPGPCertificateRequest(const RsPeerId& fromId, const RsDiscPgpListItem* item );
|
||||||
void sendPGPCertificate(const RsPgpId &aboutId, const RsPeerId &toId);
|
void sendPGPCertificate(const RsPgpId &aboutId, const RsPeerId &toId);
|
||||||
void recvPGPCertificate(const SSLID &fromId, RsDiscPgpCertItem *item); // deprecated
|
void recvPGPCertificate(const RsPeerId &fromId, RsDiscPgpKeyItem *item);
|
||||||
void recvPGPCertificate(const SSLID &fromId, RsDiscPgpKeyItem *item);
|
|
||||||
void recvIdentityList(const RsPeerId& pid,const std::list<RsGxsId>& ids);
|
void recvIdentityList(const RsPeerId& pid,const std::list<RsGxsId>& ids);
|
||||||
|
|
||||||
bool setPeerVersion(const SSLID &peerId, const std::string &version);
|
bool setPeerVersion(const RsPeerId &peerId, const std::string &version);
|
||||||
|
|
||||||
void recvInvite(std::unique_ptr<RsGossipDiscoveryInviteItem> inviteItem);
|
|
||||||
|
|
||||||
void rsEventsHandler(const RsEvent& event);
|
void rsEventsHandler(const RsEvent& event);
|
||||||
RsEventsHandlerId_t mRsEventsHandle;
|
RsEventsHandlerId_t mRsEventsHandle;
|
||||||
@ -152,16 +133,18 @@ private:
|
|||||||
/* data */
|
/* data */
|
||||||
RsMutex mDiscMtx;
|
RsMutex mDiscMtx;
|
||||||
|
|
||||||
void updatePeers_locked(const SSLID &aboutId);
|
void updatePeers_locked(const RsPeerId &aboutId);
|
||||||
void sendContactInfo_locked(const PGPID &aboutId, const SSLID &toId);
|
void sendContactInfo_locked(const RsPgpId &aboutId, const RsPeerId &toId);
|
||||||
|
|
||||||
rstime_t mLastPgpUpdate;
|
rstime_t mLastPgpUpdate;
|
||||||
|
|
||||||
std::map<PGPID, DiscPgpInfo> mFriendList;
|
std::map<RsPgpId, DiscPgpInfo> mFriendList;
|
||||||
std::map<SSLID, DiscPeerInfo> mLocationMap;
|
std::map<RsPeerId, DiscPeerInfo> mLocationMap;
|
||||||
|
|
||||||
std::list<RsDiscPgpCertItem *> mPendingDiscPgpCertInList;
|
// This was used to async the receiving of PGP keys, mainly because PGPHandler cross-checks all signatures, so receiving these keys in large loads can be costly
|
||||||
//std::list<RsDiscPgpCertItem *> mPendingDiscPgpCertOutList;
|
// Because discovery is not running in the main thread, there's no reason to re-async this into another process (e.g. AuthGPG)
|
||||||
|
//
|
||||||
|
// std::list<RsDiscPgpCertItem *> mPendingDiscPgpCertInList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RS_SET_CONTEXT_DEBUG_LEVEL(1)
|
RS_SET_CONTEXT_DEBUG_LEVEL(1)
|
||||||
|
@ -64,6 +64,8 @@ struct RsGossipDiscoveryFriendInviteReceivedEvent : RsEvent
|
|||||||
class RsGossipDiscovery
|
class RsGossipDiscovery
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~RsGossipDiscovery() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getDiscFriends get a list of all friends of a given friend
|
* @brief getDiscFriends get a list of all friends of a given friend
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
@ -101,34 +103,4 @@ public:
|
|||||||
* @return true on success false otherwise
|
* @return true on success false otherwise
|
||||||
*/
|
*/
|
||||||
virtual bool getWaitingDiscCount(size_t& sendCount, size_t& recvCount) = 0;
|
virtual bool getWaitingDiscCount(size_t& sendCount, size_t& recvCount) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Send RetroShare invite to given peer
|
|
||||||
* @jsonapi{development}
|
|
||||||
* @param[in] inviteId id of peer of which send the invite
|
|
||||||
* @param[in] toSslId ssl id of the destination peer
|
|
||||||
* @param[out] errorMessage Optional storage for the error message,
|
|
||||||
* meaningful only on failure.
|
|
||||||
* @return true on success false otherwise
|
|
||||||
*/
|
|
||||||
virtual bool sendInvite(
|
|
||||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
|
||||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
|
|
||||||
) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Request RetroShare certificate to given peer
|
|
||||||
* @jsonapi{development}
|
|
||||||
* @param[in] inviteId id of the peer of which request the invite
|
|
||||||
* @param[in] toSslId id of the destination of the request
|
|
||||||
* @param[out] errorMessage Optional storage for the error message,
|
|
||||||
* meaningful only on failure.
|
|
||||||
* @return true on success false otherwise
|
|
||||||
*/
|
|
||||||
virtual bool requestInvite(
|
|
||||||
const RsPeerId& inviteId, const RsPeerId& toSslId,
|
|
||||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
|
|
||||||
) = 0;
|
|
||||||
|
|
||||||
virtual ~RsGossipDiscovery();
|
|
||||||
};
|
};
|
||||||
|
@ -1792,7 +1792,7 @@ int RsServer::StartupRetroShare()
|
|||||||
/* Add AuthGPG services */
|
/* Add AuthGPG services */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
AuthGPG::getAuthGPG()->addService(mDisc);
|
//AuthGPG::getAuthGPG()->addService(mDisc);
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* Force Any Last Configuration Options */
|
/* Force Any Last Configuration Options */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user