feat(p2p): file transfer p2p feature

This commit is contained in:
Alexey Kasyanchuk
2018-08-31 06:14:25 +03:00
parent 2773db3949
commit 3e6ac4c00d
3 changed files with 54 additions and 11 deletions

View File

@ -5,6 +5,7 @@ const getTorrent = require('./gettorrent')
const _ = require('lodash')
const asyncForEach = require('./asyncForEach')
const cpuUsage = require('./bt/cpu-usage-global')
const magnetParse = require('./magnetParse')
module.exports = async ({
sphinx,
@ -291,15 +292,6 @@ module.exports = async ({
return /[0-9a-f]+/i.test(hash)
}
const magnetParse = (magnet) => {
const match = /magnet:\?xt=urn:btih:([0-9a-f]+)/i.exec(magnet)
if(!match)
return
if(match[1].length === 40)
return match[1].toLowerCase()
return
}
const searchTorrentCall = function(text, navigation, callback, isP2P)
{
if(typeof callback != 'function')