added default encryption policy variable and GUI to change it

This commit is contained in:
mr-alice 2016-10-29 17:59:03 +02:00
parent 8486346368
commit babc126be3
10 changed files with 183 additions and 35 deletions

View file

@ -168,13 +168,6 @@ bool DirectoryStorage::updateHash(const EntryIndex& index,const RsFileHash& hash
return mFileHierarchy->updateHash(index,hash);
}
int DirectoryStorage::searchHash(const RsFileHash& hash, const RsFileHash& real_hash, EntryIndex& result) const
{
RS_STACK_MUTEX(mDirStorageMtx) ;
#warning code needed here
return mFileHierarchy->searchHash(hash,result);
}
void DirectoryStorage::load(const std::string& local_file_name)
{
RS_STACK_MUTEX(mDirStorageMtx) ;
@ -296,6 +289,32 @@ bool DirectoryStorage::getIndexFromDirHash(const RsFileHash& hash,EntryIndex& in
/* Local Directory Storage */
/******************************************************************************************************************/
bool LocalDirectoryStorage::locked_findRealHash(const RsFileHash& hash, RsFileHash& real_hash) const
{
std::map<RsFileHash,RsFileHash>::const_iterator it = mEncryptedHashes.find(hash) ;
if(it == mEncryptedHashes.end())
return false ;
real_hash = it->second ;
return true ;
}
int LocalDirectoryStorage::searchHash(const RsFileHash& hash, RsFileHash& real_hash, EntryIndex& result) const
{
RS_STACK_MUTEX(mDirStorageMtx) ;
if(locked_findRealHash(hash,real_hash) && mFileHierarchy->searchHash(real_hash,result))
return true ;
if(mFileHierarchy->searchHash(hash,result))
{
real_hash.clear();
return true ;
}
return false ;
}
void LocalDirectoryStorage::setSharedDirectoryList(const std::list<SharedDirInfo>& lst)
{
RS_STACK_MUTEX(mDirStorageMtx) ;

View file

@ -53,7 +53,6 @@ class DirectoryStorage
virtual int searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const ;
virtual int searchBoolExp(RsRegularExpression::Expression * exp, std::list<EntryIndex> &results) const ;
virtual int searchHash(const RsFileHash& hash, const RsFileHash &real_hash, EntryIndex &results) const ;
// gets/sets the various time stamps:
//
@ -216,6 +215,19 @@ public:
void updateShareFlags(const SharedDirInfo& info) ;
bool convertSharedFilePath(const std::string& path_with_virtual_name,std::string& fullpath) ;
/*!
* \brief searchHash
* Looks into local database of shared files for the given hash. Also looks for files such that the hash of the hash
* matches the given hash, and returns the real hash.
* \param hash hash to look for
* \param real_hash hash such that H(real_hash) = hash, or null hash if not found.
* \param results Entry index of the file that is found
* \return
* true is a file is found
* false otherwise.
*/
virtual int searchHash(const RsFileHash& hash, RsFileHash &real_hash, EntryIndex &results) const ;
/*!
* \brief updateTimeStamps
* Checks recursive TS and update the if needed.
@ -261,6 +273,7 @@ public:
bool serialiseDirEntry(const EntryIndex& indx, RsTlvBinaryData& bindata, const RsPeerId &client_id) ;
private:
bool locked_findRealHash(const RsFileHash& hash, RsFileHash& real_hash) const;
std::string locked_getVirtualPath(EntryIndex indx) const ;
std::string locked_getVirtualDirName(EntryIndex indx) const ;
@ -268,6 +281,7 @@ private:
std::string locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const;
std::map<std::string,SharedDirInfo> mLocalDirs ; // map is better for search. it->first=it->second.filename
std::map<RsFileHash,RsFileHash> mEncryptedHashes; // map such that hash(it->second) = it->first
std::string mFileName;
bool mTSChanged ;