mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-31 18:29:02 -04:00
merged upstream/master
This commit is contained in:
commit
f3824f2348
47 changed files with 1639 additions and 646 deletions
|
@ -1602,7 +1602,7 @@ void p3GxsCircles::checkDummyIdData()
|
|||
std::vector<RsGxsIdGroup>::iterator it;
|
||||
for(it = ids.begin(); it != ids.end(); ++it)
|
||||
{
|
||||
if (it->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (it->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << "p3GxsCircles::checkDummyIdData() PgpLinkedId: " << it->mMeta.mGroupId;
|
||||
|
@ -1978,7 +1978,7 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
|
|||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << "Processing circle membership requests." << std::endl;
|
||||
#endif
|
||||
GxsMsgDataMap msgItems ;
|
||||
RsGxsMetaDataTemporaryMapVector<RsGxsMsgItem> msgItems;
|
||||
|
||||
if(!RsGenExchange::getMsgData(token, msgItems))
|
||||
{
|
||||
|
|
|
@ -451,24 +451,25 @@ void p3GxsReputation::cleanup()
|
|||
++it ;
|
||||
}
|
||||
|
||||
// update opinions based on flags and contact information
|
||||
// Update opinions based on flags and contact information.
|
||||
// Note: the call to rsIdentity->isARegularContact() is done off-mutex, in order to avoid a cross-deadlock, as
|
||||
// normally, p3GxsReputation gets called by p3dentity and not te reverse. That explains the weird implementation
|
||||
// of these two loops.
|
||||
{
|
||||
std::list<RsGxsId> should_set_to_positive ;
|
||||
std::list<RsGxsId> should_set_to_positive_candidates ;
|
||||
|
||||
if(mAutoSetPositiveOptionToContacts)
|
||||
{
|
||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();++it)
|
||||
{
|
||||
bool is_a_contact = rsIdentity->isARegularContact(it->first) ;
|
||||
|
||||
if(mAutoSetPositiveOptionToContacts && is_a_contact && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
|
||||
should_set_to_positive.push_back(it->first) ;
|
||||
}
|
||||
if(it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
|
||||
should_set_to_positive_candidates.push_back(it->first) ;
|
||||
}
|
||||
|
||||
for(std::list<RsGxsId>::const_iterator it(should_set_to_positive.begin());it!=should_set_to_positive.end();++it)
|
||||
setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ;
|
||||
for(std::list<RsGxsId>::const_iterator it(should_set_to_positive_candidates.begin());it!=should_set_to_positive_candidates.end();++it)
|
||||
if(rsIdentity->isARegularContact(*it))
|
||||
setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,14 +768,45 @@ bool p3GxsReputation::updateLatestUpdate(RsPeerId peerid,time_t latest_update)
|
|||
* Opinion
|
||||
****/
|
||||
|
||||
RsReputations::ReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id)
|
||||
RsReputations::ReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags)
|
||||
{
|
||||
ReputationInfo info ;
|
||||
getReputationInfo(id,RsPgpId(),info) ;
|
||||
|
||||
RsPgpId owner_id ;
|
||||
|
||||
if(identity_flags)
|
||||
getIdentityFlagsAndOwnerId(id,*identity_flags,owner_id);
|
||||
|
||||
return info.mOverallReputationLevel ;
|
||||
}
|
||||
|
||||
bool p3GxsReputation::getIdentityFlagsAndOwnerId(const RsGxsId& gxsid, uint32_t& identity_flags,RsPgpId& owner_id)
|
||||
{
|
||||
if(gxsid.isNull())
|
||||
return false ;
|
||||
|
||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
std::map<RsGxsId,Reputation>::iterator it = mReputations.find(gxsid) ;
|
||||
|
||||
if(it == mReputations.end())
|
||||
return false ;
|
||||
|
||||
if(!(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_UP_TO_DATE))
|
||||
return false ;
|
||||
|
||||
if(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_LINKED)
|
||||
identity_flags |= RS_IDENTITY_FLAGS_PGP_LINKED ;
|
||||
|
||||
if(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_KNOWN)
|
||||
identity_flags |= RS_IDENTITY_FLAGS_PGP_KNOWN ;
|
||||
|
||||
owner_id = it->second.mOwnerNode ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& ownerNode, RsReputations::ReputationInfo& info, bool stamp)
|
||||
{
|
||||
if(gxsid.isNull())
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
|
||||
virtual bool isNodeBanned(const RsPgpId& id);
|
||||
virtual void banNode(const RsPgpId& id,bool b) ;
|
||||
virtual ReputationLevel overallReputationLevel(const RsGxsId& id);
|
||||
virtual ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL);
|
||||
|
||||
virtual void setNodeAutoPositiveOpinionForContacts(bool b) ;
|
||||
virtual bool nodeAutoPositiveOpinionForContacts() ;
|
||||
|
@ -143,6 +143,7 @@ public:
|
|||
virtual bool loadList(std::list<RsItem*>& load) ;
|
||||
|
||||
private:
|
||||
bool getIdentityFlagsAndOwnerId(const RsGxsId& gxsid, uint32_t& identity_flags, RsPgpId &owner_id);
|
||||
|
||||
bool processIncoming();
|
||||
|
||||
|
|
|
@ -695,12 +695,26 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
|||
|
||||
if (params.isPgpLinked)
|
||||
{
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
#warning Backward compatibility issue to fix here in v0.7.0
|
||||
|
||||
// This is a hack, because a bad decision led to having RSGXSID_GROUPFLAG_REALID be equal to GXS_SERV::FLAG_PRIVACY_PRIVATE.
|
||||
// In order to keep backward compatibility, we'll also add the new value
|
||||
// When the ID is not PGP linked, the group flag cannot be let empty, so we use PUBLIC.
|
||||
//
|
||||
// The correct combination of flags should be:
|
||||
// PGP-linked: GXS_SERV::FLAGS_PRIVACY_PUBLIC | RSGXSID_GROUPFLAG_REALID
|
||||
// Anonymous : GXS_SERV::FLAGS_PRIVACY_PUBLIC
|
||||
|
||||
id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PRIVATE; // this is also equal to RSGXSID_GROUPFLAG_REALID_deprecated
|
||||
id.mMeta.mGroupFlags |= RSGXSID_GROUPFLAG_REALID;
|
||||
|
||||
// The current version should be able to produce new identities that old peers will accept as well.
|
||||
// In the future, we need to:
|
||||
// - set the current group flags here (see above)
|
||||
// - replace all occurences of RSGXSID_GROUPFLAG_REALID_deprecated by RSGXSID_GROUPFLAG_REALID in the code.
|
||||
}
|
||||
else
|
||||
{
|
||||
id.mMeta.mGroupFlags = 0;
|
||||
}
|
||||
id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
|
||||
createGroup(token, id);
|
||||
|
||||
|
@ -1260,7 +1274,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token)
|
|||
}
|
||||
|
||||
// update IdScore too.
|
||||
bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||
bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility);
|
||||
ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature);
|
||||
ssdata.score.rep.update();
|
||||
|
||||
|
@ -1876,7 +1890,7 @@ void RsGxsIdCache::init(const RsGxsIdGroupItem *item, const RsTlvPublicRSAKey& i
|
|||
details.mFlags = 0 ;
|
||||
|
||||
if(item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) details.mFlags |= RS_IDENTITY_FLAGS_IS_OWN_ID;
|
||||
if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED;
|
||||
if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED;
|
||||
|
||||
// do some tests
|
||||
if(details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID)
|
||||
|
@ -2830,7 +2844,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
|
|||
|
||||
ServiceCreate_Return createStatus;
|
||||
|
||||
if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
/* create the hash */
|
||||
Sha1CheckSum hash;
|
||||
|
@ -3033,7 +3047,7 @@ bool p3IdService::pgphash_handlerequest(uint32_t token)
|
|||
#endif // DEBUG_IDS
|
||||
|
||||
/* Filter based on IdType */
|
||||
if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID))
|
||||
if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility))
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::pgphash_request() discarding AnonID";
|
||||
|
@ -3609,7 +3623,7 @@ bool p3IdService::recogn_process()
|
|||
ssdata.recogntags.publishTs = item->meta.mPublishTs;
|
||||
|
||||
// update IdScore too.
|
||||
bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||
bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility);
|
||||
ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature);
|
||||
ssdata.score.rep.update();
|
||||
|
||||
|
@ -3830,7 +3844,7 @@ void p3IdService::generateDummy_FriendPGP()
|
|||
|
||||
RsGxsIdGroup id;
|
||||
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_kept_for_compatibility;
|
||||
|
||||
int idx = RSRandom::random_f32() * (gpgids.size() - 1);
|
||||
it = gpgids.begin();
|
||||
|
@ -3867,7 +3881,7 @@ void p3IdService::generateDummy_UnknownPGP()
|
|||
RsGxsIdGroup id;
|
||||
|
||||
// FAKE DATA.
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_kept_for_compatibility;
|
||||
id.mPgpIdHash = Sha1CheckSum::random() ;
|
||||
id.mPgpIdSign = RSRandom::random_alphaNumericString(20) ;
|
||||
id.mMeta.mGroupName = RSRandom::random_alphaNumericString(10) ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue