2012-02-13 13:22:35 -05:00
|
|
|
/*
|
|
|
|
* libretroshare/src/services: p3idservice.h
|
|
|
|
*
|
|
|
|
* Identity interface for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2012-2012 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
2012-10-14 14:32:33 -04:00
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
2012-02-13 13:22:35 -05:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef P3_IDENTITY_SERVICE_HEADER
|
|
|
|
#define P3_IDENTITY_SERVICE_HEADER
|
|
|
|
|
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
#include "retroshare/rsidentity.h" // External Interfaces.
|
|
|
|
#include "gxs/rsgenexchange.h" // GXS service.
|
|
|
|
#include "gxs/rsgixs.h" // Internal Interfaces.
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
#include "gxs/gxstokenqueue.h"
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2012-11-03 09:15:21 -04:00
|
|
|
#include "util/rsmemcache.h"
|
2012-11-19 17:00:05 -05:00
|
|
|
#include "util/rstickevent.h"
|
2013-10-20 05:43:30 -04:00
|
|
|
#include "util/rsrecogn.h"
|
2012-11-03 09:15:21 -04:00
|
|
|
|
2012-11-05 17:28:08 -05:00
|
|
|
#include "pqi/authgpg.h"
|
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
#include "serialiser/rsgxsrecognitems.h"
|
|
|
|
|
2014-04-27 09:14:07 -04:00
|
|
|
class PgpAuxUtils;
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
/*
|
2012-06-07 13:10:47 -04:00
|
|
|
* Identity Service
|
2012-02-13 13:22:35 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
#if 0
|
|
|
|
class GxsReputation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GxsReputation();
|
|
|
|
|
|
|
|
bool updateIdScore(bool pgpLinked, bool pgpKnown);
|
|
|
|
bool update(); // checks ranges and calculates overall score.
|
|
|
|
int mOverallScore;
|
|
|
|
int mIdScore; // PGP, Known, etc.
|
|
|
|
int mOwnOpinion;
|
|
|
|
int mPeerOpinion;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class OpinionRequest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OpinionRequest(uint32_t token, RsGxsId id, bool absOpinion, int32_t score)
|
|
|
|
:mToken(token), mId(id), mAbsOpinion(absOpinion), mScore(score)
|
|
|
|
{ return; }
|
|
|
|
OpinionRequest()
|
|
|
|
:mToken(0), mId(), mAbsOpinion(false), mScore(0)
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
uint32_t mToken;
|
|
|
|
RsGxsId mId;
|
|
|
|
bool mAbsOpinion;
|
|
|
|
int32_t mScore;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
// INTERNAL DATA TYPES.
|
2012-07-29 09:09:36 -04:00
|
|
|
// Describes data stored in GroupServiceString.
|
2012-11-05 17:28:08 -05:00
|
|
|
|
|
|
|
class SSBit
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool load(const std::string &input) = 0;
|
|
|
|
virtual std::string save() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SSGxsIdPgp: public SSBit
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SSGxsIdPgp()
|
|
|
|
:idKnown(false), lastCheckTs(0), checkAttempts(0) { return; }
|
|
|
|
|
|
|
|
virtual bool load(const std::string &input);
|
|
|
|
virtual std::string save() const;
|
|
|
|
|
|
|
|
bool idKnown;
|
|
|
|
time_t lastCheckTs;
|
|
|
|
uint32_t checkAttempts;
|
2014-03-17 16:56:06 -04:00
|
|
|
RsPgpId pgpId;
|
2012-11-05 17:28:08 -05:00
|
|
|
};
|
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
class SSGxsIdRecognTags: public SSBit
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SSGxsIdRecognTags()
|
|
|
|
:tagFlags(0), publishTs(0), lastCheckTs(0) { return; }
|
|
|
|
|
|
|
|
virtual bool load(const std::string &input);
|
|
|
|
virtual std::string save() const;
|
|
|
|
|
|
|
|
void setTags(bool processed, bool pending, uint32_t flags);
|
|
|
|
|
|
|
|
bool tagsProcessed() const; // have we processed?
|
|
|
|
bool tagsPending() const; // should we reprocess?
|
|
|
|
bool tagValid(int i) const;
|
|
|
|
|
2014-01-20 06:42:27 -05:00
|
|
|
uint32_t tagFlags;
|
2013-10-20 05:43:30 -04:00
|
|
|
time_t publishTs;
|
|
|
|
time_t lastCheckTs;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
class SSGxsIdReputation: public SSBit
|
2012-11-05 17:28:08 -05:00
|
|
|
{
|
|
|
|
public:
|
2014-02-19 06:08:37 -05:00
|
|
|
SSGxsIdReputation()
|
|
|
|
:rep() { return; }
|
2012-11-05 17:28:08 -05:00
|
|
|
|
|
|
|
virtual bool load(const std::string &input);
|
|
|
|
virtual std::string save() const;
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
GxsReputation rep;
|
2012-11-05 17:28:08 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class SSGxsIdCumulator: public SSBit
|
2012-07-29 09:09:36 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-11-05 17:28:08 -05:00
|
|
|
SSGxsIdCumulator()
|
|
|
|
:count(0), nullcount(0), sum(0), sumsq(0) { return; }
|
|
|
|
|
|
|
|
virtual bool load(const std::string &input);
|
|
|
|
virtual std::string save() const;
|
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
uint32_t count;
|
|
|
|
uint32_t nullcount;
|
|
|
|
double sum;
|
|
|
|
double sumsq;
|
|
|
|
|
|
|
|
// derived parameters:
|
|
|
|
};
|
|
|
|
|
2012-11-05 17:28:08 -05:00
|
|
|
class SSGxsIdGroup: public SSBit
|
2012-07-29 09:09:36 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-11-05 17:28:08 -05:00
|
|
|
SSGxsIdGroup() { return; }
|
|
|
|
|
|
|
|
virtual bool load(const std::string &input);
|
|
|
|
virtual std::string save() const;
|
|
|
|
|
|
|
|
// pgphash status
|
|
|
|
SSGxsIdPgp pgp;
|
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
// recogTags.
|
|
|
|
SSGxsIdRecognTags recogntags;
|
|
|
|
|
2012-11-05 17:28:08 -05:00
|
|
|
// reputation score.
|
2014-02-19 06:08:37 -05:00
|
|
|
SSGxsIdReputation score;
|
|
|
|
|
|
|
|
// These are depreciated (will load, but not save)
|
2012-11-05 17:28:08 -05:00
|
|
|
SSGxsIdCumulator opinion;
|
|
|
|
SSGxsIdCumulator reputation;
|
2013-10-20 05:43:30 -04:00
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ID_LOCAL_STATUS_FULL_CALC_FLAG 0x00010000
|
|
|
|
#define ID_LOCAL_STATUS_INC_CALC_FLAG 0x00020000
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-10-21 15:15:46 -04:00
|
|
|
#define MAX_CACHE_SIZE 100 // Small for testing..
|
|
|
|
//#define MAX_CACHE_SIZE 10000 // More useful size
|
|
|
|
|
2012-10-22 16:36:28 -04:00
|
|
|
class RsGxsIdGroupItem;
|
|
|
|
|
2012-10-21 15:15:46 -04:00
|
|
|
class RsGxsIdCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsGxsIdCache();
|
2013-10-20 05:43:30 -04:00
|
|
|
RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey &in_pkey,
|
|
|
|
const std::list<RsRecognTag> &tagList);
|
2012-10-21 15:15:46 -04:00
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
void updateServiceString(std::string serviceString);
|
2012-10-21 15:15:46 -04:00
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
time_t mPublishTs;
|
|
|
|
std::list<RsRecognTag> mRecognTags; // Only partially validated.
|
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
RsIdentityDetails details;
|
|
|
|
RsTlvSecurityKey pubkey;
|
2012-10-21 15:15:46 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
// Not sure exactly what should be inherited here?
|
|
|
|
// Chris - please correct as necessary.
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
class p3IdService: public RsGxsIdExchange, public RsIdentity, public GxsTokenQueue, public RsTickEvent, public p3Config
|
2012-10-14 14:32:33 -04:00
|
|
|
{
|
2012-02-13 13:22:35 -05:00
|
|
|
public:
|
2014-04-27 09:14:07 -04:00
|
|
|
p3IdService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, PgpAuxUtils *pgpUtils);
|
2014-03-21 23:53:44 -04:00
|
|
|
|
|
|
|
virtual RsServiceInfo getServiceInfo();
|
2013-03-24 15:21:30 -04:00
|
|
|
static uint32_t idAuthenPolicy();
|
2012-11-19 17:00:05 -05:00
|
|
|
|
2012-10-28 19:13:15 -04:00
|
|
|
virtual void service_tick(); // needed for background processing.
|
2012-06-07 13:10:47 -04:00
|
|
|
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2013-11-04 09:09:32 -05:00
|
|
|
/*!
|
|
|
|
* Design hack, id service must be constructed first as it
|
|
|
|
* is need for construction of subsequent net services
|
|
|
|
*/
|
|
|
|
void setNes(RsNetworkExchangeService* nes);
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
/* General Interface is provided by RsIdentity / RsGxsIfaceImpl. */
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
/* Data Specific Interface */
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
// These are exposed via RsIdentity.
|
|
|
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
|
2014-02-19 06:08:37 -05:00
|
|
|
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions);
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-21 11:48:18 -04:00
|
|
|
// These are local - and not exposed via RsIdentity.
|
|
|
|
virtual bool createGroup(uint32_t& token, RsGxsIdGroup &group);
|
2013-10-20 05:43:30 -04:00
|
|
|
virtual bool updateGroup(uint32_t& token, RsGxsIdGroup &group);
|
2014-05-06 13:15:20 -04:00
|
|
|
virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group);
|
2014-02-19 06:08:37 -05:00
|
|
|
//virtual bool createMsg(uint32_t& token, RsGxsIdOpinion &opinion);
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-17 20:28:54 -04:00
|
|
|
/**************** RsIdentity External Interface.
|
|
|
|
* Notes:
|
2012-11-19 17:00:05 -05:00
|
|
|
*
|
|
|
|
* All the data is cached together for the moment - We should probably
|
|
|
|
* seperate and sort this out.
|
|
|
|
*
|
|
|
|
* Also need to handle Cache updates / invalidation from internal changes.
|
|
|
|
*
|
2012-10-17 20:28:54 -04:00
|
|
|
*/
|
2012-11-19 17:00:05 -05:00
|
|
|
//virtual bool getNickname(const RsGxsId &id, std::string &nickname);
|
2012-10-21 11:48:18 -04:00
|
|
|
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
|
2012-11-19 17:00:05 -05:00
|
|
|
|
2012-10-17 20:28:54 -04:00
|
|
|
//
|
2014-02-19 06:08:37 -05:00
|
|
|
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
|
|
|
|
bool absOpinion, int score);
|
2012-10-17 20:28:54 -04:00
|
|
|
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms);
|
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group);
|
2014-05-06 13:15:20 -04:00
|
|
|
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group);
|
2013-10-20 05:43:30 -04:00
|
|
|
|
|
|
|
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname,
|
|
|
|
const std::string &tag, RsRecognTagDetails &details);
|
|
|
|
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
|
|
|
uint16_t tag_class, uint16_t tag_type, std::string &tag);
|
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
/**************** RsGixs Implementation ***************/
|
2012-10-17 20:28:54 -04:00
|
|
|
|
2015-04-18 15:59:27 -04:00
|
|
|
virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
|
2012-11-03 07:57:27 -04:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
//virtual bool getPublicKey(const RsGxsId &id, RsTlvSecurityKey &key) ;
|
|
|
|
//virtual void networkRequestPublicKey(const RsGxsId& key_id,const std::list<RsPeerId>& peer_ids) ;
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
virtual bool isOwnId(const RsGxsId& key_id) ;
|
|
|
|
|
|
|
|
virtual bool signData(const uint8_t *data,uint32_t data_size,const RsGxsId& signer_id,RsTlvKeySignature& signature,uint32_t& signing_error) ;
|
|
|
|
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 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 haveKey(const RsGxsId &id);
|
|
|
|
virtual bool havePrivateKey(const RsGxsId &id);
|
|
|
|
|
|
|
|
virtual bool getKey(const RsGxsId &id, RsTlvSecurityKey &key);
|
|
|
|
virtual bool getPrivateKey(const RsGxsId &id, RsTlvSecurityKey &key);
|
|
|
|
|
|
|
|
virtual bool requestKey(const RsGxsId &id, const std::list<PeerId> &peers);
|
|
|
|
virtual bool requestPrivateKey(const RsGxsId &id);
|
|
|
|
|
|
|
|
|
|
|
|
/**************** RsGixsReputation Implementation ****************/
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
// get Reputation.
|
2013-06-04 17:00:43 -04:00
|
|
|
virtual bool haveReputation(const RsGxsId &id);
|
2014-03-17 16:56:06 -04:00
|
|
|
virtual bool loadReputation(const RsGxsId &id, const std::list<RsPeerId>& peers);
|
2013-06-04 17:00:43 -04:00
|
|
|
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep);
|
2012-06-13 20:27:28 -04:00
|
|
|
|
2012-10-28 19:13:15 -04:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
protected:
|
|
|
|
/** Notifications **/
|
2012-11-05 17:28:08 -05:00
|
|
|
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
|
|
|
|
|
|
|
/** Overloaded to add PgpIdHash to Group Definition **/
|
2013-03-08 14:55:59 -05:00
|
|
|
virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);
|
2012-10-28 19:13:15 -04:00
|
|
|
|
2012-11-29 17:48:28 -05:00
|
|
|
// Overloaded from GxsTokenQueue for Request callbacks.
|
|
|
|
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
|
|
|
|
|
|
|
// Overloaded from RsTickEvent.
|
|
|
|
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
//===================================================//
|
|
|
|
// p3Config methods //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
// Load/save the routing info, the pending items in transit, and the config variables.
|
|
|
|
//
|
|
|
|
virtual bool loadList(std::list<RsItem*>& items) ;
|
|
|
|
virtual bool saveList(bool& cleanup,std::list<RsItem*>& items) ;
|
|
|
|
|
|
|
|
virtual RsSerialiser *setupSerialiser() ;
|
|
|
|
|
|
|
|
|
2012-07-06 19:14:18 -04:00
|
|
|
private:
|
2012-06-07 13:10:47 -04:00
|
|
|
|
2012-10-21 15:15:46 -04:00
|
|
|
/************************************************************************
|
|
|
|
* This is the Cache for minimising calls to the DataStore.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int cache_tick();
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
bool cache_request_load(const RsGxsId &id, const std::list<PeerId>& peers = std::list<PeerId>());
|
2012-10-21 15:15:46 -04:00
|
|
|
bool cache_start_load();
|
|
|
|
bool cache_load_for_token(uint32_t token);
|
|
|
|
|
2012-11-03 10:07:26 -04:00
|
|
|
bool cache_store(const RsGxsIdGroupItem *item);
|
2012-11-19 17:00:05 -05:00
|
|
|
bool cache_update_if_cached(const RsGxsId &id, std::string serviceString);
|
|
|
|
|
2015-05-31 14:18:02 -04:00
|
|
|
bool isPendingNetworkRequest(const RsGxsId& gxsId);
|
2013-11-03 18:46:34 -05:00
|
|
|
void requestIdsFromNet();
|
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
// Mutex protected.
|
2012-10-21 15:15:46 -04:00
|
|
|
|
2013-11-03 18:46:34 -05:00
|
|
|
//std::list<RsGxsId> mCacheLoad_ToCache;
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsGxsId, std::list<RsPeerId> > mCacheLoad_ToCache, mPendingCache;
|
2012-10-21 15:15:46 -04:00
|
|
|
|
2012-11-03 10:07:26 -04:00
|
|
|
// Switching to RsMemCache for Key Caching.
|
|
|
|
RsMemCache<RsGxsId, RsGxsIdCache> mPublicKeyCache;
|
|
|
|
RsMemCache<RsGxsId, RsGxsIdCache> mPrivateKeyCache;
|
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
/************************************************************************
|
|
|
|
* Refreshing own Ids.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool cache_request_ownids();
|
|
|
|
bool cache_load_ownids(uint32_t token);
|
|
|
|
|
|
|
|
std::list<RsGxsId> mOwnIds;
|
2012-10-21 15:15:46 -04:00
|
|
|
|
2012-11-03 07:57:27 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Test fns for Caching.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool cachetest_tick();
|
|
|
|
bool cachetest_getlist();
|
2012-11-19 17:00:05 -05:00
|
|
|
bool cachetest_handlerequest(uint32_t token);
|
2012-11-06 14:18:11 -05:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* for processing background tasks that use the serviceString.
|
|
|
|
* - must be mutually exclusive to avoid clashes.
|
|
|
|
*/
|
2012-11-19 17:00:05 -05:00
|
|
|
bool CacheArbitration(uint32_t mode);
|
|
|
|
void CacheArbitrationDone(uint32_t mode);
|
2012-11-06 14:18:11 -05:00
|
|
|
|
|
|
|
bool mBgSchedule_Active;
|
|
|
|
uint32_t mBgSchedule_Mode;
|
|
|
|
|
2012-11-05 17:28:08 -05:00
|
|
|
/************************************************************************
|
|
|
|
* pgphash processing.
|
|
|
|
*
|
|
|
|
*/
|
2012-11-06 14:18:11 -05:00
|
|
|
bool pgphash_start();
|
2012-11-19 17:00:05 -05:00
|
|
|
bool pgphash_handlerequest(uint32_t token);
|
2012-11-05 17:28:08 -05:00
|
|
|
bool pgphash_process();
|
|
|
|
|
2014-12-10 16:59:28 -05:00
|
|
|
bool checkId(const RsGxsIdGroup &grp, RsPgpId &pgp_id, bool &error);
|
2012-11-05 17:28:08 -05:00
|
|
|
void getPgpIdList();
|
|
|
|
|
2012-11-19 17:00:05 -05:00
|
|
|
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
2012-11-05 17:28:08 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPgpId, PGPFingerprintType> mPgpFingerprintMap;
|
2012-11-05 17:28:08 -05:00
|
|
|
std::list<RsGxsIdGroup> mGroupsToProcess;
|
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
/************************************************************************
|
|
|
|
* recogn processing.
|
|
|
|
*
|
|
|
|
*/
|
2013-11-05 18:33:12 -05:00
|
|
|
bool recogn_schedule();
|
2013-10-20 05:43:30 -04:00
|
|
|
bool recogn_start();
|
|
|
|
bool recogn_handlerequest(uint32_t token);
|
|
|
|
bool recogn_process();
|
|
|
|
|
|
|
|
// helper functions.
|
|
|
|
bool recogn_extract_taginfo(const RsGxsIdGroupItem *item, std::list<RsGxsRecognTagItem *> &tagItems);
|
|
|
|
bool cache_process_recogntaginfo(const RsGxsIdGroupItem *item, std::list<RsRecognTag> &tagList);
|
|
|
|
|
|
|
|
bool recogn_checktag(const RsGxsId &id, const std::string &nickname, RsGxsRecognTagItem *item, bool doSignCheck, bool &isPending);
|
|
|
|
|
|
|
|
void loadRecognKeys();
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* opinion processing.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool opinion_handlerequest(uint32_t token);
|
|
|
|
|
|
|
|
/* MUTEX PROTECTED DATA */
|
|
|
|
std::map<uint32_t, OpinionRequest> mPendingOpinion;
|
|
|
|
|
|
|
|
|
2013-10-29 17:29:20 -04:00
|
|
|
/************************************************************************
|
|
|
|
* for getting identities that are not present
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void checkPeerForIdentities();
|
|
|
|
|
2014-04-27 09:14:07 -04:00
|
|
|
|
2013-10-20 05:43:30 -04:00
|
|
|
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
|
|
|
|
|
|
|
bool checkRecognSignature_locked(std::string encoded, RSA &key, std::string signature);
|
|
|
|
bool getRecognKey_locked(std::string signer, RSA &key);
|
|
|
|
|
|
|
|
std::list<RsGxsGroupId> mRecognGroupIds;
|
|
|
|
std::list<RsGxsIdGroupItem *> mRecognGroupsToProcess;
|
2014-06-12 06:28:23 -04:00
|
|
|
std::map<RsGxsId, RsGxsRecognSignerItem *> mRecognSignKeys;
|
|
|
|
std::map<RsGxsId, uint32_t> mRecognOldSignKeys;
|
2013-10-20 05:43:30 -04:00
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Below is the background task for processing opinions => reputations
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
virtual void generateDummyData();
|
2012-11-30 19:16:24 -05:00
|
|
|
void generateDummy_OwnIds();
|
|
|
|
void generateDummy_FriendPGP();
|
|
|
|
void generateDummy_UnknownPGP();
|
|
|
|
void generateDummy_UnknownPseudo();
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
void cleanUnusedKeys() ;
|
2015-03-14 17:46:30 -04:00
|
|
|
void slowIndicateConfigChanged() ;
|
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
virtual void timeStampKey(const RsGxsId& id) ;
|
|
|
|
time_t locked_getLastUsageTS(const RsGxsId& gxs_id);
|
|
|
|
|
2012-11-30 19:16:24 -05:00
|
|
|
std::string genRandomId(int len = 20);
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
#if 0
|
2012-11-06 14:18:11 -05:00
|
|
|
bool reputation_start();
|
|
|
|
bool reputation_continue();
|
|
|
|
|
2012-07-29 09:09:36 -04:00
|
|
|
int background_tick();
|
|
|
|
bool background_checkTokenRequest();
|
|
|
|
bool background_requestGroups();
|
|
|
|
bool background_requestNewMessages();
|
|
|
|
bool background_processNewMessages();
|
|
|
|
bool background_FullCalcRequest();
|
|
|
|
bool background_processFullCalc();
|
|
|
|
|
|
|
|
bool background_cleanup();
|
2014-02-19 06:08:37 -05:00
|
|
|
#endif
|
2012-07-29 09:09:36 -04:00
|
|
|
|
2012-02-13 13:22:35 -05:00
|
|
|
RsMutex mIdMtx;
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
#if 0
|
2012-02-13 13:22:35 -05:00
|
|
|
/***** below here is locked *****/
|
2012-07-29 09:09:36 -04:00
|
|
|
bool mLastBgCheck;
|
|
|
|
bool mBgProcessing;
|
|
|
|
|
|
|
|
uint32_t mBgToken;
|
|
|
|
uint32_t mBgPhase;
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsGxsGroupId, RsGroupMetaData> mBgGroupMap;
|
|
|
|
std::list<RsGxsGroupId> mBgFullCalcGroups;
|
2014-02-19 06:08:37 -05:00
|
|
|
#endif
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Other Data that is protected by the Mutex.
|
|
|
|
*/
|
2012-02-13 13:22:35 -05:00
|
|
|
|
2013-10-29 17:29:20 -04:00
|
|
|
private:
|
|
|
|
|
2013-11-03 18:46:34 -05:00
|
|
|
std::map<uint32_t, std::set<RsGxsGroupId> > mIdsPendingCache;
|
2013-10-29 17:29:20 -04:00
|
|
|
std::map<uint32_t, std::list<RsGxsGroupId> > mGroupNotPresent;
|
2015-03-14 10:33:23 -04:00
|
|
|
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
|
|
|
|
std::map<RsGxsId,time_t> mKeysTS ;
|
2013-10-29 17:29:20 -04:00
|
|
|
RsNetworkExchangeService* mNes;
|
2014-04-27 09:14:07 -04:00
|
|
|
|
|
|
|
/**************************
|
|
|
|
* AuxUtils provides interface to Security Function (e.g. GPGAuth(), notify etc.)
|
|
|
|
* without depending directly on all these classes.
|
|
|
|
*/
|
|
|
|
|
2015-03-14 10:33:23 -04:00
|
|
|
PgpAuxUtils *mPgpUtils;
|
|
|
|
|
|
|
|
time_t mLastKeyCleaningTime ;
|
2015-03-14 17:46:30 -04:00
|
|
|
time_t mLastConfigUpdate ;
|
2015-04-14 16:57:40 -04:00
|
|
|
|
|
|
|
bool mOwnIdsLoaded ;
|
2012-02-13 13:22:35 -05:00
|
|
|
};
|
|
|
|
|
2012-10-14 14:32:33 -04:00
|
|
|
#endif // P3_IDENTITY_SERVICE_HEADER
|
|
|
|
|
|
|
|
|
|
|
|
|