mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added sending of banned file info
This commit is contained in:
parent
e5e566051b
commit
0b176a0fe5
@ -1415,8 +1415,8 @@ void p3FileDatabase::tickRecv()
|
||||
{
|
||||
switch(item->PacketSubType())
|
||||
{
|
||||
case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: handleDirSyncRequest( dynamic_cast<RsFileListsSyncRequestItem*>(item) ) ;
|
||||
break ;
|
||||
case RS_PKT_SUBTYPE_FILELISTS_SYNC_REQ_ITEM: handleDirSyncRequest( dynamic_cast<RsFileListsSyncRequestItem*>(item) ) ; break ;
|
||||
case RS_PKT_SUBTYPE_FILELISTS_BANNED_HASHES_ITEM : handleBannedFilesInfo( dynamic_cast<RsFileListsBannedHashesItem*>(item) ) ; break ;
|
||||
case RS_PKT_SUBTYPE_FILELISTS_SYNC_RSP_ITEM:
|
||||
{
|
||||
RsFileListsSyncResponseItem *sitem = dynamic_cast<RsFileListsSyncResponseItem*>(item);
|
||||
@ -1969,9 +1969,10 @@ void p3FileDatabase::checkSendBannedFilesInfo()
|
||||
|
||||
// Add all H(H(f)) from friends
|
||||
|
||||
for(auto it(mPeerBannedFiles.begin());it!=mPeerBannedFiles.end();++it)
|
||||
for(auto it2(it->second.mBannedHashOfHash.begin());it2!=it->second.mBannedHashOfHash.end();++it2)
|
||||
mBannedFileList.insert(*it2);
|
||||
if(mTrustFriendNodesForBannedFiles)
|
||||
for(auto it(mPeerBannedFiles.begin());it!=mPeerBannedFiles.end();++it)
|
||||
for(auto it2(it->second.mBannedHashOfHash.begin());it2!=it->second.mBannedHashOfHash.end();++it2)
|
||||
mBannedFileList.insert(*it2);
|
||||
|
||||
// Add H(f) and H(H(f)) from our primary list
|
||||
|
||||
@ -1989,10 +1990,47 @@ void p3FileDatabase::checkSendBannedFilesInfo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void p3FileDatabase::locked_sendBanInfo(const RsPeerId& peer)
|
||||
{
|
||||
#warning TODO: add code to send ban info to friends
|
||||
RsFileListsBannedHashesItem *item = NULL;
|
||||
uint32_t session_id = RSRandom::random_u32();
|
||||
|
||||
for(auto it(mPrimaryBanList.begin());it!=mPrimaryBanList.end();++it)
|
||||
{
|
||||
RsFileHash hash_of_hash ;
|
||||
|
||||
ftServer::encryptHash(it->first,hash_of_hash) ;
|
||||
|
||||
if(!item)
|
||||
{
|
||||
RsFileListsBannedHashesItem *item = new RsFileListsBannedHashesItem ;
|
||||
|
||||
item->PeerId(peer);
|
||||
item->session_id = session_id ;
|
||||
}
|
||||
|
||||
item->encrypted_hashes.insert(hash_of_hash) ;
|
||||
|
||||
if(item->encrypted_hashes.size() >= 200)
|
||||
{
|
||||
sendItem(item);
|
||||
item = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
if(item)
|
||||
sendItem(item);
|
||||
}
|
||||
|
||||
|
||||
void p3FileDatabase::handleBannedFilesInfo(RsFileListsBannedHashesItem *item)
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
|
||||
// 1 - localize the friend in the banned file map
|
||||
|
||||
// 2 - replace/update the list, depending on the session_id
|
||||
|
||||
// 3 - tell the updater that the banned file list has changed
|
||||
#warning missing code here!
|
||||
}
|
||||
|
@ -62,13 +62,14 @@ class LocalDirectoryStorage ;
|
||||
|
||||
class RsFileListsSyncRequestItem ;
|
||||
class RsFileListsSyncResponseItem ;
|
||||
class RsFileListsBannedHashesItem ;
|
||||
|
||||
class HashStorage ;
|
||||
|
||||
struct PeerBannedFilesEntry
|
||||
{
|
||||
std::set<RsFileHash> mBannedHashOfHash;
|
||||
uint32_t mRecordNumber ; // used for when a friend sends multiple packets in separate items.
|
||||
uint32_t mSessionId ; // used for when a friend sends multiple packets in separate items.
|
||||
time_t mLastSent;
|
||||
};
|
||||
|
||||
@ -260,7 +261,7 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
||||
time_t mLastCleanupTime;
|
||||
time_t mLastDataRecvTS ;
|
||||
|
||||
// file filtering. Not explicitly related to shared files, but
|
||||
// file filtering. Not explicitly related to shared files, but has its place here
|
||||
//
|
||||
|
||||
std::map<RsFileHash,BannedFileEntry> mPrimaryBanList ; // primary list (user controlled) of files banned from FT search and forwarding. map<real hash, BannedFileEntry>
|
||||
@ -270,5 +271,6 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
||||
bool mBannedFilesChanged;
|
||||
|
||||
void locked_sendBanInfo(const RsPeerId& pid);
|
||||
void handleBannedFilesInfo(RsFileListsBannedHashesItem *item);
|
||||
};
|
||||
|
||||
|
@ -43,6 +43,7 @@ void RsFileListsSyncResponseItem::serial_process(RsGenericSerializer::SerializeJ
|
||||
}
|
||||
void RsFileListsBannedHashesItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,session_id ,"session_id") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,encrypted_hashes,"encrypted_hashes") ;
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,7 @@ public:
|
||||
virtual void clear() { encrypted_hashes.clear(); }
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
|
||||
|
||||
uint32_t session_id ; // used to allow to send in multiple parts.
|
||||
std::set<RsFileHash> encrypted_hashes ;// hash of hash for each banned file.
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user