added seperated limit for discovery (30 days)

This commit is contained in:
sehraf 2016-02-19 16:32:57 +01:00
parent 841299d077
commit 4140969fcb
3 changed files with 10 additions and 6 deletions

View File

@ -2749,7 +2749,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
std::map<RsPeerId, peerState>::iterator it;
for(it = mFriendList.begin(); it != mFriendList.end(); ++it)
{
if (now - it->second.lastcontact > RS_PEER_OLD_PEER)
if (now > it->second.lastcontact + RS_PEER_OFFLINE_DELETE)
{
toRemove.push_back(it->first);

View File

@ -65,8 +65,12 @@ 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 */
const time_t RS_PEER_OLD_PEER = (90 * 24 * 3600);
/*
* 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
{

View File

@ -931,10 +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.
// set last seen to RS_PEER_OLD_PEER minus 1 day so that the DHT has a fair chance to establish a connection
// before the location gets automatically removed again
// 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_OLD_PEER + (24 * 3600), RS_NODE_PERM_ALL);
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);
}
}