aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/webtorrentProcess.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/webtorrentProcess.js')
-rw-r--r--server/lib/webtorrentProcess.js38
1 files changed, 19 insertions, 19 deletions
diff --git a/server/lib/webtorrentProcess.js b/server/lib/webtorrentProcess.js
index 7da52523a..c68e97ee4 100644
--- a/server/lib/webtorrentProcess.js
+++ b/server/lib/webtorrentProcess.js
@@ -1,32 +1,32 @@
1'use strict' 1'use strict'
2 2
3var WebTorrent = require('webtorrent') 3const WebTorrent = require('webtorrent')
4var ipc = require('node-ipc') 4const ipc = require('node-ipc')
5 5
6function webtorrent (args) { 6function webtorrent (args) {
7 if (args.length !== 3) { 7 if (args.length !== 3) {
8 throw new Error('Wrong arguments number: ' + args.length + '/3') 8 throw new Error('Wrong arguments number: ' + args.length + '/3')
9 } 9 }
10 10
11 var host = args[1] 11 const host = args[1]
12 var port = args[2] 12 const port = args[2]
13 var nodeKey = 'webtorrentnode' + port 13 const nodeKey = 'webtorrentnode' + port
14 var processKey = 'webtorrentprocess' + port 14 const processKey = 'webtorrentprocess' + port
15 15
16 ipc.config.silent = true 16 ipc.config.silent = true
17 ipc.config.id = processKey 17 ipc.config.id = processKey
18 18
19 if (host === 'client' && port === '1') global.WEBTORRENT_ANNOUNCE = [] 19 if (host === 'client' && port === '1') global.WEBTORRENT_ANNOUNCE = []
20 else global.WEBTORRENT_ANNOUNCE = 'ws://' + host + ':' + port + '/tracker/socket' 20 else global.WEBTORRENT_ANNOUNCE = 'ws://' + host + ':' + port + '/tracker/socket'
21 var wt = new WebTorrent({ dht: false }) 21 const wt = new WebTorrent({ dht: false })
22 22
23 function seed (data) { 23 function seed (data) {
24 var args = data.args 24 const args = data.args
25 var path = args.path 25 const path = args.path
26 var _id = data._id 26 const _id = data._id
27 27
28 wt.seed(path, { announceList: '' }, function (torrent) { 28 wt.seed(path, { announceList: '' }, function (torrent) {
29 var to_send = { 29 const to_send = {
30 magnetUri: torrent.magnetURI 30 magnetUri: torrent.magnetURI
31 } 31 }
32 32
@@ -35,12 +35,12 @@ function webtorrent (args) {
35 } 35 }
36 36
37 function add (data) { 37 function add (data) {
38 var args = data.args 38 const args = data.args
39 var magnetUri = args.magnetUri 39 const magnetUri = args.magnetUri
40 var _id = data._id 40 const _id = data._id
41 41
42 wt.add(magnetUri, function (torrent) { 42 wt.add(magnetUri, function (torrent) {
43 var to_send = { 43 const to_send = {
44 files: [] 44 files: []
45 } 45 }
46 46
@@ -53,9 +53,9 @@ function webtorrent (args) {
53 } 53 }
54 54
55 function remove (data) { 55 function remove (data) {
56 var args = data.args 56 const args = data.args
57 var magnetUri = args.magnetUri 57 const magnetUri = args.magnetUri
58 var _id = data._id 58 const _id = data._id
59 59
60 try { 60 try {
61 wt.remove(magnetUri, callback) 61 wt.remove(magnetUri, callback)
@@ -65,7 +65,7 @@ function webtorrent (args) {
65 } 65 }
66 66
67 function callback () { 67 function callback () {
68 var to_send = {} 68 const to_send = {}
69 ipc.of[nodeKey].emit(nodeKey + '.removeDone.' + _id, to_send) 69 ipc.of[nodeKey].emit(nodeKey + '.removeDone.' + _id, to_send)
70 } 70 }
71 } 71 }