mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 15:45:04 -04:00
added filter in p3turtle against banned hashes in tunnel requests and search results
This commit is contained in:
parent
365464623a
commit
3055897425
6 changed files with 50 additions and 0 deletions
|
@ -1109,6 +1109,27 @@ void p3turtle::performLocalSearch_files(RsTurtleFileSearchRequestItem *item,uint
|
|||
|
||||
void p3turtle::handleSearchResult(RsTurtleSearchResultItem *item)
|
||||
{
|
||||
// Filter out banned hashes from the result.
|
||||
|
||||
RsTurtleFTSearchResultItem *ftsr_tmp = dynamic_cast<RsTurtleFTSearchResultItem*>(item) ;
|
||||
|
||||
if(ftsr_tmp != NULL)
|
||||
{
|
||||
for(auto it(ftsr_tmp->result.begin());it!=ftsr_tmp->result.end();)
|
||||
if( rsFiles->isHashBanned((*it).hash) )
|
||||
{
|
||||
std::cerr << "(II) filtering out banned hash " << (*it).hash << " from turtle result " << std::hex << item->request_id << std::dec << std::endl;
|
||||
it = ftsr_tmp->result.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
|
||||
if(ftsr_tmp->result.empty())
|
||||
return ;
|
||||
}
|
||||
|
||||
// Then handle the result
|
||||
|
||||
std::list<std::pair<RsTurtleSearchResultItem*,RsTurtleClientService*> > results_to_notify_off_mutex ;
|
||||
|
||||
{
|
||||
|
@ -1525,6 +1546,16 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
|
|||
item->print(std::cerr,0) ;
|
||||
#endif
|
||||
|
||||
// check first if the hash is in the ban list. If so, drop the request.
|
||||
|
||||
if(rsFiles->isHashBanned(item->file_hash))
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "(II) Rejecting tunnel request to ban hash " << item->file_hash << std::endl;
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
|
||||
#ifdef TUNNEL_STATISTICS
|
||||
if(TS_request_bounces.find(item->request_id) != TS_request_bounces.end())
|
||||
TS_request_bounces[item->request_id].push_back(time(NULL)) ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue