aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/tracker.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-14 11:00:03 +0200
committerChocobozzz <me@florianbigard.com>2018-08-14 11:00:03 +0200
commitcc43831a90ab8b1b460cd7021c100190049ec64b (patch)
tree187f3602fd8749b66d5782174ba48f8a33453d7d /server/controllers/tracker.ts
parent08c11bec43987364e83246e4e76958f5ccf89fe8 (diff)
downloadPeerTube-cc43831a90ab8b1b460cd7021c100190049ec64b.tar.gz
PeerTube-cc43831a90ab8b1b460cd7021c100190049ec64b.tar.zst
PeerTube-cc43831a90ab8b1b460cd7021c100190049ec64b.zip
Filter tracker based on infohash
Diffstat (limited to 'server/controllers/tracker.ts')
-rw-r--r--server/controllers/tracker.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/server/controllers/tracker.ts b/server/controllers/tracker.ts
index 42f5aea81..9bc7586d1 100644
--- a/server/controllers/tracker.ts
+++ b/server/controllers/tracker.ts
@@ -5,6 +5,7 @@ import * as bitTorrentTracker from 'bittorrent-tracker'
5import * as proxyAddr from 'proxy-addr' 5import * as proxyAddr from 'proxy-addr'
6import { Server as WebSocketServer } from 'ws' 6import { Server as WebSocketServer } from 'ws'
7import { CONFIG, TRACKER_RATE_LIMITS } from '../initializers/constants' 7import { CONFIG, TRACKER_RATE_LIMITS } from '../initializers/constants'
8import { VideoFileModel } from '../models/video/video-file'
8 9
9const TrackerServer = bitTorrentTracker.Server 10const TrackerServer = bitTorrentTracker.Server
10 11
@@ -37,7 +38,12 @@ const trackerServer = new TrackerServer({
37 return cb(new Error(`Too many requests (${peersIpInfoHash[ key ]} of ip ${ip} for torrent ${infoHash}`)) 38 return cb(new Error(`Too many requests (${peersIpInfoHash[ key ]} of ip ${ip} for torrent ${infoHash}`))
38 } 39 }
39 40
40 return cb() 41 VideoFileModel.isInfohashExists(infoHash)
42 .then(exists => {
43 if (exists === false) return cb(new Error(`Unknown infoHash ${infoHash}`))
44
45 return cb()
46 })
41 } 47 }
42}) 48})
43 49