From 0521b7ea02952f2765aa24dc43ae169f0f95ae6c Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Sun, 2 Sep 2018 08:40:26 +0300 Subject: [PATCH] blacklist of words for p2p --- src/background/p2p.js | 12 +++++++++++- src/background/spider.js | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/background/p2p.js b/src/background/p2p.js index f5c79eb..02a6b33 100644 --- a/src/background/p2p.js +++ b/src/background/p2p.js @@ -28,6 +28,7 @@ class p2p { this.version = '0' this.info = {} this.filesRequests = {} + this.filesBlacklist = [] if(!config.peerId) { logT('p2p', 'generate peerId') @@ -146,7 +147,7 @@ class p2p { } const filePath = ph.resolve(this.dataDirectory + '/' + path) - if(!filePath.includes(this.dataDirectory)) + if(!filePath.includes(this.dataDirectory) || filePath == this.dataDirectory) { logTE('transfer', 'file get must be from data dir') return @@ -158,6 +159,15 @@ class p2p { return } + for(const blackWord of this.filesBlacklist) + { + if(filePath.includes(blackWord)) + { + logTE('transfer', 'file in blackwords', filePath, blackWord) + return + } + } + if(fs.lstatSync(filePath).isDirectory()) { const filesList = directoryFilesRecursive(filePath).map(file => ph.relative(this.dataDirectory, file).replace(/\\/g, '/')) diff --git a/src/background/spider.js b/src/background/spider.js index 171adfb..9097275 100644 --- a/src/background/spider.js +++ b/src/background/spider.js @@ -68,6 +68,23 @@ module.exports = function (send, recive, dataDirectory, version, env) p2p.version = version p2p.encryptor = encryptor p2p.dataDirectory = dataDirectory // make file transfer work + p2p.filesBlacklist = [ + 'rats.json', + 'rats.log', + 'downloads.json', + 'Cookies', + 'Cookies-journal', + 'searchd', + 'Preferences', + 'Local Storage', + 'IndexedDB', + 'GPUCache', + 'Cache', + 'blob_storage', + 'peers.p2p', + 'query.log', + 'sphinx.conf' + ] p2p.listen() const p2pStore = new P2PStore(p2p, sphinx)