+ try {
+ if (CONFIG.TRACKER.PRIVATE === false) return cb()
+
+ const videoFileExists = await VideoFileModel.doesInfohashExistCached(infoHash)
+ if (videoFileExists === true) return cb()
+
+ const playlistExists = await VideoStreamingPlaylistModel.doesInfohashExistCached(infoHash)
+ if (playlistExists === true) return cb()
+
+ cb(new Error(`Unknown infoHash ${infoHash} requested by ip ${ip}`))
+
+ // Close socket connection and block IP for a few time
+ if (params.type === 'ws') {
+ Redis.Instance.setTrackerBlockIP(ip)
+ .catch(err => logger.error('Cannot set tracker block ip.', { err }))
+
+ // setTimeout to wait filter response
+ setTimeout(() => params.socket.close(), 0)
+ }
+ } catch (err) {
+ logger.error('Error in tracker filter.', { err })
+ return cb(err)
+ }