From f7a36d65a98e2918dc11bc6ede3e1a981385cc45 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 28 Nov 2013 20:53:03 +0000 Subject: [PATCH] filter out disallowed direct sources from file request source list. Should systematically prevent unwanted direct transfers git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6915 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftcontroller.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index d30817dcd..052503825 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -167,9 +167,9 @@ void ftController::addFileSource(const std::string& hash,const std::string& peer std::map::iterator it = mDownloads.find(hash); -#ifdef CONTROL_DEBUG +//#ifdef CONTROL_DEBUG std::cerr << "ftController: Adding source " << peer_id << " to current download hash=" << hash ; -#endif +//#endif if(it != mDownloads.end()) { it->second->mTransfer->addFileSource(peer_id); @@ -1133,6 +1133,20 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has } } + // remove the sources from the list, if they don't have clearance for direct transfer. This happens only for non cache files. + // + if(!(flags & RS_FILE_REQ_CACHE)) + for(std::list::iterator it = srcIds.begin(); it != srcIds.end(); ) + if(!(rsPeers->servicePermissionFlags_sslid(*it) & RS_SERVICE_PERM_DIRECT_DL)) + { + std::list::iterator tmp(it) ; + ++tmp ; + srcIds.erase(it) ; + it = tmp ; + } + else + ++it ; + std::list::const_iterator it; std::list::const_iterator pit; @@ -1213,6 +1227,7 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has } } /******* UNLOCKED ********/ + if(!(flags & RS_FILE_REQ_NO_SEARCH)) { /* do a source search - for any extra sources */