mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 09:26:18 -05:00
fixed bug that prevented banned/old IP cleaning. Now it works fine.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8292 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
cbdadfb3bf
commit
79882695b7
@ -274,14 +274,13 @@ bool p3PeerMgrIMPL::setOwnVisState(uint16_t vs_disc, uint16_t vs_dht)
|
|||||||
|
|
||||||
void p3PeerMgrIMPL::tick()
|
void p3PeerMgrIMPL::tick()
|
||||||
{
|
{
|
||||||
|
|
||||||
static const time_t INTERVAL_BETWEEN_LOCATION_CLEANING = 600 ; // Remove unused locations and clean IPs every 10 minutes.
|
static const time_t INTERVAL_BETWEEN_LOCATION_CLEANING = 600 ; // Remove unused locations and clean IPs every 10 minutes.
|
||||||
|
|
||||||
static time_t last_friends_check = time(NULL) + INTERVAL_BETWEEN_LOCATION_CLEANING; // first cleaning after 1 hour.
|
static time_t last_friends_check = time(NULL) ; // first cleaning after 1 hour.
|
||||||
|
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
|
|
||||||
if(now - last_friends_check > INTERVAL_BETWEEN_LOCATION_CLEANING)
|
if(now > INTERVAL_BETWEEN_LOCATION_CLEANING + last_friends_check )
|
||||||
{
|
{
|
||||||
#ifdef PEER_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgrIMPL::tick(): cleaning unused locations." << std::endl ;
|
std::cerr << "p3PeerMgrIMPL::tick(): cleaning unused locations." << std::endl ;
|
||||||
@ -2217,7 +2216,7 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::getAssociatedPeers() for id : " << gpg_id << std::endl;
|
std::cerr << "p3PeerMgr::getAssociatedPeers() for id : " << gpg_id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2230,7 +2229,7 @@ bool p3PeerMgrIMPL::getAssociatedPeers(const RsPgpId &gpg_id, std::list<RsPeerId
|
|||||||
count++;
|
count++;
|
||||||
ids.push_back(it->first);
|
ids.push_back(it->first);
|
||||||
|
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::getAssociatedPeers() found ssl id : " << it->first << std::endl;
|
std::cerr << "p3PeerMgr::getAssociatedPeers() found ssl id : " << it->first << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2249,12 +2248,12 @@ static bool cleanIpList(std::list<pqiIpAddress>& lst,const RsPeerId& pid,p3LinkM
|
|||||||
|
|
||||||
for(std::list<pqiIpAddress>::iterator it2(lst.begin());it2 != lst.end();)
|
for(std::list<pqiIpAddress>::iterator it2(lst.begin());it2 != lst.end();)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "Checking IP address " << sockaddr_storage_iptostring( (*it2).mAddr) << " for peer " << pid << ", age = " << now - (*it2).mSeenTime << std::endl;
|
std::cerr << "Checking IP address " << sockaddr_storage_iptostring( (*it2).mAddr) << " for peer " << pid << ", age = " << now - (*it2).mSeenTime << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if(!link_mgr->checkPotentialAddr( (*it2).mAddr,now - (*it2).mSeenTime))
|
if(!link_mgr->checkPotentialAddr( (*it2).mAddr,now - (*it2).mSeenTime))
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << " ==> Removing Banned/old IP address " << sockaddr_storage_iptostring( (*it2).mAddr) << " from peer " << pid << ", age = " << now - (*it2).mSeenTime << std::endl;
|
std::cerr << " ==> Removing Banned/old IP address " << sockaddr_storage_iptostring( (*it2).mAddr) << " from peer " << pid << ", age = " << now - (*it2).mSeenTime << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2279,12 +2278,12 @@ bool p3PeerMgrIMPL::removeBannedIps()
|
|||||||
bool changed = false ;
|
bool changed = false ;
|
||||||
for( std::map<RsPeerId, peerState>::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it)
|
for( std::map<RsPeerId, peerState>::iterator it = mFriendList.begin(); it != mFriendList.end(); ++it)
|
||||||
{
|
{
|
||||||
changed = changed || cleanIpList(it->second.ipAddrs.mExt.mAddrs,it->first,mLinkMgr) ;
|
if(cleanIpList(it->second.ipAddrs.mExt.mAddrs,it->first,mLinkMgr)) changed = true ;
|
||||||
changed = changed || cleanIpList(it->second.ipAddrs.mLocal.mAddrs,it->first,mLinkMgr) ;
|
if(cleanIpList(it->second.ipAddrs.mLocal.mAddrs,it->first,mLinkMgr)) changed = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = changed || cleanIpList(mOwnState.ipAddrs.mExt.mAddrs,mOwnState.id,mLinkMgr) ;
|
if(cleanIpList(mOwnState.ipAddrs.mExt.mAddrs,mOwnState.id,mLinkMgr) ) changed = true ;
|
||||||
changed = changed || cleanIpList(mOwnState.ipAddrs.mLocal.mAddrs,mOwnState.id,mLinkMgr) ;
|
if(cleanIpList(mOwnState.ipAddrs.mLocal.mAddrs,mOwnState.id,mLinkMgr) ) changed = true ;
|
||||||
|
|
||||||
if(changed)
|
if(changed)
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
@ -2310,7 +2309,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef PEER_DEBUG
|
||||||
std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl;
|
std::cerr << "p3PeerMgr::removeUnusedLocations()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2323,7 +2322,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||||||
{
|
{
|
||||||
toRemove.push_back(it->first);
|
toRemove.push_back(it->first);
|
||||||
|
|
||||||
#ifdef P3PEERS_DEBUG
|
#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
|
#endif
|
||||||
|
|
||||||
@ -2333,7 +2332,7 @@ bool p3PeerMgrIMPL::removeUnusedLocations()
|
|||||||
// {
|
// {
|
||||||
// toRemove.push_back(it->first);
|
// toRemove.push_back(it->first);
|
||||||
//
|
//
|
||||||
//#ifdef P3PEERS_DEBUG
|
//#ifdef PEER_DEBUG
|
||||||
// std::cerr << "p3PeerMgr::removeUnusedLocations() removing Dummy Id: " << it->first << std::endl;
|
// std::cerr << "p3PeerMgr::removeUnusedLocations() removing Dummy Id: " << it->first << std::endl;
|
||||||
//#endif
|
//#endif
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user