- VideoFileModel.isInfohashExists(infoHash)
- .then(exists => {
- if (exists === false) return cb(new Error(`Unknown infoHash ${infoHash}`))
+ 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 }))