mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 23:40:26 -04:00
Added PgpAuxUtils to allow Mocking of Pgp functions for simulations.
Cleaned up some of the debug messages. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7306 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4fe6161d58
commit
23480be883
16 changed files with 490 additions and 94 deletions
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "gxssecurity.h"
|
||||
#include "pqi/authgpg.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
//#include "retroshare/rspeers.h"
|
||||
|
||||
#define GXS_SECURITY_DEBUG
|
||||
|
||||
|
|
|
@ -140,7 +140,9 @@
|
|||
#define COL_IDENTITY 4
|
||||
#define COL_HASH 5
|
||||
|
||||
#define RS_DATA_SERVICE_DEBUG
|
||||
/*****
|
||||
* #define RS_DATA_SERVICE_DEBUG 1
|
||||
****/
|
||||
|
||||
const std::string RsGeneralDataService::GRP_META_SERV_STRING = KEY_NXS_SERV_STRING;
|
||||
const std::string RsGeneralDataService::GRP_META_STATUS = KEY_GRP_STATUS;
|
||||
|
@ -196,6 +198,12 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
|||
}
|
||||
|
||||
RsDataService::~RsDataService(){
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::~RsDataService()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mDb->closeDb();
|
||||
delete mDb;
|
||||
}
|
||||
|
@ -270,6 +278,11 @@ void RsDataService::initialise(){
|
|||
|
||||
RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::locked_getGrpMeta()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsGxsGrpMetaData* grpMeta = new RsGxsGrpMetaData();
|
||||
|
||||
bool ok = true;
|
||||
|
@ -283,11 +296,9 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c)
|
|||
std::string tempId;
|
||||
c.getString(COL_GRP_ID, tempId);
|
||||
grpMeta->mGroupId = RsGxsGroupId(tempId);
|
||||
|
||||
|
||||
|
||||
c.getString(COL_IDENTITY, tempId);
|
||||
grpMeta->mAuthorId = RsGxsId(tempId);
|
||||
|
||||
c.getString(COL_GRP_NAME, grpMeta->mGroupName);
|
||||
c.getString(COL_ORIG_GRP_ID, tempId);
|
||||
grpMeta->mOrigGrpId = RsGxsGroupId(tempId);
|
||||
|
@ -1081,11 +1092,20 @@ void RsDataService::locked_retrieveMsgMeta(RetroCursor *c, std::vector<RsGxsMsgM
|
|||
|
||||
int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaData *>& grp)
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::retrieveGxsGrpMetaData()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsStackMutex stack(mDbMutex);
|
||||
|
||||
if(grp.empty()){
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG
|
||||
std::cerr << "RsDataService::retrieveGxsGrpMetaData() retrieving all";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, grpMetaColumns, "", "");
|
||||
|
||||
if(c)
|
||||
|
@ -1095,7 +1115,6 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
|
|||
while(valid)
|
||||
{
|
||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c);
|
||||
|
||||
if(g)
|
||||
{
|
||||
grp[g->mGroupId] = g;
|
||||
|
|
|
@ -30,9 +30,12 @@
|
|||
#include "rsgxsnetservice.h"
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
#include "retroshare/rsgxscircles.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "pgp/pgpauxutils.h"
|
||||
|
||||
/***
|
||||
* #define NXS_NET_DEBUG 1
|
||||
***/
|
||||
|
||||
#define NXS_NET_DEBUG 1
|
||||
#define GIXS_CUT_OFF 0
|
||||
|
||||
#define SYNC_PERIOD 12 // in microseconds every 10 seconds (1 second for testing)
|
||||
|
@ -43,11 +46,14 @@
|
|||
RsGxsNetService::RsGxsNetService(uint16_t servType, RsGeneralDataService *gds,
|
||||
RsNxsNetMgr *netMgr, RsNxsObserver *nxsObs,
|
||||
const RsServiceInfo serviceInfo,
|
||||
RsGixsReputation* reputations, RsGcxs* circles, bool grpAutoSync)
|
||||
RsGixsReputation* reputations, RsGcxs* circles,
|
||||
PgpAuxUtils *pgpUtils, bool grpAutoSync)
|
||||
: p3ThreadedService(), p3Config(), mTransactionN(0),
|
||||
mObserver(nxsObs), mDataStore(gds), mServType(servType),
|
||||
mTransactionTimeOut(TRANSAC_TIMEOUT), mNetMgr(netMgr), mNxsMutex("RsGxsNetService"),
|
||||
mSyncTs(0), mSYNC_PERIOD(SYNC_PERIOD), mCircles(circles), mReputations(reputations), mGrpAutoSync(grpAutoSync), mGrpServerUpdateItem(NULL),
|
||||
mSyncTs(0), mSYNC_PERIOD(SYNC_PERIOD), mCircles(circles), mReputations(reputations),
|
||||
mPgpUtils(pgpUtils),
|
||||
mGrpAutoSync(grpAutoSync), mGrpServerUpdateItem(NULL),
|
||||
mServiceInfo(serviceInfo)
|
||||
|
||||
{
|
||||
|
@ -61,8 +67,8 @@ RsGxsNetService::~RsGxsNetService()
|
|||
}
|
||||
|
||||
|
||||
int RsGxsNetService::tick(){
|
||||
|
||||
int RsGxsNetService::tick()
|
||||
{
|
||||
// always check for new items arriving
|
||||
// from peers
|
||||
if(receivedItems())
|
||||
|
@ -82,6 +88,10 @@ int RsGxsNetService::tick(){
|
|||
|
||||
void RsGxsNetService::syncWithPeers()
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::syncWithPeers()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::set<RsPeerId> peers;
|
||||
mNetMgr->getOnlineList(mServiceInfo.mServiceType, peers);
|
||||
|
@ -363,6 +373,10 @@ void RsGxsNetService::locked_createTransactionFromPending(
|
|||
|
||||
if(entry.mPassedVetting)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "locked_createTransactionFromPending(AUTHOR VETTING) Group Id: " << entry.mGrpId << " PASSED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
RsNxsSyncGrpItem* msgItem = new RsNxsSyncGrpItem(mServType);
|
||||
msgItem->grpId = entry.mGrpId;
|
||||
msgItem->authorId = entry.mAuthorId;
|
||||
|
@ -371,6 +385,13 @@ void RsGxsNetService::locked_createTransactionFromPending(
|
|||
msgItem->PeerId(grpPend->mPeerId);
|
||||
reqList.push_back(msgItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "locked_createTransactionFromPending(AUTHOR VETTING) Group Id: " << entry.mGrpId << " FAILED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(!reqList.empty())
|
||||
|
@ -386,14 +407,12 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVett
|
|||
for(; cit != grpPend->mGrpCircleV.end(); cit++)
|
||||
{
|
||||
const GrpIdCircleVet& entry = *cit;
|
||||
|
||||
// this shows what groups got cleared by the server
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "locked_createTransactionFromPending() Group Id: " << entry.mGroupId << "cleared: "
|
||||
<< entry.mCleared << std::endl;
|
||||
#endif
|
||||
if(entry.mCleared)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "locked_createTransactionFromPending(CIRCLE VETTING) Group Id: " << entry.mGroupId << " PASSED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
RsNxsSyncGrpItem* gItem = new
|
||||
RsNxsSyncGrpItem(mServType);
|
||||
gItem->flag = RsNxsSyncGrpItem::FLAG_RESPONSE;
|
||||
|
@ -401,8 +420,16 @@ void RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVett
|
|||
gItem->publishTs = 0;
|
||||
gItem->PeerId(grpPend->mPeerId);
|
||||
gItem->transactionNumber = transN;
|
||||
// why it authorId not set here???
|
||||
itemL.push_back(gItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "locked_createTransactionFromPending(CIRCLE VETTING) Group Id: " << entry.mGroupId << " FAILED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(!itemL.empty())
|
||||
|
@ -457,7 +484,7 @@ bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta,
|
|||
|
||||
if(mCircles->isLoaded(grpMeta->mCircleId))
|
||||
{
|
||||
const RsPgpId& pgpId = mNetMgr->getGPGId(peerId);
|
||||
const RsPgpId& pgpId = mPgpUtils->getPGPId(peerId);
|
||||
return mCircles->canSend(grpMeta->mCircleId, pgpId);
|
||||
}
|
||||
|
||||
|
@ -465,7 +492,8 @@ bool RsGxsNetService::locked_canReceive(const RsGxsGrpMetaData * const grpMeta,
|
|||
i++;
|
||||
}
|
||||
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -680,6 +708,7 @@ void RsGxsNetService::recvNxsItemQueue(){
|
|||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService Item:" << (void*)item << std::endl ;
|
||||
item->print(std::cerr);
|
||||
#endif
|
||||
// RsNxsItem needs dynamic_cast, since they have derived siblings.
|
||||
//
|
||||
|
@ -1047,10 +1076,13 @@ void RsGxsNetService::processTransactions(){
|
|||
mComplTransactions.push_back(tr);
|
||||
}else{
|
||||
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "processTransactions() " << std::endl;
|
||||
std::cerr << "processTransactions(), Unknown flag for active transaction, transN: " << transN
|
||||
<< std::endl;
|
||||
std::cerr << "processTransactions(), Unknown flag, Peer: " << mit->first;
|
||||
#endif
|
||||
|
||||
toRemove.push_back(transN);
|
||||
tr->mFlag = NxsTransaction::FLAG_STATE_FAILED;
|
||||
mComplTransactions.push_back(tr);
|
||||
|
@ -1080,11 +1112,9 @@ void RsGxsNetService::processTransactions(){
|
|||
if(locked_checkTransacTimedOut(tr))
|
||||
{
|
||||
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "processTransactions() " << std::endl;
|
||||
std::cerr << "Transaction has failed, tranN: " << transN << std::endl;
|
||||
std::cerr << "Transaction has failed, Peer: " << mit->first << std::endl;
|
||||
#endif
|
||||
|
||||
tr->mFlag = NxsTransaction::FLAG_STATE_FAILED;
|
||||
toRemove.push_back(transN);
|
||||
|
@ -1612,6 +1642,11 @@ void RsGxsNetService::addGroupItemToList(NxsTransaction*& tr,
|
|||
const RsGxsGroupId& grpId, uint32_t& transN,
|
||||
std::list<RsNxsItem*>& reqList)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::addGroupItemToList() Added GroupID: << grpId";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsNxsSyncGrpItem* grpItem = new RsNxsSyncGrpItem(mServType);
|
||||
grpItem->PeerId(tr->mTransaction->PeerId());
|
||||
grpItem->grpId = grpId;
|
||||
|
@ -2074,6 +2109,10 @@ bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncGrp *item)
|
|||
{
|
||||
if(item->updateTS >= mGrpServerUpdateItem->grpUpdateTS && item->updateTS != 0)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::locked_CanReceiveUpdate() No Updates";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2087,7 +2126,13 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||
RsStackMutex stack(mNxsMutex);
|
||||
|
||||
if(!locked_CanReceiveUpdate(item))
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::handleRecvSyncGroup() Cannot RecvUpdate";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
RsPeerId peer = item->PeerId();
|
||||
|
||||
|
@ -2097,7 +2142,13 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||
mDataStore->retrieveGxsGrpMetaData(grp);
|
||||
|
||||
if(grp.empty())
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::handleRecvSyncGroup() Grp Empty";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit =
|
||||
grp.begin();
|
||||
|
@ -2134,8 +2185,12 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||
gItem->transactionNumber = transN;
|
||||
itemL.push_back(gItem);
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::handleRecvSyncGroup"
|
||||
<< "\nGroup : " << grpMeta->mGroupName << ", id: " << gItem->grpId << std::endl;
|
||||
std::cerr << "RsGxsNetService::handleRecvSyncGroup";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Group : " << grpMeta->mGroupName;
|
||||
std::cerr << ", id: " << gItem->grpId;
|
||||
std::cerr << ", authorId: " << gItem->authorId;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -2145,7 +2200,7 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||
|
||||
if(!toVet.empty())
|
||||
{
|
||||
mPendingCircleVets.push_back(new GrpCircleIdRequestVetting(mCircles, mNetMgr, toVet, peer));
|
||||
mPendingCircleVets.push_back(new GrpCircleIdRequestVetting(mCircles, mPgpUtils, toVet, peer));
|
||||
}
|
||||
|
||||
locked_pushGrpRespFromList(itemL, peer, transN);
|
||||
|
@ -2157,14 +2212,30 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||
|
||||
bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
// first do the simple checks
|
||||
uint8_t circleType = grpMeta.mCircleType;
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_LOCAL)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() LOCAL_CIRCLE, cannot send";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() PUBLIC_CIRCLE, can send";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
const RsGxsCircleId& circleId = grpMeta.mCircleId;
|
||||
|
||||
|
@ -2172,7 +2243,11 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
|
|||
{
|
||||
if(mCircles->isLoaded(circleId))
|
||||
{
|
||||
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() EXTERNAL_CIRCLE, checking mCircles->canSend";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
|
||||
return mCircles->canSend(circleId, pgpId);
|
||||
}
|
||||
|
||||
|
@ -2182,17 +2257,38 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
|
|||
|
||||
if(circleType == GXS_CIRCLE_TYPE_YOUREYESONLY)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() YOUREYESONLY, checking further";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
// a non empty internal circle id means this
|
||||
// is the personal circle owner
|
||||
if(!grpMeta.mInternalCircle.isNull())
|
||||
{
|
||||
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() have mInternalCircle - we are Group creator";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() mCircleId: " << grpMeta.mCircleId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() mInternalCircle: " << grpMeta.mInternalCircle;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if(mCircles->isLoaded(internalCircleId))
|
||||
{
|
||||
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() circle Loaded - checking mCircles->canSend";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
|
||||
return mCircles->canSend(internalCircleId, pgpId);
|
||||
}
|
||||
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() Circle Not Loaded - add to vetting";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toVet.push_back(GrpIdCircleVet(grpMeta.mGroupId, internalCircleId));
|
||||
return false;
|
||||
}
|
||||
|
@ -2200,10 +2296,26 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
|
|||
{
|
||||
// an empty internal circle id means this peer can only
|
||||
// send circle related info from peer he received it
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() mInternalCircle not set, someone else's personal circle";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if(grpMeta.mOriginator == sslId)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() Originator matches -> can send";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendGrpId() Originator doesn't match -> cannot send";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2323,6 +2435,11 @@ void RsGxsNetService::locked_pushMsgRespFromList(std::list<RsNxsItem*>& itemL, c
|
|||
bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMetas,
|
||||
const RsGxsGrpMetaData& grpMeta, const RsPeerId& sslId)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::canSendMsgIds() CIRCLE VETTING";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// first do the simple checks
|
||||
uint8_t circleType = grpMeta.mCircleType;
|
||||
|
||||
|
@ -2338,7 +2455,7 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
|
|||
{
|
||||
if(mCircles->isLoaded(circleId))
|
||||
{
|
||||
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
|
||||
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
|
||||
return mCircles->canSend(circleId, pgpId);
|
||||
}
|
||||
|
||||
|
@ -2354,7 +2471,7 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
|
|||
}
|
||||
|
||||
if(!toVet.empty())
|
||||
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mNetMgr, toVet, grpMeta.mGroupId,
|
||||
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils, toVet, grpMeta.mGroupId,
|
||||
sslId, grpMeta.mCircleId));
|
||||
|
||||
return false;
|
||||
|
@ -2369,7 +2486,7 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
|
|||
const RsGxsCircleId& internalCircleId = grpMeta.mInternalCircle;
|
||||
if(mCircles->isLoaded(internalCircleId))
|
||||
{
|
||||
const RsPgpId& pgpId = mNetMgr->getGPGId(sslId);
|
||||
const RsPgpId& pgpId = mPgpUtils->getPGPId(sslId);
|
||||
return mCircles->canSend(internalCircleId, pgpId);
|
||||
}
|
||||
|
||||
|
@ -2385,7 +2502,8 @@ bool RsGxsNetService::canSendMsgIds(const std::vector<RsGxsMsgMetaData*>& msgMet
|
|||
}
|
||||
|
||||
if(!toVet.empty())
|
||||
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mNetMgr, toVet, grpMeta.mGroupId,
|
||||
mPendingCircleVets.push_back(new MsgCircleIdsRequestVetting(mCircles, mPgpUtils,
|
||||
toVet, grpMeta.mGroupId,
|
||||
sslId, grpMeta.mCircleId));
|
||||
|
||||
return false;
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef std::map<uint32_t, NxsTransaction*> TransactionIdMap;
|
|||
/// to keep track of peers active transactions
|
||||
typedef std::map<RsPeerId, TransactionIdMap > TransactionsPeerMap;
|
||||
|
||||
class PgpAuxUtils;
|
||||
|
||||
/*!
|
||||
* This class implements the RsNetWorkExchangeService
|
||||
|
@ -80,7 +81,9 @@ public:
|
|||
RsNxsNetMgr *netMgr,
|
||||
RsNxsObserver *nxsObs, // used to be = NULL.
|
||||
const RsServiceInfo serviceInfo,
|
||||
RsGixsReputation* reputations = NULL, RsGcxs* circles = NULL, bool grpAutoSync = true);
|
||||
RsGixsReputation* reputations = NULL, RsGcxs* circles = NULL,
|
||||
PgpAuxUtils *pgpUtils = NULL,
|
||||
bool grpAutoSync = true);
|
||||
|
||||
virtual ~RsGxsNetService();
|
||||
|
||||
|
@ -429,6 +432,7 @@ private:
|
|||
|
||||
RsGcxs* mCircles;
|
||||
RsGixsReputation* mReputations;
|
||||
PgpAuxUtils *mPgpUtils;
|
||||
bool mGrpAutoSync;
|
||||
|
||||
// need to be verfied
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "rsgxsnetutils.h"
|
||||
#include "pqi/p3servicecontrol.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "pgp/pgpauxutils.h"
|
||||
|
||||
|
||||
const time_t AuthorPending::EXPIRY_PERIOD_OFFSET = 30; // 30 seconds
|
||||
|
@ -213,8 +213,8 @@ const int GrpCircleVetting::MSG_ID_RECV_PEND = 3;
|
|||
GrpIdCircleVet::GrpIdCircleVet(const RsGxsGroupId& grpId, const RsGxsCircleId& circleId)
|
||||
: mGroupId(grpId), mCircleId(circleId), mCleared(false) {}
|
||||
|
||||
GrpCircleVetting::GrpCircleVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr)
|
||||
: mCircles(circles), mNetMgr(netMgr) {}
|
||||
GrpCircleVetting::GrpCircleVetting(RsGcxs* const circles, PgpAuxUtils *pgpUtils)
|
||||
: mCircles(circles), mPgpUtils(pgpUtils) {}
|
||||
|
||||
GrpCircleVetting::~GrpCircleVetting() {}
|
||||
|
||||
|
@ -226,7 +226,7 @@ bool GrpCircleVetting::canSend(const SSLIdType& peerId, const RsGxsCircleId& cir
|
|||
{
|
||||
if(mCircles->isLoaded(circleId))
|
||||
{
|
||||
const RsPgpId& pgpId = mNetMgr->getGPGId(peerId);
|
||||
const RsPgpId& pgpId = mPgpUtils->getPGPId(peerId);
|
||||
return mCircles->canSend(circleId, pgpId);
|
||||
}
|
||||
|
||||
|
@ -236,8 +236,10 @@ bool GrpCircleVetting::canSend(const SSLIdType& peerId, const RsGxsCircleId& cir
|
|||
}
|
||||
|
||||
GrpCircleIdRequestVetting::GrpCircleIdRequestVetting(
|
||||
RsGcxs* const circles, RsNxsNetMgr* const netMgr, std::vector<GrpIdCircleVet> grpCircleV, const RsPeerId& peerId)
|
||||
: GrpCircleVetting(circles, netMgr), mGrpCircleV(grpCircleV), mPeerId(peerId) {}
|
||||
RsGcxs* const circles,
|
||||
PgpAuxUtils *pgpUtils,
|
||||
std::vector<GrpIdCircleVet> grpCircleV, const RsPeerId& peerId)
|
||||
: GrpCircleVetting(circles, pgpUtils), mGrpCircleV(grpCircleV), mPeerId(peerId) {}
|
||||
|
||||
bool GrpCircleIdRequestVetting::cleared()
|
||||
{
|
||||
|
@ -274,10 +276,11 @@ MsgIdCircleVet::MsgIdCircleVet(const RsGxsMessageId& msgId,
|
|||
: mMsgId(msgId), mAuthorId(authorId) {
|
||||
}
|
||||
|
||||
MsgCircleIdsRequestVetting::MsgCircleIdsRequestVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr,
|
||||
MsgCircleIdsRequestVetting::MsgCircleIdsRequestVetting(RsGcxs* const circles,
|
||||
PgpAuxUtils *pgpUtils,
|
||||
std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId,
|
||||
const RsPeerId& peerId, const RsGxsCircleId& circleId)
|
||||
: GrpCircleVetting(circles, netMgr), mMsgs(msgs), mGrpId(grpId), mPeerId(peerId), mCircleId(circleId) {}
|
||||
: GrpCircleVetting(circles, pgpUtils), mMsgs(msgs), mGrpId(grpId), mPeerId(peerId), mCircleId(circleId) {}
|
||||
|
||||
bool MsgCircleIdsRequestVetting::cleared()
|
||||
{
|
||||
|
@ -291,8 +294,4 @@ int MsgCircleIdsRequestVetting::getType() const
|
|||
return MSG_ID_SEND_PEND;
|
||||
}
|
||||
|
||||
RsPgpId RsNxsNetMgrImpl::getGPGId(const RsPeerId& peerId) {
|
||||
rsPeers->getGPGId(peerId);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "rsgixs.h"
|
||||
|
||||
class p3ServiceControl;
|
||||
class PgpAuxUtils;
|
||||
|
||||
/*!
|
||||
* This represents a transaction made
|
||||
|
@ -83,7 +84,6 @@ public:
|
|||
virtual ~RsNxsNetMgr(){};
|
||||
virtual const RsPeerId& getOwnId() = 0;
|
||||
virtual void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers) = 0;
|
||||
virtual RsPgpId getGPGId(const RsPeerId& peerId) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -95,9 +95,8 @@ public:
|
|||
RsNxsNetMgrImpl(p3ServiceControl* sc);
|
||||
virtual ~RsNxsNetMgrImpl(){};
|
||||
|
||||
const RsPeerId& getOwnId();
|
||||
void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers);
|
||||
RsPgpId getGPGId(const RsPeerId& peerId);
|
||||
virtual const RsPeerId& getOwnId();
|
||||
virtual void getOnlineList(const uint32_t serviceId, std::set<RsPeerId>& ssl_peers);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -245,7 +244,7 @@ public:
|
|||
static const int MSG_ID_RECV_PEND;
|
||||
|
||||
|
||||
GrpCircleVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr);
|
||||
GrpCircleVetting(RsGcxs* const circles, PgpAuxUtils *pgpUtils);
|
||||
virtual ~GrpCircleVetting();
|
||||
bool expired();
|
||||
virtual int getType() const = 0;
|
||||
|
@ -257,14 +256,16 @@ protected:
|
|||
private:
|
||||
|
||||
RsGcxs* const mCircles;
|
||||
RsNxsNetMgr* const mNetMgr;
|
||||
PgpAuxUtils *mPgpUtils;
|
||||
time_t mTimeStamp;
|
||||
};
|
||||
|
||||
class GrpCircleIdRequestVetting : public GrpCircleVetting
|
||||
{
|
||||
public:
|
||||
GrpCircleIdRequestVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr, std::vector<GrpIdCircleVet> mGrpCircleV, const RsPeerId& peerId);
|
||||
GrpCircleIdRequestVetting(RsGcxs* const circles,
|
||||
PgpAuxUtils *pgpUtils,
|
||||
std::vector<GrpIdCircleVet> mGrpCircleV, const RsPeerId& peerId);
|
||||
bool cleared();
|
||||
int getType() const;
|
||||
std::vector<GrpIdCircleVet> mGrpCircleV;
|
||||
|
@ -274,7 +275,9 @@ public:
|
|||
class MsgCircleIdsRequestVetting : public GrpCircleVetting
|
||||
{
|
||||
public:
|
||||
MsgCircleIdsRequestVetting(RsGcxs* const circles, RsNxsNetMgr* const netMgr, std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId,
|
||||
MsgCircleIdsRequestVetting(RsGcxs* const circles,
|
||||
PgpAuxUtils *auxUtils,
|
||||
std::vector<MsgIdCircleVet> msgs, const RsGxsGroupId& grpId,
|
||||
const RsPeerId& peerId, const RsGxsCircleId& circleId);
|
||||
bool cleared();
|
||||
int getType() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue