added some security checks to turtle router

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2208 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-02-05 22:45:52 +00:00
parent b47762cf12
commit 3e921bb254

View File

@ -367,9 +367,18 @@ void p3turtle::locked_closeTunnel(TurtleTunnelId tid)
std::cerr << " Associated file source." << std::endl ;
#endif
_ft_controller->removeFileSource(hash,vpid) ;
// Let's be cautious. Normally we should never be here without consistent information,
// but still, this happens, rarely.
//
if(_virtual_peers.find(vpid) != _virtual_peers.end())
_virtual_peers.erase(_virtual_peers.find(vpid)) ;
std::vector<TurtleTunnelId>& tunnels(_incoming_file_hashes[hash].tunnels) ;
std::map<TurtleFileHash,TurtleFileHashInfo>::iterator it(_incoming_file_hashes.find(hash)) ;
if(it != _incoming_file_hashes.end())
{
std::vector<TurtleTunnelId>& tunnels(it->second.tunnels) ;
// Remove tunnel id from it's corresponding hash. For security we
// go through the whole tab, although the tunnel id should only be listed once
@ -384,11 +393,13 @@ void p3turtle::locked_closeTunnel(TurtleTunnelId tid)
else
++i ;
}
}
else if(it->second.local_dst == mConnMgr->getOwnId()) // This is a ending tunnel. We also remove the virtual peer id
{
#ifdef P3TURTLE_DEBUG
std::cerr << " Tunnel is a ending point. Also removing associated outgoing hash." ;
#endif
if(_outgoing_file_hashes.find(it->second.hash) != _outgoing_file_hashes.end())
_outgoing_file_hashes.erase(_outgoing_file_hashes.find(it->second.hash)) ;
}