From cc43831a90ab8b1b460cd7021c100190049ec64b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 14 Aug 2018 11:00:03 +0200 Subject: Filter tracker based on infohash --- server/controllers/tracker.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'server/controllers') 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' import * as proxyAddr from 'proxy-addr' import { Server as WebSocketServer } from 'ws' import { CONFIG, TRACKER_RATE_LIMITS } from '../initializers/constants' +import { VideoFileModel } from '../models/video/video-file' const TrackerServer = bitTorrentTracker.Server @@ -37,7 +38,12 @@ const trackerServer = new TrackerServer({ return cb(new Error(`Too many requests (${peersIpInfoHash[ key ]} of ip ${ip} for torrent ${infoHash}`)) } - return cb() + VideoFileModel.isInfohashExists(infoHash) + .then(exists => { + if (exists === false) return cb(new Error(`Unknown infoHash ${infoHash}`)) + + return cb() + }) } }) -- cgit v1.2.3