added option whether to trust friend nodes for banned files

This commit is contained in:
csoler 2018-08-19 15:52:35 +02:00
parent a2804a70ec
commit af7556610a
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
4 changed files with 49 additions and 11 deletions

View file

@ -72,6 +72,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
mLastRemoteDirSweepTS = 0 ;
mLastCleanupTime = 0 ;
mLastDataRecvTS = 0 ;
mTrustFriendNodesForBannedFiles = TRUST_FRIEND_NODES_FOR_BANNED_FILES_DEFAULT;
// This is for the transmission of data
@ -369,6 +370,14 @@ cleanup = true;
{
RsTlvKeyValue kv;
kv.key = TRUST_FRIEND_NODES_FOR_BANNED_FILES_SS;
kv.value = trustFriendNodesForBannedFiles()?"YES":"NO" ;
rskv->tlvkvs.pairs.push_back(kv);
}
{
RsTlvKeyValue kv;
kv.key = WATCH_HASH_SALT_SS;
kv.value = mLocalDirWatcher->hashSalt().toStdString();
@ -462,6 +471,10 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
{
setWatchEnabled(kit->value == "YES") ;
}
else if(kit->key == TRUST_FRIEND_NODES_FOR_BANNED_FILES_SS)
{
setTrustFriendNodesForBannedFiles(kit->value == "YES") ;
}
else if(kit->key == WATCH_HASH_SALT_SS)
{
std::cerr << "Initing directory watcher with saved secret salt..." << std::endl;
@ -1895,6 +1908,19 @@ bool p3FileDatabase::getPrimaryBannedFilesList(std::map<RsFileHash,BannedFileEnt
return true ;
}
bool p3FileDatabase::trustFriendNodesForBannedFiles() const
{
RS_STACK_MUTEX(mFLSMtx) ;
return mTrustFriendNodesForBannedFiles;
}
void p3FileDatabase::setTrustFriendNodesForBannedFiles(bool b)
{
if(b != mTrustFriendNodesForBannedFiles)
IndicateConfigChanged();
RS_STACK_MUTEX(mFLSMtx) ;
mTrustFriendNodesForBannedFiles = b;
}