mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Made key exchange more stable.
removed restore key function sorry introduced lock with my last commit git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3924 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
35f91f5e07
commit
5bc8e68059
@ -251,6 +251,13 @@ virtual bool channelEditInfo(std::string chId, ChannelInfo &ci) = 0;
|
||||
*/
|
||||
virtual void getPubKeysAvailableGrpIds(std::list<std::string>& chanIds) = 0;
|
||||
|
||||
/*!
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
//virtual void setPrivateChannelDir(const std::string&) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ RsChannels *rsChannels = NULL;
|
||||
/* remember 2^16 = 64K max units in store period.
|
||||
* PUBPERIOD * 2^16 = max STORE PERIOD */
|
||||
#define CHANNEL_STOREPERIOD (30*24*3600) /* 30 * 24 * 3600 - secs in a 30 day month */
|
||||
#define CHANNEL_PUBPERIOD 600 /* 10 minutes ... (max = 455 days) */
|
||||
#define CHANNEL_PUBPERIOD 120 /* 2 minutes ... (max = 455 days) */
|
||||
#define MAX_AUTO_DL 1E9 /* auto download of attachment limit; 1 GIG */
|
||||
|
||||
p3Channels::p3Channels(uint16_t type, CacheStrapper *cs,
|
||||
@ -658,9 +658,9 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
|
||||
|
||||
// tho if empty don't bother
|
||||
if(!chanMsg->attachment.items.empty()){
|
||||
getChannelInfo(grpId, cInfo);
|
||||
|
||||
if(cInfo.channelFlags & RS_DISTRIB_PRIVATE)
|
||||
|
||||
if(grp->flags & RS_DISTRIB_PRIVATE)
|
||||
chanPrivate = true;
|
||||
}
|
||||
|
||||
@ -679,7 +679,7 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
|
||||
|
||||
// send to download directory if file is private
|
||||
if(chanPrivate){
|
||||
localpath = mChannelsDir + "/" + channelname;
|
||||
localpath = mChannelsDir;
|
||||
flags = RS_FILE_HINTS_BACKGROUND | RS_FILE_HINTS_EXTRA;
|
||||
|
||||
}else{
|
||||
|
@ -79,6 +79,7 @@ virtual bool channelRestoreKeys(std::string chId);
|
||||
virtual bool channelShareKeys(std::string chId, std::list<std::string>& peers);
|
||||
virtual bool channelEditInfo(std::string chId, ChannelInfo &ci);
|
||||
virtual void getPubKeysAvailableGrpIds(std::list<std::string>& grpIds);
|
||||
//virtual void setPrivateChannelDir(const std::string dirName);
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
|
@ -96,7 +96,7 @@ int p3GroupDistrib::tick()
|
||||
|
||||
{
|
||||
RsStackMutex stack(distribMtx); /**** STACK LOCKED MUTEX ****/
|
||||
toPublish = (mPendingPublish.size() > 0) && (now > (time_t) (mPubPeriod + mLastPublishTime));
|
||||
toPublish = ((mPendingPublish.size() > 0) || (mPendingPubKeyRecipients.size() > 0)) && (now > (time_t) (mPubPeriod + mLastPublishTime));
|
||||
|
||||
}
|
||||
|
||||
@ -136,19 +136,8 @@ int p3GroupDistrib::tick()
|
||||
bool toReceive = receivedItems();
|
||||
|
||||
if(toReceive){
|
||||
RsStackMutex stack(distribMtx);
|
||||
locked_receivePubKeys();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
RsStackMutex stack(distribMtx);
|
||||
|
||||
toReceive = (mRecvdPubKeys.size() > 0) && (now > (time_t) (mPubPeriod + mLastRecvdKeyTime));
|
||||
|
||||
if(toReceive)
|
||||
locked_loadRecvdPubKeys();
|
||||
|
||||
receivePubKeys();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -513,23 +502,44 @@ void p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey)
|
||||
std::map<std::string, GroupInfo>::iterator it;
|
||||
it = mGroups.find(gid);
|
||||
|
||||
//
|
||||
if (it == mGroups.end())
|
||||
{
|
||||
|
||||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::loadGroupKey() Group Not Found - discarding Key";
|
||||
std::cerr << "p3GroupDistrib::loadGroupKey() Group Not Found - Checking to see if shared Key";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// if this is an in-date publish key then keep to see if group arrives later
|
||||
if(((time_t)(newKey->key.startTS + mStorePeriod) > time(NULL)) && !(newKey->key.keyFlags & RSTLV_KEY_DISTRIB_ADMIN))
|
||||
// if this is an in-date full publish key then keep to see if group arrives later
|
||||
if(((time_t)(newKey->key.startTS + mStorePeriod) > time(NULL)) && (newKey->key.keyFlags & RSTLV_KEY_TYPE_FULL)){
|
||||
|
||||
// make sure key does not exist
|
||||
if(mRecvdPubKeys.find(gid) == mRecvdPubKeys.end()){
|
||||
mRecvdPubKeys.insert(std::pair<std::string, RsDistribGrpKey*>(gid, newKey));
|
||||
else
|
||||
mPubKeyAvailableGrpId.push_back(gid);
|
||||
}else{
|
||||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::loadGroupKey() Key already received; discarding";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
delete newKey;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::loadGroupKey() Key out of date: discarding";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
delete newKey;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* have the group -> add in the key */
|
||||
bool updateOk = false;
|
||||
if (newKey->key.keyFlags & RSTLV_KEY_DISTRIB_ADMIN)
|
||||
@ -559,6 +569,44 @@ void p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey)
|
||||
{
|
||||
updateOk = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::map<std::string, RsDistribGrpKey* >::iterator kit;
|
||||
std::list<std::string>::iterator sit;
|
||||
bool canAdd = false;
|
||||
|
||||
// check to see if client has received a private publish key
|
||||
if(mRecvdPubKeys.end() != (kit = mRecvdPubKeys.find(gid))){
|
||||
|
||||
if(!locked_updateGroupPublishKey(it->second, kit->second)){
|
||||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::loadGroupKey() Failed Recvd Publish Key Update";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}else{
|
||||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::loadGroupKey() Recvd Publish Key Update";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
sit = mPubKeyAvailableGrpId.begin();
|
||||
for(; sit != mPubKeyAvailableGrpId.end(); sit++){
|
||||
|
||||
if(gid == *sit)
|
||||
canAdd = true;
|
||||
|
||||
}
|
||||
|
||||
if(canAdd)
|
||||
mPubKeyAvailableGrpId.push_back(gid);
|
||||
|
||||
mRecvdPubKeys.erase(gid);
|
||||
updateOk = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (updateOk)
|
||||
@ -1230,8 +1278,8 @@ bool p3GroupDistrib::subscribeToGroup(const std::string &grpId, bool subscrib
|
||||
{
|
||||
git->second.flags |= RS_DISTRIB_SUBSCRIBED;
|
||||
|
||||
if(attemptPublishKeysRecvd(git->second))
|
||||
git->second.flags |= RS_DISTRIB_PUBLISH;
|
||||
// if(attemptPublishKeysRecvd(git->second))
|
||||
// git->second.flags |= RS_DISTRIB_PUBLISH;
|
||||
|
||||
locked_notifyGroupChanged(git->second, GRP_SUBSCRIBED);
|
||||
mGroupsRepublish = true;
|
||||
@ -1252,6 +1300,7 @@ bool p3GroupDistrib::subscribeToGroup(const std::string &grpId, bool subscrib
|
||||
for(pit = git->second.sources.begin();
|
||||
pit != git->second.sources.end(); pit++)
|
||||
{
|
||||
if(*pit != mOwnId)
|
||||
locked_eventDuplicateMsg(&(git->second), mit->second, *pit);
|
||||
}
|
||||
}
|
||||
@ -2063,7 +2112,7 @@ void p3GroupDistrib::locked_sharePubKey(){
|
||||
}
|
||||
|
||||
|
||||
void p3GroupDistrib::locked_receivePubKeys(){
|
||||
void p3GroupDistrib::receivePubKeys(){
|
||||
|
||||
|
||||
RsItem* item;
|
||||
@ -2082,7 +2131,9 @@ void p3GroupDistrib::locked_receivePubKeys(){
|
||||
std::cerr << "Got key Item" << std::endl;
|
||||
#endif
|
||||
if(key_item->key.keyFlags & RSTLV_KEY_TYPE_FULL){
|
||||
mRecvdPubKeys[key_item->grpId] = key_item;
|
||||
|
||||
loadGroupKey(key_item);
|
||||
|
||||
}
|
||||
else{
|
||||
std::cerr << "p3GroupDistrib::locked_receiveKeys():" << "Not full public key"
|
||||
@ -2094,9 +2145,15 @@ void p3GroupDistrib::locked_receivePubKeys(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RsStackMutex stack(distribMtx);
|
||||
|
||||
// indicate config changed and also record the groups keys received for
|
||||
if(!mRecvdPubKeys.empty())
|
||||
IndicateConfigChanged();
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -507,11 +507,12 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
||||
/**
|
||||
* Attempt to receive publication keys
|
||||
*/
|
||||
virtual void locked_receivePubKeys();
|
||||
virtual void receivePubKeys();
|
||||
|
||||
/*!
|
||||
* utility function to check whether grps exist
|
||||
* for private publish keys received
|
||||
* @deprecated
|
||||
*/
|
||||
virtual void locked_loadRecvdPubKeys();
|
||||
|
||||
|
@ -172,8 +172,8 @@ void ChannelFeed::channelListCustomPopupMenu( QPoint point )
|
||||
QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), &contextMnu);
|
||||
connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );
|
||||
|
||||
QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
|
||||
connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );
|
||||
//QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Channel" ), &contextMnu);
|
||||
//connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreChannelKeys() ) );
|
||||
|
||||
QAction *editChannelDetailAct = new QAction(QIcon(":/images/edit_16.png"), tr("Edit Channel Details"), &contextMnu);
|
||||
connect( editChannelDetailAct, SIGNAL( triggered() ), this, SLOT( editChannelDetail() ) );
|
||||
@ -197,12 +197,12 @@ void ChannelFeed::channelListCustomPopupMenu( QPoint point )
|
||||
contextMnu.addAction( unsubscribechannelAct );
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction( channeldetailsAct );
|
||||
contextMnu.addAction( restoreKeysAct );
|
||||
// contextMnu.addAction( restoreKeysAct );
|
||||
} else {
|
||||
contextMnu.addAction( subscribechannelAct );
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction( channeldetailsAct );
|
||||
contextMnu.addAction( restoreKeysAct );
|
||||
// contextMnu.addAction( restoreKeysAct );
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
|
Loading…
Reference in New Issue
Block a user