mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
added auto-cleaning of reputation info for outdated/removed identities
This commit is contained in:
parent
bf28ea7ac7
commit
c98416dc28
@ -221,47 +221,48 @@ public:
|
|||||||
RsIdentity(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) { return; }
|
RsIdentity(RsGxsIface *gxs): RsGxsIfaceHelper(gxs) { return; }
|
||||||
virtual ~RsIdentity() { return; }
|
virtual ~RsIdentity() { return; }
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
// For Other Services....
|
|
||||||
// It should be impossible for them to get a message which we don't have the identity.
|
|
||||||
// Its a major error if we don't have the identity.
|
|
||||||
|
|
||||||
// We cache all identities, and provide alternative (instantaneous)
|
// For Other Services....
|
||||||
// functions to extract info, rather than the standard Token system.
|
// It should be impossible for them to get a message which we don't have the identity.
|
||||||
|
// Its a major error if we don't have the identity.
|
||||||
|
|
||||||
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0;
|
// We cache all identities, and provide alternative (instantaneous)
|
||||||
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0;
|
// functions to extract info, rather than the standard Token system.
|
||||||
|
|
||||||
// Fills up list of all own ids. Returns false if ids are not yet loaded.
|
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0;
|
||||||
virtual bool getOwnIds(std::list<RsGxsId> &ownIds) = 0;
|
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0;
|
||||||
virtual bool isOwnId(const RsGxsId& id) = 0;
|
|
||||||
|
|
||||||
//
|
// Fills up list of all own ids. Returns false if ids are not yet loaded.
|
||||||
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
|
virtual bool getOwnIds(std::list<RsGxsId> &ownIds) = 0;
|
||||||
bool absOpinion, int score) = 0;
|
virtual bool isOwnId(const RsGxsId& id) = 0;
|
||||||
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms) = 0;
|
|
||||||
|
|
||||||
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
//
|
||||||
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
|
||||||
|
bool absOpinion, int score) = 0;
|
||||||
|
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms) = 0;
|
||||||
|
|
||||||
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
||||||
const std::string &tag, RsRecognTagDetails &details) = 0;
|
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
||||||
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
|
||||||
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0;
|
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
||||||
|
const std::string &tag, RsRecognTagDetails &details) = 0;
|
||||||
|
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
||||||
|
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0;
|
||||||
|
|
||||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||||
virtual bool isBanned(const RsGxsId& id) =0;
|
virtual bool isBanned(const RsGxsId& id) =0;
|
||||||
|
virtual time_t getLastUsageTS(const RsGxsId &id) =0;
|
||||||
// Specific RsIdentity Functions....
|
|
||||||
/* Specific Service Data */
|
// Specific RsIdentity Functions....
|
||||||
/* We expose these initially for testing / GUI purposes.
|
/* Specific Service Data */
|
||||||
|
/* We expose these initially for testing / GUI purposes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
||||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
|
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,13 +117,13 @@
|
|||||||
* 10 | 1.0 | 0 | 0.25 | 1.0
|
* 10 | 1.0 | 0 | 0.25 | 1.0
|
||||||
*
|
*
|
||||||
* To check:
|
* To check:
|
||||||
* [ ] Opinions are saved/loaded accross restart
|
* [X] Opinions are saved/loaded accross restart
|
||||||
* [ ] Opinions are transmitted to friends
|
* [X] Opinions are transmitted to friends
|
||||||
* [ ] Opinions are transmitted to friends when updated
|
* [X] Opinions are transmitted to friends when updated
|
||||||
*
|
*
|
||||||
* To do:
|
* To do:
|
||||||
* [ ] Add debug info
|
* [X] Add debug info
|
||||||
* [ ] Test the whole thing
|
* [X] Test the whole thing
|
||||||
* [X] Implement a system to allow not storing info when we don't have it
|
* [X] Implement a system to allow not storing info when we don't have it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -139,6 +139,7 @@ static const float REPUTATION_ASSESSMENT_THRESHOLD_X1 = 0.5f ; // reputat
|
|||||||
static const uint32_t PGP_AUTO_BAN_THRESHOLD_DEFAULT = 2 ; // above this, auto ban any GXS id signed by this node
|
static const uint32_t PGP_AUTO_BAN_THRESHOLD_DEFAULT = 2 ; // above this, auto ban any GXS id signed by this node
|
||||||
static const uint32_t IDENTITY_FLAGS_UPDATE_DELAY = 100 ; //
|
static const uint32_t IDENTITY_FLAGS_UPDATE_DELAY = 100 ; //
|
||||||
static const uint32_t BANNED_NODES_UPDATE_DELAY = 313 ; // update approx every 5 mins. Chosen to not be a multiple of IDENTITY_FLAGS_UPDATE_DELAY
|
static const uint32_t BANNED_NODES_UPDATE_DELAY = 313 ; // update approx every 5 mins. Chosen to not be a multiple of IDENTITY_FLAGS_UPDATE_DELAY
|
||||||
|
static const uint32_t REPUTATION_INFO_KEEP_DELAY = 86400*35; // remove old reputation info 5 days after last usage limit, in case the ID would come back..
|
||||||
|
|
||||||
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
|
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
|
||||||
:p3Service(), p3Config(),
|
:p3Service(), p3Config(),
|
||||||
@ -343,26 +344,38 @@ void p3GxsReputation::cleanup()
|
|||||||
// identities, which would cause an excess of hits to the database.
|
// identities, which would cause an excess of hits to the database.
|
||||||
|
|
||||||
bool updated = false ;
|
bool updated = false ;
|
||||||
|
time_t now = time(NULL) ;
|
||||||
|
|
||||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
|
||||||
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();)
|
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();)
|
||||||
if(it->second.mOpinions.empty() && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
|
if(it->second.mOpinions.empty() && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
|
||||||
{
|
{
|
||||||
std::map<RsGxsId,Reputation>::iterator tmp(it) ;
|
std::map<RsGxsId,Reputation>::iterator tmp(it) ;
|
||||||
++tmp ;
|
++tmp ;
|
||||||
mReputations.erase(it) ;
|
mReputations.erase(it) ;
|
||||||
it = tmp ;
|
it = tmp ;
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << " ID " << it->first << ": own is neutral and no opinions from friends => remove entry" << std::endl;
|
std::cerr << " ID " << it->first << ": own is neutral and no opinions from friends => remove entry" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
updated = true ;
|
updated = true ;
|
||||||
}
|
}
|
||||||
else
|
else if(rsIdentity->getLastUsageTS(it->first) + REPUTATION_INFO_KEEP_DELAY < now)
|
||||||
++it ;
|
{
|
||||||
|
#ifdef DEBUG_REPUTATION
|
||||||
|
std::cerr << " Identity " << it->first << " has a last usage TS of " << now - rsIdentity->getLastUsageTS(it->first) << " secs ago: deleting it." << std::endl;
|
||||||
|
#endif
|
||||||
|
std::map<RsGxsId,Reputation>::iterator tmp(it) ;
|
||||||
|
++tmp ;
|
||||||
|
mReputations.erase(it) ;
|
||||||
|
it = tmp ;
|
||||||
|
updated = true ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++it ;
|
||||||
|
|
||||||
if(updated)
|
if(updated)
|
||||||
IndicateConfigChanged() ;
|
IndicateConfigChanged() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsReputation::updateActiveFriends()
|
void p3GxsReputation::updateActiveFriends()
|
||||||
@ -709,28 +722,28 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
|
|||||||
{
|
{
|
||||||
info.mOwnOpinion = RsReputations::OPINION_NEUTRAL ;
|
info.mOwnOpinion = RsReputations::OPINION_NEUTRAL ;
|
||||||
info.mOverallReputationScore = RsReputations::REPUTATION_THRESHOLD_DEFAULT ;
|
info.mOverallReputationScore = RsReputations::REPUTATION_THRESHOLD_DEFAULT ;
|
||||||
info.mFriendAverage = REPUTATION_THRESHOLD_DEFAULT ;
|
info.mFriendAverage = REPUTATION_THRESHOLD_DEFAULT ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const Reputation& rep(it->second) ;
|
const Reputation& rep(it->second) ;
|
||||||
|
|
||||||
info.mOwnOpinion = RsReputations::Opinion(rep.mOwnOpinion) ;
|
info.mOwnOpinion = RsReputations::Opinion(rep.mOwnOpinion) ;
|
||||||
info.mOverallReputationScore = rep.mReputation ;
|
info.mOverallReputationScore = rep.mReputation ;
|
||||||
info.mFriendAverage = rep.mFriendAverage ;
|
info.mFriendAverage = rep.mFriendAverage ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!owner_id.isNull() && (mBannedPgpIds.find(owner_id) != mBannedPgpIds.end()))
|
if(!owner_id.isNull() && (mBannedPgpIds.find(owner_id) != mBannedPgpIds.end()))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << "p3GxsReputations: identity " << gxsid << " is banned because owner node ID " << owner_id << " is banned." << std::endl;
|
std::cerr << "p3GxsReputations: identity " << gxsid << " is banned because owner node ID " << owner_id << " is banned." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
||||||
}
|
}
|
||||||
else if(info.mOverallReputationScore <= REPUTATION_ASSESSMENT_THRESHOLD_X1)
|
else if(info.mOverallReputationScore <= REPUTATION_ASSESSMENT_THRESHOLD_X1)
|
||||||
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
||||||
else
|
else
|
||||||
info.mAssessment = RsReputations::ASSESSMENT_OK ;
|
info.mAssessment = RsReputations::ASSESSMENT_OK ;
|
||||||
|
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << " information present. OwnOp = " << info.mOwnOpinion << ", overall score=" << info.mAssessment << std::endl;
|
std::cerr << " information present. OwnOp = " << info.mOwnOpinion << ", overall score=" << info.mAssessment << std::endl;
|
||||||
@ -745,7 +758,7 @@ bool p3GxsReputation::isIdentityBanned(const RsGxsId &id,const RsPgpId& owner_no
|
|||||||
|
|
||||||
if(!getReputationInfo(id,owner_node,info))
|
if(!getReputationInfo(id,owner_node,info))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << "isIdentityBanned(): returning " << (info.mAssessment == RsReputations::ASSESSMENT_BAD) << " for GXS id " << id << std::endl;
|
std::cerr << "isIdentityBanned(): returning " << (info.mAssessment == RsReputations::ASSESSMENT_BAD) << " for GXS id " << id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -503,6 +503,12 @@ bool p3IdService:: getNickname(const RsGxsId &id, std::string &nickname)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
time_t p3IdService::getLastUsageTS(const RsGxsId &id)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
return locked_getLastUsageTS(id) ;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3IdService::getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
bool p3IdService::getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_IDS
|
#ifdef DEBUG_IDS
|
||||||
|
@ -218,34 +218,34 @@ private:
|
|||||||
|
|
||||||
class p3IdService: public RsGxsIdExchange, public RsIdentity, public GxsTokenQueue, public RsTickEvent, public p3Config
|
class p3IdService: public RsGxsIdExchange, public RsIdentity, public GxsTokenQueue, public RsTickEvent, public p3Config
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
p3IdService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, PgpAuxUtils *pgpUtils);
|
p3IdService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, PgpAuxUtils *pgpUtils);
|
||||||
|
|
||||||
virtual RsServiceInfo getServiceInfo();
|
virtual RsServiceInfo getServiceInfo();
|
||||||
static uint32_t idAuthenPolicy();
|
static uint32_t idAuthenPolicy();
|
||||||
|
|
||||||
virtual void service_tick(); // needed for background processing.
|
virtual void service_tick(); // needed for background processing.
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Design hack, id service must be constructed first as it
|
* Design hack, id service must be constructed first as it
|
||||||
* is need for construction of subsequent net services
|
* is need for construction of subsequent net services
|
||||||
*/
|
*/
|
||||||
void setNes(RsNetworkExchangeService* nes);
|
void setNes(RsNetworkExchangeService* nes);
|
||||||
|
|
||||||
/* General Interface is provided by RsIdentity / RsGxsIfaceImpl. */
|
/* General Interface is provided by RsIdentity / RsGxsIfaceImpl. */
|
||||||
|
|
||||||
/* Data Specific Interface */
|
/* Data Specific Interface */
|
||||||
|
|
||||||
// These are exposed via RsIdentity.
|
// These are exposed via RsIdentity.
|
||||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
|
||||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions);
|
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions);
|
||||||
|
|
||||||
// These are local - and not exposed via RsIdentity.
|
// These are local - and not exposed via RsIdentity.
|
||||||
virtual bool createGroup(uint32_t& token, RsGxsIdGroup &group);
|
virtual bool createGroup(uint32_t& token, RsGxsIdGroup &group);
|
||||||
virtual bool updateGroup(uint32_t& token, RsGxsIdGroup &group);
|
virtual bool updateGroup(uint32_t& token, RsGxsIdGroup &group);
|
||||||
virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group);
|
virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group);
|
||||||
//virtual bool createMsg(uint32_t& token, RsGxsIdOpinion &opinion);
|
//virtual bool createMsg(uint32_t& token, RsGxsIdOpinion &opinion);
|
||||||
|
|
||||||
/**************** RsIdentity External Interface.
|
/**************** RsIdentity External Interface.
|
||||||
* Notes:
|
* Notes:
|
||||||
@ -256,87 +256,88 @@ virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group);
|
|||||||
* Also need to handle Cache updates / invalidation from internal changes.
|
* Also need to handle Cache updates / invalidation from internal changes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//virtual bool getNickname(const RsGxsId &id, std::string &nickname);
|
//virtual bool getNickname(const RsGxsId &id, std::string &nickname);
|
||||||
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
|
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
|
||||||
|
|
||||||
//
|
//
|
||||||
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
|
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
|
||||||
bool absOpinion, int score);
|
bool absOpinion, int score);
|
||||||
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms);
|
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms);
|
||||||
|
|
||||||
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group);
|
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group);
|
||||||
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group);
|
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group);
|
||||||
|
|
||||||
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
||||||
const std::string &tag, RsRecognTagDetails &details);
|
const std::string &tag, RsRecognTagDetails &details);
|
||||||
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
||||||
uint16_t tag_class, uint16_t tag_type, std::string &tag);
|
uint16_t tag_class, uint16_t tag_type, std::string &tag);
|
||||||
|
|
||||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
||||||
virtual bool isARegularContact(const RsGxsId& id) ;
|
virtual bool isARegularContact(const RsGxsId& id) ;
|
||||||
virtual bool isBanned(const RsGxsId& id) ;
|
virtual bool isBanned(const RsGxsId& id) ;
|
||||||
|
virtual time_t getLastUsageTS(const RsGxsId &id) ;
|
||||||
/**************** RsGixs Implementation ***************/
|
|
||||||
|
|
||||||
virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
|
/**************** RsGixs Implementation ***************/
|
||||||
|
|
||||||
//virtual bool getPublicKey(const RsGxsId &id, RsTlvSecurityKey &key) ;
|
virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
|
||||||
//virtual void networkRequestPublicKey(const RsGxsId& key_id,const std::list<RsPeerId>& peer_ids) ;
|
|
||||||
|
|
||||||
virtual bool isOwnId(const RsGxsId& key_id) ;
|
//virtual bool getPublicKey(const RsGxsId &id, RsTlvSecurityKey &key) ;
|
||||||
|
//virtual void networkRequestPublicKey(const RsGxsId& key_id,const std::list<RsPeerId>& peer_ids) ;
|
||||||
|
|
||||||
virtual bool signData(const uint8_t *data,uint32_t data_size,const RsGxsId& signer_id,RsTlvKeySignature& signature,uint32_t& signing_error) ;
|
virtual bool isOwnId(const RsGxsId& key_id) ;
|
||||||
virtual bool validateData(const uint8_t *data,uint32_t data_size,const RsTlvKeySignature& signature,bool force_load,uint32_t& signing_error) ;
|
|
||||||
|
|
||||||
virtual bool encryptData(const uint8_t *decrypted_data,uint32_t decrypted_data_size,uint8_t *& encrypted_data,uint32_t& encrypted_data_size,const RsGxsId& encryption_key_id,bool force_load,uint32_t& encryption_error) ;
|
virtual bool signData(const uint8_t *data,uint32_t data_size,const RsGxsId& signer_id,RsTlvKeySignature& signature,uint32_t& signing_error) ;
|
||||||
virtual bool decryptData(const uint8_t *encrypted_data,uint32_t encrypted_data_size,uint8_t *& decrypted_data,uint32_t& decrypted_data_size,const RsGxsId& encryption_key_id,uint32_t& encryption_error) ;
|
virtual bool validateData(const uint8_t *data,uint32_t data_size,const RsTlvKeySignature& signature,bool force_load,uint32_t& signing_error) ;
|
||||||
|
|
||||||
virtual bool haveKey(const RsGxsId &id);
|
virtual bool encryptData(const uint8_t *decrypted_data,uint32_t decrypted_data_size,uint8_t *& encrypted_data,uint32_t& encrypted_data_size,const RsGxsId& encryption_key_id,bool force_load,uint32_t& encryption_error) ;
|
||||||
virtual bool havePrivateKey(const RsGxsId &id);
|
virtual bool decryptData(const uint8_t *encrypted_data,uint32_t encrypted_data_size,uint8_t *& decrypted_data,uint32_t& decrypted_data_size,const RsGxsId& encryption_key_id,uint32_t& encryption_error) ;
|
||||||
|
|
||||||
virtual bool getKey(const RsGxsId &id, RsTlvPublicRSAKey &key);
|
virtual bool haveKey(const RsGxsId &id);
|
||||||
virtual bool getPrivateKey(const RsGxsId &id, RsTlvPrivateRSAKey &key);
|
virtual bool havePrivateKey(const RsGxsId &id);
|
||||||
|
|
||||||
virtual bool requestKey(const RsGxsId &id, const std::list<PeerId> &peers);
|
virtual bool getKey(const RsGxsId &id, RsTlvPublicRSAKey &key);
|
||||||
virtual bool requestPrivateKey(const RsGxsId &id);
|
virtual bool getPrivateKey(const RsGxsId &id, RsTlvPrivateRSAKey &key);
|
||||||
|
|
||||||
|
virtual bool requestKey(const RsGxsId &id, const std::list<PeerId> &peers);
|
||||||
|
virtual bool requestPrivateKey(const RsGxsId &id);
|
||||||
|
|
||||||
|
|
||||||
/**************** RsGixsReputation Implementation ****************/
|
/**************** RsGixsReputation Implementation ****************/
|
||||||
|
|
||||||
// get Reputation.
|
// get Reputation.
|
||||||
virtual bool haveReputation(const RsGxsId &id);
|
virtual bool haveReputation(const RsGxsId &id);
|
||||||
virtual bool loadReputation(const RsGxsId &id, const std::list<RsPeerId>& peers);
|
virtual bool loadReputation(const RsGxsId &id, const std::list<RsPeerId>& peers);
|
||||||
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep);
|
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Notifications **/
|
/** Notifications **/
|
||||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||||
|
|
||||||
/** Overloaded to add PgpIdHash to Group Definition **/
|
/** Overloaded to add PgpIdHash to Group Definition **/
|
||||||
virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);
|
virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);
|
||||||
|
|
||||||
// Overloaded from GxsTokenQueue for Request callbacks.
|
// Overloaded from GxsTokenQueue for Request callbacks.
|
||||||
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
||||||
|
|
||||||
// Overloaded from RsTickEvent.
|
// Overloaded from RsTickEvent.
|
||||||
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||||
|
|
||||||
//===================================================//
|
//===================================================//
|
||||||
// p3Config methods //
|
// p3Config methods //
|
||||||
//===================================================//
|
//===================================================//
|
||||||
|
|
||||||
// Load/save the routing info, the pending items in transit, and the config variables.
|
// Load/save the routing info, the pending items in transit, and the config variables.
|
||||||
//
|
//
|
||||||
virtual bool loadList(std::list<RsItem*>& items) ;
|
virtual bool loadList(std::list<RsItem*>& items) ;
|
||||||
virtual bool saveList(bool& cleanup,std::list<RsItem*>& items) ;
|
virtual bool saveList(bool& cleanup,std::list<RsItem*>& items) ;
|
||||||
|
|
||||||
virtual RsSerialiser *setupSerialiser() ;
|
virtual RsSerialiser *setupSerialiser() ;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* This is the Cache for minimising calls to the DataStore.
|
* This is the Cache for minimising calls to the DataStore.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -349,7 +350,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
bool cache_store(const RsGxsIdGroupItem *item);
|
bool cache_store(const RsGxsIdGroupItem *item);
|
||||||
bool cache_update_if_cached(const RsGxsId &id, std::string serviceString);
|
bool cache_update_if_cached(const RsGxsId &id, std::string serviceString);
|
||||||
|
|
||||||
bool isPendingNetworkRequest(const RsGxsId& gxsId);
|
bool isPendingNetworkRequest(const RsGxsId& gxsId);
|
||||||
void requestIdsFromNet();
|
void requestIdsFromNet();
|
||||||
|
|
||||||
// Mutex protected.
|
// Mutex protected.
|
||||||
@ -360,7 +361,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
// Switching to RsMemCache for Key Caching.
|
// Switching to RsMemCache for Key Caching.
|
||||||
RsMemCache<RsGxsId, RsGxsIdCache> mKeyCache;
|
RsMemCache<RsGxsId, RsGxsIdCache> mKeyCache;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Refreshing own Ids.
|
* Refreshing own Ids.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -369,7 +370,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
|
|
||||||
std::list<RsGxsId> mOwnIds;
|
std::list<RsGxsId> mOwnIds;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Test fns for Caching.
|
* Test fns for Caching.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -377,7 +378,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
bool cachetest_getlist();
|
bool cachetest_getlist();
|
||||||
bool cachetest_handlerequest(uint32_t token);
|
bool cachetest_handlerequest(uint32_t token);
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* for processing background tasks that use the serviceString.
|
* for processing background tasks that use the serviceString.
|
||||||
* - must be mutually exclusive to avoid clashes.
|
* - must be mutually exclusive to avoid clashes.
|
||||||
*/
|
*/
|
||||||
@ -387,7 +388,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
bool mBgSchedule_Active;
|
bool mBgSchedule_Active;
|
||||||
uint32_t mBgSchedule_Mode;
|
uint32_t mBgSchedule_Mode;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* pgphash processing.
|
* pgphash processing.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -395,7 +396,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
bool pgphash_handlerequest(uint32_t token);
|
bool pgphash_handlerequest(uint32_t token);
|
||||||
bool pgphash_process();
|
bool pgphash_process();
|
||||||
|
|
||||||
bool checkId(const RsGxsIdGroup &grp, RsPgpId &pgp_id, bool &error);
|
bool checkId(const RsGxsIdGroup &grp, RsPgpId &pgp_id, bool &error);
|
||||||
void getPgpIdList();
|
void getPgpIdList();
|
||||||
|
|
||||||
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
||||||
@ -403,7 +404,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
std::map<RsPgpId, PGPFingerprintType> mPgpFingerprintMap;
|
std::map<RsPgpId, PGPFingerprintType> mPgpFingerprintMap;
|
||||||
std::list<RsGxsIdGroup> mGroupsToProcess;
|
std::list<RsGxsIdGroup> mGroupsToProcess;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* recogn processing.
|
* recogn processing.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -421,7 +422,7 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
void loadRecognKeys();
|
void loadRecognKeys();
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* opinion processing.
|
* opinion processing.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -449,24 +450,24 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
std::map<RsGxsId, RsGxsRecognSignerItem *> mRecognSignKeys;
|
std::map<RsGxsId, RsGxsRecognSignerItem *> mRecognSignKeys;
|
||||||
std::map<RsGxsId, uint32_t> mRecognOldSignKeys;
|
std::map<RsGxsId, uint32_t> mRecognOldSignKeys;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Below is the background task for processing opinions => reputations
|
* Below is the background task for processing opinions => reputations
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual void generateDummyData();
|
virtual void generateDummyData();
|
||||||
void generateDummy_OwnIds();
|
void generateDummy_OwnIds();
|
||||||
void generateDummy_FriendPGP();
|
void generateDummy_FriendPGP();
|
||||||
void generateDummy_UnknownPGP();
|
void generateDummy_UnknownPGP();
|
||||||
void generateDummy_UnknownPseudo();
|
void generateDummy_UnknownPseudo();
|
||||||
|
|
||||||
void cleanUnusedKeys() ;
|
void cleanUnusedKeys() ;
|
||||||
void slowIndicateConfigChanged() ;
|
void slowIndicateConfigChanged() ;
|
||||||
|
|
||||||
virtual void timeStampKey(const RsGxsId& id) ;
|
virtual void timeStampKey(const RsGxsId& id) ;
|
||||||
time_t locked_getLastUsageTS(const RsGxsId& gxs_id);
|
time_t locked_getLastUsageTS(const RsGxsId& gxs_id);
|
||||||
|
|
||||||
std::string genRandomId(int len = 20);
|
std::string genRandomId(int len = 20);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
bool reputation_start();
|
bool reputation_start();
|
||||||
@ -479,7 +480,7 @@ std::string genRandomId(int len = 20);
|
|||||||
bool background_processNewMessages();
|
bool background_processNewMessages();
|
||||||
bool background_FullCalcRequest();
|
bool background_FullCalcRequest();
|
||||||
bool background_processFullCalc();
|
bool background_processFullCalc();
|
||||||
|
|
||||||
bool background_cleanup();
|
bool background_cleanup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -489,40 +490,40 @@ std::string genRandomId(int len = 20);
|
|||||||
/***** below here is locked *****/
|
/***** below here is locked *****/
|
||||||
bool mLastBgCheck;
|
bool mLastBgCheck;
|
||||||
bool mBgProcessing;
|
bool mBgProcessing;
|
||||||
|
|
||||||
uint32_t mBgToken;
|
uint32_t mBgToken;
|
||||||
uint32_t mBgPhase;
|
uint32_t mBgPhase;
|
||||||
|
|
||||||
std::map<RsGxsGroupId, RsGroupMetaData> mBgGroupMap;
|
std::map<RsGxsGroupId, RsGroupMetaData> mBgGroupMap;
|
||||||
std::list<RsGxsGroupId> mBgFullCalcGroups;
|
std::list<RsGxsGroupId> mBgFullCalcGroups;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Other Data that is protected by the Mutex.
|
* Other Data that is protected by the Mutex.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<uint32_t, std::set<RsGxsGroupId> > mIdsPendingCache;
|
std::map<uint32_t, std::set<RsGxsGroupId> > mIdsPendingCache;
|
||||||
std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent;
|
std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent;
|
||||||
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
|
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
|
||||||
std::map<RsGxsId,time_t> mKeysTS ;
|
std::map<RsGxsId,time_t> mKeysTS ;
|
||||||
|
|
||||||
// keep a list of regular contacts. This is useful to sort IDs, and allow some services to priviledged ids only.
|
// keep a list of regular contacts. This is useful to sort IDs, and allow some services to priviledged ids only.
|
||||||
std::set<RsGxsId> mContacts;
|
std::set<RsGxsId> mContacts;
|
||||||
RsNetworkExchangeService* mNes;
|
RsNetworkExchangeService* mNes;
|
||||||
|
|
||||||
/**************************
|
/**************************
|
||||||
* AuxUtils provides interface to Security Function (e.g. GPGAuth(), notify etc.)
|
* AuxUtils provides interface to Security Function (e.g. GPGAuth(), notify etc.)
|
||||||
* without depending directly on all these classes.
|
* without depending directly on all these classes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PgpAuxUtils *mPgpUtils;
|
PgpAuxUtils *mPgpUtils;
|
||||||
|
|
||||||
time_t mLastKeyCleaningTime ;
|
time_t mLastKeyCleaningTime ;
|
||||||
time_t mLastConfigUpdate ;
|
time_t mLastConfigUpdate ;
|
||||||
|
|
||||||
bool mOwnIdsLoaded ;
|
bool mOwnIdsLoaded ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // P3_IDENTITY_SERVICE_HEADER
|
#endif // P3_IDENTITY_SERVICE_HEADER
|
||||||
|
Loading…
Reference in New Issue
Block a user