mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 22:55:04 -04:00
merged with upstream/master
This commit is contained in:
commit
9ddef9e45b
59 changed files with 1234 additions and 303 deletions
|
@ -768,7 +768,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
|
|||
#endif
|
||||
}
|
||||
}
|
||||
RsServer::notify()->notifyChatLobbyEvent(item->lobby_id,item->event_type,item->signature.keyId.toStdString(),item->string1) ;
|
||||
RsServer::notify()->notifyChatLobbyEvent(item->lobby_id,item->event_type,item->signature.keyId,item->string1) ;
|
||||
}
|
||||
void DistributedChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& visible_lobbies)
|
||||
{
|
||||
|
@ -1834,7 +1834,7 @@ void DistributedChatService::cleanLobbyCaches()
|
|||
|
||||
// update the gui
|
||||
for(std::list<ChatLobbyId>::const_iterator it(changed_lobbies.begin());it!=changed_lobbies.end();++it)
|
||||
RsServer::notify()->notifyChatLobbyEvent(*it,RS_CHAT_LOBBY_EVENT_KEEP_ALIVE,"","") ;
|
||||
RsServer::notify()->notifyChatLobbyEvent(*it,RS_CHAT_LOBBY_EVENT_KEEP_ALIVE,RsGxsId(),"") ;
|
||||
|
||||
// send connection challenges
|
||||
//
|
||||
|
|
|
@ -1141,9 +1141,17 @@ void p3GRouter::locked_collectAvailableFriends(const GRouterKeyId& gxs_id,const
|
|||
|
||||
for(uint32_t i=0;i<tmp_peers.size();++i)
|
||||
if(incoming_routes.find(tmp_peers[i]) != incoming_routes.end())
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " removing " << tmp_peers[i] << " which is an incoming route" << std::endl;
|
||||
#endif
|
||||
}
|
||||
else if(probas[i] < RS_GROUTER_PROBABILITY_THRESHOLD_BEST_PEERS_SELECT*max_probability)
|
||||
{
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " removing " << tmp_peers[i] << " because probability is below best peers threshold" << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_peers[count] = tmp_peers[i] ;
|
||||
|
@ -1200,7 +1208,9 @@ void p3GRouter::locked_collectAvailableFriends(const GRouterKeyId& gxs_id,const
|
|||
uint32_t real_dupl = std::min( duplication_factor - max_count+1,std::max(1u,uint32_t(rint(ideal_dupl)))) ;
|
||||
duplication_factor_delta = real_dupl - ideal_dupl ;
|
||||
|
||||
#ifdef GROUTER_DEBUG
|
||||
std::cerr << " Peer " << mypairs[i].second << " prob=" << mypairs[i].first << ", ideal_dupl=" << ideal_dupl << ", real=" << real_dupl << ". Delta = " << duplication_factor_delta << std::endl;
|
||||
#endif
|
||||
|
||||
friend_peers_and_duplication_factors[ mypairs[i].second ] = real_dupl ; // should be updated correctly
|
||||
}
|
||||
|
|
|
@ -950,6 +950,7 @@ int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||
cv.put(KEY_GRP_ORIGINATOR, grpMetaPtr->mOriginator.toStdString());
|
||||
cv.put(KEY_GRP_AUTHEN_FLAGS, (int32_t)grpMetaPtr->mAuthenFlags);
|
||||
cv.put(KEY_NXS_HASH, grpMetaPtr->mHash.toStdString());
|
||||
cv.put(KEY_RECV_TS, (int32_t)grpMetaPtr->mRecvTS);
|
||||
cv.put(KEY_NXS_IDENTITY, grpMetaPtr->mAuthorId.toStdString());
|
||||
|
||||
offset = 0;
|
||||
|
|
|
@ -2013,8 +2013,12 @@ void RsGenExchange::publishMsgs()
|
|||
grpId = msg->grpId;
|
||||
msg->metaData->recvTS = time(NULL);
|
||||
|
||||
mRoutingClues[msg->metaData->mAuthorId].insert(rsPeers->getOwnId()) ;
|
||||
mTrackingClues.push_back(std::make_pair(msg->msgId,rsPeers->getOwnId())) ;
|
||||
// FIXTESTS global variable rsPeers not available in unittests!
|
||||
if(rsPeers)
|
||||
{
|
||||
mRoutingClues[msg->metaData->mAuthorId].insert(rsPeers->getOwnId()) ;
|
||||
mTrackingClues.push_back(std::make_pair(msg->msgId,rsPeers->getOwnId())) ;
|
||||
}
|
||||
|
||||
computeHash(msg->msg, msg->metaData->mHash);
|
||||
mDataAccess->addMsgData(msg);
|
||||
|
@ -2327,7 +2331,6 @@ void RsGenExchange::publishGrps()
|
|||
{
|
||||
grp->metaData = new RsGxsGrpMetaData();
|
||||
grpItem->meta.mPublishTs = time(NULL);
|
||||
//grpItem->meta.mParentGrpId = std::string("empty");
|
||||
*(grp->metaData) = grpItem->meta;
|
||||
|
||||
// TODO: change when publish key optimisation added (public groups don't have publish key
|
||||
|
@ -2797,13 +2800,17 @@ void RsGenExchange::processRecvdGroups()
|
|||
std::cerr << "Group routage info: Identity=" << meta->mAuthorId << " from " << grp->PeerId() << std::endl;
|
||||
#endif
|
||||
|
||||
if(!meta->mAuthorId.isNull())
|
||||
if(!meta->mAuthorId.isNull())
|
||||
mRoutingClues[meta->mAuthorId].insert(grp->PeerId()) ;
|
||||
|
||||
// This has been moved here (as opposed to inside part for new groups below) because it is used to update the server TS when updates
|
||||
// of grp metadata arrive.
|
||||
|
||||
meta->mRecvTS = time(NULL);
|
||||
|
||||
// now check if group already existss
|
||||
if(std::find(existingGrpIds.begin(), existingGrpIds.end(), grp->grpId) == existingGrpIds.end())
|
||||
{
|
||||
meta->mRecvTS = time(NULL);
|
||||
if(meta->mCircleType == GXS_CIRCLE_TYPE_YOUREYESONLY)
|
||||
meta->mOriginator = grp->PeerId();
|
||||
|
||||
|
@ -2919,6 +2926,11 @@ void RsGenExchange::performUpdateValidation()
|
|||
if(gu.newGrp->metaData->mCircleType == GXS_CIRCLE_TYPE_YOUREYESONLY)
|
||||
gu.newGrp->metaData->mOriginator = gu.newGrp->PeerId();
|
||||
|
||||
// Keep subscriptionflag to what it was. This avoids clearing off the flag when updates to group meta information
|
||||
// is received.
|
||||
|
||||
gu.newGrp->metaData->mSubscribeFlags = gu.oldGrpMeta->mSubscribeFlags ;
|
||||
|
||||
grps.insert(std::make_pair(gu.newGrp, gu.newGrp->metaData));
|
||||
}
|
||||
else
|
||||
|
@ -2930,6 +2942,18 @@ void RsGenExchange::performUpdateValidation()
|
|||
}
|
||||
|
||||
mDataStore->updateGroup(grps);
|
||||
|
||||
// notify the client
|
||||
|
||||
RsGxsGroupChange* c = new RsGxsGroupChange(RsGxsNotify::TYPE_RECEIVE, true);
|
||||
|
||||
for(uint32_t i=0;i<mGroupUpdates.size();++i)
|
||||
c->mGrpIdList.push_back(mGroupUpdates[i].oldGrpMeta->mGroupId) ;
|
||||
|
||||
mNotifications.push_back(c);
|
||||
|
||||
// cleanup
|
||||
|
||||
mGroupUpdates.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -512,6 +512,13 @@ public:
|
|||
|
||||
static float computeCurrentSendingProbability()
|
||||
{
|
||||
// FIXTESTS global variable rsConfig not available in unittests!
|
||||
if(rsConfig == 0)
|
||||
{
|
||||
std::cerr << "computeCurrentSendingProbability(): rsConfig not initialised, returning 1.0"<<std::endl;
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
int maxIn=50,maxOut=50;
|
||||
float currIn=0,currOut=0 ;
|
||||
|
||||
|
@ -1920,19 +1927,15 @@ void RsGxsNetService::updateServerSyncTS()
|
|||
// retrieve all grps and update TS
|
||||
mDataStore->retrieveGxsGrpMetaData(gxsMap);
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
// (cyril) This code is removed because it is inconsistent: the list of grps does not need to be updated when
|
||||
// new posts arrive. The two (grp list and msg list) are handled independently.
|
||||
// (cyril) This code was previously removed because it sounded inconsistent: the list of grps normally does not need to be updated when
|
||||
// new posts arrive. The two (grp list and msg list) are handled independently. Still, when group meta data updates are received,
|
||||
// the server TS needs to be updated, because it is the only way to propagate the changes. So we update it to the publish time stamp,
|
||||
// if needed.
|
||||
|
||||
// as a grp list server also note this is the latest item you have
|
||||
if(mGrpServerUpdateItem == NULL)
|
||||
mGrpServerUpdateItem = new RsGxsServerGrpUpdateItem(mServType);
|
||||
|
||||
// First reset it. That's important because it will re-compute correct TS in case
|
||||
// we have unsubscribed a group.
|
||||
|
||||
mGrpServerUpdateItem->grpUpdateTS = 0 ;
|
||||
#endif
|
||||
bool change = false;
|
||||
|
||||
// then remove from mServerMsgUpdateMap, all items that are not in the group list!
|
||||
|
@ -2004,19 +2007,18 @@ void RsGxsNetService::updateServerSyncTS()
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
// This might be very inefficient with time. This is needed because an old message might have been received, so the last modification time
|
||||
// needs to account for this so that a friend who hasn't
|
||||
// This is needed for group metadata updates to actually propagate: only a new grpUpdateTS will trigger the exchange of groups mPublishTs which
|
||||
// will then be compared and pssibly trigger a MetaData transmission. mRecvTS is upated when creating, receiving for the first time, or receiving
|
||||
// an update, all in rsgenexchange.cc, after group/update validation. It is therefore a local TS, that can be compared to grpUpdateTS (same machine).
|
||||
|
||||
if(mGrpServerUpdateItem->grpUpdateTS < grpMeta->mRecvTS)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last RecvTS = " << time(NULL) - grpMeta->mRecvTS << " secs ago for group "<< grpId << std::endl;
|
||||
GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last RecvTS = " << time(NULL) - grpMeta->mRecvTS << " secs ago for group "<< grpId << ". This is probably because an update has been received." << std::endl;
|
||||
#endif
|
||||
mGrpServerUpdateItem->grpUpdateTS = grpMeta->mRecvTS;
|
||||
change = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// actual change in config settings, then save configuration
|
||||
|
@ -2828,8 +2830,9 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if(rsReputations->isIdentityBanned(syncItem->authorId))
|
||||
// FIXTESTS global variable rsReputations not available in unittests!
|
||||
if(rsReputations == 0){ std::cerr << "rsReputations==0, accepting all messages!" << std::endl; }
|
||||
if(rsReputations && rsReputations->isIdentityBanned(syncItem->authorId))
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", Identity " << syncItem->authorId << " is banned. Not requesting message!" << std::endl;
|
||||
|
@ -3072,8 +3075,9 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
haveItem = true;
|
||||
latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs;
|
||||
}
|
||||
|
||||
if(!grpSyncItem->authorId.isNull() && rsReputations->isIdentityBanned(grpSyncItem->authorId))
|
||||
// FIXTESTS global variable rsReputations not available in unittests!
|
||||
if(rsReputations == 0){ std::cerr << "rsReputations==0, accepting all groups!" << std::endl; }
|
||||
if(!grpSyncItem->authorId.isNull() && rsReputations && rsReputations->isIdentityBanned(grpSyncItem->authorId))
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl;
|
||||
|
|
|
@ -334,6 +334,13 @@ static int initLib = 0;
|
|||
sslctx = SSL_CTX_new(SSLv23_method());
|
||||
SSL_CTX_set_options(sslctx,SSL_OP_NO_SSLv3) ;
|
||||
|
||||
//SSL_OP_SINGLE_DH_USE CVE-2016-0701
|
||||
//https://www.openssl.org/docs/manmaster/ssl/SSL_CTX_set_options.html
|
||||
//If "strong" primes were used, it is not strictly necessary to generate a new DH key during each handshake but it is also recommended. SSL_OP_SINGLE_DH_USE should therefore be enabled whenever temporary/ephemeral DH parameters are used.
|
||||
//SSL_CTX_set_options() adds the options set via bitmask in options to ctx. Options already set before are not cleared!
|
||||
SSL_CTX_set_options(sslctx,SSL_OP_SINGLE_DH_USE) ;
|
||||
|
||||
|
||||
// Setup cipher lists:
|
||||
//
|
||||
// std::string cipherString = "HIGH:!DSS:!aNULL:!3DES";
|
||||
|
|
|
@ -217,7 +217,7 @@ bool p3Notify::ClearFeedItems(uint32_t type)
|
|||
|
||||
#define FOR_ALL_NOTIFY_CLIENTS for(std::list<NotifyClient*>::const_iterator it(notifyClients.begin());it!=notifyClients.end();++it)
|
||||
|
||||
void p3Notify::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type,const std::string& nickname,const std::string& any_string) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatLobbyEvent(lobby_id,event_type,nickname,any_string) ; }
|
||||
void p3Notify::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type,const RsGxsId& nickname,const std::string& any_string) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatLobbyEvent(lobby_id,event_type,nickname,any_string) ; }
|
||||
|
||||
void p3Notify::notifyListPreChange(int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListPreChange(list,type) ; }
|
||||
void p3Notify::notifyListChange (int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListChange (list,type) ; }
|
||||
|
@ -239,10 +239,7 @@ void p3Notify::notifyGxsChange (const RsGxsChanges& changes) {FOR_A
|
|||
|
||||
void p3Notify::notifyPeerStatusChangedSummary () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChangedSummary() ; }
|
||||
void p3Notify::notifyDiscInfoChanged () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiscInfoChanged () ; }
|
||||
#ifdef REMOVE
|
||||
void p3Notify::notifyForumMsgReadSatusChanged (const std::string& channelId, const std::string& msgId, uint32_t status) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyForumMsgReadSatusChanged (channelId,msgId,status) ; }
|
||||
void p3Notify::notifyChannelMsgReadSatusChanged (const std::string& channelId, const std::string& msgId, uint32_t status) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChannelMsgReadSatusChanged (channelId,msgId,status) ; }
|
||||
#endif
|
||||
|
||||
void p3Notify::notifyDownloadComplete (const std::string& fileHash ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDownloadComplete (fileHash) ; }
|
||||
void p3Notify::notifyDownloadCompleteCount (uint32_t count ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDownloadCompleteCount (count) ; }
|
||||
void p3Notify::notifyHistoryChanged (uint32_t msgId , int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyHistoryChanged (msgId,type) ; }
|
||||
|
|
|
@ -100,7 +100,7 @@ class p3Notify: public RsNotify
|
|||
void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) ;
|
||||
void notifyChatMessage (const ChatMessage& /* msg */) ;
|
||||
void notifyChatStatus (const ChatId& /* chat_id */, const std::string& /* status_string */) ;
|
||||
void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const std::string& /* nickname */,const std::string& /* any string */) ;
|
||||
void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ , const RsGxsId & /* nickname */, const std::string& /* any string */) ;
|
||||
void notifyChatLobbyTimeShift (int /* time_shift*/) ;
|
||||
void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) ;
|
||||
void notifyHashingInfo (uint32_t /* type */, const std::string& /* fileinfo */) ;
|
||||
|
@ -114,10 +114,7 @@ class p3Notify: public RsNotify
|
|||
|
||||
void notifyPeerStatusChangedSummary () ;
|
||||
void notifyDiscInfoChanged () ;
|
||||
#ifdef REMOVE
|
||||
void notifyForumMsgReadSatusChanged (const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) ;
|
||||
void notifyChannelMsgReadSatusChanged (const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) ;
|
||||
#endif
|
||||
|
||||
bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result ) ;
|
||||
void notifyDownloadComplete (const std::string& /* fileHash */) ;
|
||||
void notifyDownloadCompleteCount (uint32_t /* count */) ;
|
||||
|
|
|
@ -64,8 +64,6 @@ const uint32_t MIN_TIME_BETWEEN_NET_RESET = 5;
|
|||
|
||||
const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 4;
|
||||
|
||||
#define VERY_OLD_PEER (90 * 24 * 3600) // 90 days.
|
||||
|
||||
/****
|
||||
* #define PEER_DEBUG 1
|
||||
***/
|
||||
|
@ -2734,10 +2732,51 @@ bool p3PeerMgrIMPL::removeBannedIps()
|
|||
// return ret;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @brief p3PeerMgrIMPL::removeUnusedLocations Removes all location offline for RS_PEER_OFFLINE_DELETE seconds or more. Keeps the most recent location per PGP id.
|
||||
* @return true on success
|
||||
*
|
||||
* This function removes all location that are offline for too long defined by RS_PEER_OFFLINE_DELETE.
|
||||
* It also makes sure that at least one location (the most recent) is kept.
|
||||
*
|
||||
* The idea of the function is the following:
|
||||
* - keep track if there is at least one location per PGP id that is not offline for too long
|
||||
* -> hasRecentLocation
|
||||
* - keep track of most recent location per PGP id that is offline for too long (and its time stamp)
|
||||
* -> mostRecentLocation
|
||||
* -> mostRecentTime
|
||||
*
|
||||
* When a location is found that is offline for too long the following points are checked from the top to the bottom:
|
||||
* 1) remove it when the PGP id has a location that is not offline for too long
|
||||
* 2) remove it when the PGP id has a more recent location
|
||||
* 3) keep it when it is the most recent location
|
||||
* This location will possibly be removed when a more recent (but still offline for too long) is found
|
||||
*/
|
||||
bool p3PeerMgrIMPL::removeUnusedLocations()
|
||||
{
|
||||
std::list<RsPeerId> toRemove;
|
||||
|
||||
std::map<RsPgpId, bool> hasRecentLocation;
|
||||
std::map<RsPgpId, time_t> mostRecentTime;
|
||||
std::map<RsPgpId, RsPeerId> mostRecentLocation;
|
||||
|
||||
// init maps
|
||||
{
|
||||
std::list<RsPgpId> pgpList;
|
||||
|
||||
if(!rsPeers->getGPGAcceptedList(pgpList))
|
||||
return false;
|
||||
|
||||
std::list<RsPgpId>::iterator it;
|
||||
for(it = pgpList.begin(); it != pgpList.end(); ++it)
|
||||
{
|
||||
hasRecentLocation[*it] = false;
|
||||
mostRecentTime[*it] = (time_t)0;
|
||||
}
|
||||
}
|
||||
|
||||
const time_t now = time(NULL);
|
||||
RsPgpId pgpID;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
@ -2746,19 +2785,71 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||
std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl;
|
||||
#endif
|
||||
|
||||
time_t now = time(NULL);
|
||||
|
||||
std::map<RsPeerId, peerState>::iterator it;
|
||||
for(it = mFriendList.begin(); it != mFriendList.end(); ++it)
|
||||
{
|
||||
if (now - it->second.lastcontact > VERY_OLD_PEER)
|
||||
{
|
||||
toRemove.push_back(it->first);
|
||||
pgpID = it->second.gpg_id;
|
||||
|
||||
// store some references to speed up accessing
|
||||
RsPeerId &idRef = mostRecentLocation[pgpID];
|
||||
bool &recentRef = hasRecentLocation[pgpID];
|
||||
|
||||
if (now > it->second.lastcontact + RS_PEER_OFFLINE_DELETE)
|
||||
{
|
||||
// location is too old
|
||||
if(recentRef)
|
||||
{
|
||||
// there is already one location that won't get removed
|
||||
// -> we can safely remove this one
|
||||
toRemove.push_back(it->first);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeUnusedLocations() removing Old SSL Id: " << it->first << std::endl;
|
||||
std::cerr << "p3PeerMgr::removeUnusedLocations() removing Old SSL Id: " << it->first << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// we need to take care that the most recent location it not removed
|
||||
time_t &timeRef = mostRecentTime[pgpID];
|
||||
|
||||
if(timeRef > it->second.lastcontact)
|
||||
{
|
||||
// this (it) location is longer offline compared to mostRecentLocation
|
||||
// -> we can remove this one
|
||||
toRemove.push_back(it->first);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeUnusedLocations() removing Old SSL Id: " << it->first << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// this (it) location is more recent compared to mostRecentLocation
|
||||
// -> we can remove mostRecentLocation
|
||||
if(!idRef.isNull())
|
||||
{
|
||||
toRemove.push_back(idRef);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeUnusedLocations() removing Old SSL Id: " << it->first << std::endl;
|
||||
#endif
|
||||
}
|
||||
// update maps
|
||||
idRef = it->first;
|
||||
timeRef = it->second.lastcontact;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// found a location that won't get removed
|
||||
recentRef = true;
|
||||
|
||||
// we can remove mostRecentLocation if it is set
|
||||
if(!idRef.isNull())
|
||||
{
|
||||
toRemove.push_back(idRef);
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgr::removeUnusedLocations() removing Old SSL Id: " << it->first << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// if (isDummyFriend(it->first))
|
||||
|
@ -2773,11 +2864,11 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||
|
||||
}
|
||||
}
|
||||
std::list<RsPeerId>::iterator it;
|
||||
|
||||
|
||||
std::list<RsPeerId>::iterator it;
|
||||
for(it = toRemove.begin(); it != toRemove.end(); ++it)
|
||||
{
|
||||
removeFriend(*it,false);
|
||||
removeFriend(*it, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -65,6 +65,13 @@ const uint32_t RS_NET_FLAGS_EXTERNAL_ADDR = 0x0008;
|
|||
const uint32_t RS_NET_FLAGS_STABLE_UDP = 0x0010;
|
||||
const uint32_t RS_NET_FLAGS_TRUSTS_ME = 0x0020;
|
||||
|
||||
/*
|
||||
* remove locations offline since 90 days
|
||||
* stopt sending locations via discovery when offline for +30 days
|
||||
*/
|
||||
const time_t RS_PEER_OFFLINE_DELETE = (90 * 24 * 3600);
|
||||
const time_t RS_PEER_OFFLINE_NO_DISC = (30 * 24 * 3600);
|
||||
|
||||
class peerState
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -212,7 +212,7 @@ class NotifyClient
|
|||
virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {}
|
||||
virtual void notifyChatMessage (const ChatMessage& /* msg */) {}
|
||||
virtual void notifyChatStatus (const ChatId& /* chat_id */, const std::string& /* status_string */) {}
|
||||
virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const std::string& /* nickname */,const std::string& /* any string */) {}
|
||||
virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const RsGxsId& /* nickname */,const std::string& /* any string */) {}
|
||||
virtual void notifyChatLobbyTimeShift (int /* time_shift*/) {}
|
||||
virtual void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) {}
|
||||
virtual void notifyHashingInfo (uint32_t /* type */, const std::string& /* fileinfo */) {}
|
||||
|
@ -227,10 +227,7 @@ class NotifyClient
|
|||
/* one or more peers has changed the states */
|
||||
virtual void notifyPeerStatusChangedSummary () {}
|
||||
virtual void notifyDiscInfoChanged () {}
|
||||
#ifdef REMOVE
|
||||
virtual void notifyForumMsgReadSatusChanged (const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) {}
|
||||
virtual void notifyChannelMsgReadSatusChanged (const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) {}
|
||||
#endif
|
||||
|
||||
virtual bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result ) { signature_result = false ;return true; }
|
||||
virtual void notifyDownloadComplete (const std::string& /* fileHash */) {}
|
||||
virtual void notifyDownloadCompleteCount (uint32_t /* count */) {}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "services/p3discovery2.h"
|
||||
#include "pqi/p3peermgr.h"
|
||||
#include "util/rsversioninfo.h"
|
||||
|
||||
#include "retroshare/rsiface.h"
|
||||
|
@ -930,7 +931,10 @@ void p3discovery2::processContactInfo(const SSLID &fromId, const RsDiscContactIt
|
|||
// We pass RS_NODE_PERM_ALL because the PGP id is already a friend, so we should keep the existing
|
||||
// permission flags. Therefore the mask needs to be 0xffff.
|
||||
|
||||
mPeerMgr->addFriend(item->sslId, item->pgpId, item->netMode, RS_VS_DISC_OFF, RS_VS_DHT_FULL,(time_t)0,RS_NODE_PERM_ALL);
|
||||
// set last seen to RS_PEER_OFFLINE_NO_DISC minus 1 so that it won't be shared with other friends
|
||||
// until a first connection is established
|
||||
|
||||
mPeerMgr->addFriend(item->sslId, item->pgpId, item->netMode, RS_VS_DISC_OFF, RS_VS_DHT_FULL, time(NULL) - RS_PEER_OFFLINE_NO_DISC - 1, RS_NODE_PERM_ALL);
|
||||
updatePeerAddresses(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,7 +353,18 @@ bool p3GxsChannels::getPostData(const uint32_t &token, std::vector<RsGxsChannelP
|
|||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a GxsChannelPostItem, deleting!" << std::endl;
|
||||
RsGxsCommentItem* cmt = dynamic_cast<RsGxsCommentItem*>(*vit);
|
||||
if(!cmt)
|
||||
{
|
||||
RsGxsMsgItem* msg = (*vit);
|
||||
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
|
||||
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
|
||||
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
|
||||
std::cerr << "Not a GxsChannelPostItem neither a RsGxsCommentItem"
|
||||
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
|
||||
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
|
||||
<< " , deleting!" << std::endl;
|
||||
}
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +412,18 @@ bool p3GxsChannels::getRelatedPosts(const uint32_t &token, std::vector<RsGxsChan
|
|||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a GxsChannelPostItem, deleting!" << std::endl;
|
||||
RsGxsCommentItem* cmt = dynamic_cast<RsGxsCommentItem*>(*vit);
|
||||
if(!cmt)
|
||||
{
|
||||
RsGxsMsgItem* msg = (*vit);
|
||||
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
|
||||
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
|
||||
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
|
||||
std::cerr << "Not a GxsChannelPostItem neither a RsGxsCommentItem"
|
||||
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
|
||||
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
|
||||
<< " , deleting!" << std::endl;
|
||||
}
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
|
@ -1560,7 +1582,7 @@ void p3GxsChannels::handle_event(uint32_t event_type, const std::string &elabel)
|
|||
|
||||
default:
|
||||
/* error */
|
||||
std::cerr << "p3GxsChannels::handle_event() Unknown Event Type: " << event_type;
|
||||
std::cerr << "p3GxsChannels::handle_event() Unknown Event Type: " << event_type << " elabel:" << elabel;
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ void PeerNode::provideFileHash(const RsFileHash& hash)
|
|||
void PeerNode::manageFileHash(const RsFileHash& hash)
|
||||
{
|
||||
_managed_hashes.insert(hash) ;
|
||||
_turtle->monitorTunnels(hash,_turtle_client) ;
|
||||
_turtle->monitorTunnels(hash,_turtle_client, false) ;
|
||||
}
|
||||
void PeerNode::sendToGRKey(const GRouterKeyId& key_id)
|
||||
{
|
||||
|
|
|
@ -845,13 +845,24 @@ int p3turtle::handleIncoming()
|
|||
void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
// take a look at the item:
|
||||
|
||||
// take a look at the item and test against inconsistent values
|
||||
// - If the item destimation is
|
||||
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "Received search request from peer " << item->PeerId() << ": " << std::endl ;
|
||||
item->print(std::cerr,0) ;
|
||||
#endif
|
||||
|
||||
if(item->serial_size() > TURTLE_MAX_SEARCH_REQ_ACCEPTED_SERIAL_SIZE)
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " Dropping, because the serial size exceeds the accepted limit." << std::endl ;
|
||||
#endif
|
||||
std::cerr << " Caught a turtle search item with arbitrary large size from " << item->PeerId() << " of size " << item->serial_size() << ". This is not allowed => dropping." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if(_search_requests_origins.size() > MAX_ALLOWED_SR_IN_CACHE)
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
|
|
|
@ -161,6 +161,7 @@ class ftDataMultiplex;
|
|||
class RsSerialiser;
|
||||
|
||||
static const int TURTLE_MAX_SEARCH_DEPTH = 6 ;
|
||||
static const int TURTLE_MAX_SEARCH_REQ_ACCEPTED_SERIAL_SIZE = 200 ;
|
||||
|
||||
// This class is used to keep trace of requests (searches and tunnels).
|
||||
//
|
||||
|
|
|
@ -65,7 +65,9 @@ public:
|
|||
|
||||
~RsSharedPtr()
|
||||
{
|
||||
lock();
|
||||
DecrementAndDeleteIfLast();
|
||||
unlock();
|
||||
}
|
||||
private:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue