mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
finished backend part for identity usage statistics
This commit is contained in:
parent
a9670a569a
commit
2919058652
@ -195,11 +195,16 @@ public:
|
||||
GLOBAL_ROUTER_SIGNATURE_CHECK = 0x0a, // Global router message validation
|
||||
GLOBAL_ROUTER_SIGNATURE_CREATION = 0x0b, // Global router message signature
|
||||
GXS_TUNNEL_DH_SIGNATURE_CHECK = 0x0c, //
|
||||
GXS_TUNNEL_DH_SIGNATURE_CREATION = 0x0d //
|
||||
GXS_TUNNEL_DH_SIGNATURE_CREATION = 0x0d, //
|
||||
IDENTITY_DATA_UPDATE = 0x0e, // Group update on that identity data. Can be avatar, name, etc.
|
||||
IDENTITY_GENERIC_SIGNATURE_CHECK = 0x0f, // Any signature verified for that identity
|
||||
IDENTITY_GENERIC_SIGNATURE_CREATION = 0x10, // Any signature made by that identity
|
||||
IDENTITY_GENERIC_ENCRYPTION = 0x11,
|
||||
IDENTITY_GENERIC_DECRYPTION = 0x12,
|
||||
CIRCLE_MEMBERSHIP_CHECK = 0x13
|
||||
} ;
|
||||
|
||||
RsIdentityUsage(uint16_t service,const RsIdentityUsage::UsageCode& code,const RsGxsGroupId& gid=RsGxsGroupId(),const RsGxsMessageId& mid=RsGxsMessageId(),uint64_t additional_id=0,const std::string& comment = std::string())
|
||||
: mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid),mAdditionalId(additional_id),mComment(comment) {}
|
||||
explicit RsIdentityUsage(uint16_t service,const RsIdentityUsage::UsageCode& code,const RsGxsGroupId& gid=RsGxsGroupId(),const RsGxsMessageId& mid=RsGxsMessageId(),uint64_t additional_id=0,const std::string& comment = std::string());
|
||||
|
||||
uint16_t mServiceId; // Id of the service using that identity
|
||||
UsageCode mUsageCode; // Specific code to use. Will allow forming the correct translated message in the GUI if necessary.
|
||||
@ -208,6 +213,12 @@ public:
|
||||
RsGxsMessageId mMsgId; // Message ID using the identity
|
||||
uint64_t mAdditionalId; // Some additional ID. Can be used for e.g. chat lobbies.
|
||||
std::string mComment ; // additional comment to be used mainly for debugging, but not GUI display
|
||||
|
||||
bool operator<(const RsIdentityUsage& u) const
|
||||
{
|
||||
return mHash < u.mHash ;
|
||||
}
|
||||
RsFileHash mHash ;
|
||||
};
|
||||
|
||||
class RsIdentityDetails
|
||||
|
@ -1094,7 +1094,7 @@ bool p3GxsCircles::locked_processLoadingCacheEntry(RsGxsCircleCache& cache)
|
||||
rsPeers->getOnlineList(peers) ;
|
||||
}
|
||||
|
||||
mIdentities->requestKey(pit->first, peers,"Membership status check in Circle "+cache.mCircleName+" ("+cache.mCircleId.toStdString()+")");
|
||||
mIdentities->requestKey(pit->first, peers,RsIdentityUsage(serviceType(),RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK,RsGxsGroupId(cache.mCircleId)));
|
||||
//isUnprocessedPeers = true;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "util/rsrandom.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "util/radix64.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "gxs/gxssecurity.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
@ -525,7 +526,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
|
||||
// also time_stamp the key that this group represents
|
||||
|
||||
timeStampKey(RsGxsId(*git),"Group meta data changed") ;
|
||||
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
||||
|
||||
++git;
|
||||
}
|
||||
@ -932,7 +933,8 @@ bool p3IdService::signData(const uint8_t *data,uint32_t data_size,const RsGxsId&
|
||||
return false ;
|
||||
}
|
||||
error_status = RS_GIXS_ERROR_NO_ERROR ;
|
||||
timeStampKey(own_gxs_id,"Own GXS id") ;
|
||||
timeStampKey(own_gxs_id,RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CREATION)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
bool p3IdService::validateData(const uint8_t *data,uint32_t data_size,const RsTlvKeySignature& signature,bool force_load,const RsIdentityUsage& info,uint32_t& signing_error)
|
||||
@ -997,7 +999,7 @@ bool p3IdService::encryptData(const uint8_t *decrypted_data,uint32_t decrypted_d
|
||||
return false ;
|
||||
}
|
||||
error_status = RS_GIXS_ERROR_NO_ERROR ;
|
||||
timeStampKey(encryption_key_id,"Used to encrypt data") ;
|
||||
timeStampKey(encryption_key_id,RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@ -1029,7 +1031,7 @@ bool p3IdService::decryptData(const uint8_t *encrypted_data,uint32_t encrypted_d
|
||||
return false ;
|
||||
}
|
||||
error_status = RS_GIXS_ERROR_NO_ERROR ;
|
||||
timeStampKey(key_id,"Used to decrypt data") ;
|
||||
timeStampKey(key_id,RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@ -2537,7 +2539,7 @@ bool p3IdService::cachetest_handlerequest(uint32_t token)
|
||||
if (!haveKey(*vit))
|
||||
{
|
||||
std::list<RsPeerId> nullpeers;
|
||||
requestKey(*vit, nullpeers,"Cache test in p3IdService");
|
||||
requestKey(*vit, nullpeers,RsIdentityUsage(serviceType(),RsIdentityUsage::UNKNOWN_USAGE));
|
||||
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::cachetest_request() Requested Key Id: " << *vit;
|
||||
@ -4117,5 +4119,12 @@ void p3IdService::handle_event(uint32_t event_type, const std::string &/*elabel*
|
||||
}
|
||||
}
|
||||
|
||||
RsIdentityUsage::RsIdentityUsage(uint16_t service,const RsIdentityUsage::UsageCode& code,const RsGxsGroupId& gid,const RsGxsMessageId& mid,uint64_t additional_id,const std::string& comment)
|
||||
: mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid),mAdditionalId(additional_id),mComment(comment)
|
||||
{
|
||||
// This is a hack, since it will hash also mHash, but because it is initialized to 0, and only computed in the constructor here, it should be ok.
|
||||
mHash = RsDirUtil::sha1sum(reinterpret_cast<uint8_t*>(this),sizeof(RsIdentityUsage)) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1879,12 +1879,12 @@ void IdDialog::insertIdDetails(uint32_t token)
|
||||
rsIdentity->getIdDetails(RsGxsId(data.mMeta.mGroupId),det) ;
|
||||
|
||||
QString usage_txt ;
|
||||
std::map<time_t,std::string> rmap ;
|
||||
for(std::map<std::string,time_t>::const_iterator it(det.mUseCases.begin());it!=det.mUseCases.end();++it)
|
||||
std::map<time_t,RsIdentityUsage> rmap ;
|
||||
for(std::map<RsIdentityUsage,time_t>::const_iterator it(det.mUseCases.begin());it!=det.mUseCases.end();++it)
|
||||
rmap.insert(std::make_pair(it->second,it->first)) ;
|
||||
|
||||
for(std::map<time_t,std::string>::const_iterator it(rmap.begin());it!=rmap.end();++it)
|
||||
usage_txt += QString("<b>")+ getHumanReadableDuration(now - data.mLastUsageTS) + "</b> \t: " + QString::fromStdString(it->second) + "<br/>" ;
|
||||
for(std::map<time_t,RsIdentityUsage>::const_iterator it(rmap.begin());it!=rmap.end();++it)
|
||||
usage_txt += QString("<b>")+ getHumanReadableDuration(now - data.mLastUsageTS) + "</b> \t: " + createUsageString(it->second) + "<br/>" ;
|
||||
|
||||
if(usage_txt.isNull())
|
||||
usage_txt = tr("<b>[No record in current session]</b>") ;
|
||||
@ -1892,6 +1892,16 @@ void IdDialog::insertIdDetails(uint32_t token)
|
||||
ui->usageStatistics_TB->setText(usage_txt) ;
|
||||
}
|
||||
|
||||
QString IdDialog::createUsageString(const RsIdentityUsage& u) const
|
||||
{
|
||||
switch(u.mUsageCode)
|
||||
{
|
||||
#warning TODO! Add the different strings and translations here.
|
||||
default:
|
||||
return QString("Undone yet");
|
||||
}
|
||||
}
|
||||
|
||||
void IdDialog::modifyReputation()
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
|
@ -119,6 +119,7 @@ private slots:
|
||||
|
||||
private:
|
||||
void processSettings(bool load);
|
||||
QString createUsageString(const RsIdentityUsage& u) const;
|
||||
|
||||
void requestIdDetails();
|
||||
void insertIdDetails(uint32_t token);
|
||||
|
Loading…
Reference in New Issue
Block a user