process.title = 'peertube'
// Create our main app
-const app = express()
+const app = express().disable("x-powered-by")
// ----------- Core checker -----------
import { checkMissedConfig, checkFFmpeg, checkNodeVersion } from './server/initializers/checker-before-init'
checkNodeVersion()
-import { checkConfig, checkActivityPubUrls } from './server/initializers/checker-after-init'
+import { checkConfig, checkActivityPubUrls, checkFFmpegVersion } from './server/initializers/checker-after-init'
const errorMessage = checkConfig()
if (errorMessage !== null) {
if (CONFIG.CSP.ENABLED) {
app.use(baseCSP)
- app.use(helmet({
- frameguard: {
- action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts
- },
- hsts: false
+}
+
+if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) {
+ app.use(helmet.frameguard({
+ action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts
}))
}
webfingerRouter,
trackerRouter,
createWebsocketTrackerServer,
- botsRouter
+ botsRouter,
+ downloadRouter
} from './server/controllers'
import { advertiseDoNotTrack } from './server/middlewares/dnt'
import { Redis } from './server/lib/redis'
import { PeerTubeSocket } from './server/lib/peertube-socket'
import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls'
import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler'
+import { PeerTubeVersionCheckScheduler } from './server/lib/schedulers/peertube-version-check-scheduler'
import { Hooks } from './server/lib/plugins/hooks'
import { PluginManager } from './server/lib/plugins/plugin-manager'
import { LiveManager } from './server/lib/live-manager'
import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes'
+import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
// ----------- Command line -----------
return req.get('user-agent')
})
app.use(morgan('combined', {
- stream: { write: logger.info.bind(logger) }
+ stream: {
+ write: (str: string) => logger.info(str, { tags: [ 'http' ] })
+ },
+ skip: req => CONFIG.LOG.LOG_PING_REQUESTS === false && req.originalUrl === '/api/v1/ping'
}))
// For body requests
// Static files
app.use('/', staticRouter)
+app.use('/', downloadRouter)
app.use('/', lazyStaticRouter)
// Client files, last valid routes!
-if (cli.client) app.use('/', clientsRouter)
+const cliOptions = cli.opts()
+if (cliOptions.client) app.use('/', clientsRouter)
// ----------- Errors -----------
process.exit(-1)
})
+ checkFFmpegVersion()
+ .catch(err => logger.error('Cannot check ffmpeg version', { err }))
+
// Email initialization
Emailer.Instance.init()
await Promise.all([
- Emailer.Instance.checkConnectionOrDie(),
+ Emailer.Instance.checkConnection(),
JobQueue.Instance.init()
])
// Caches initializations
VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE, FILES_CACHE.PREVIEWS.MAX_AGE)
VideosCaptionCache.Instance.init(CONFIG.CACHE.VIDEO_CAPTIONS.SIZE, FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE)
+ VideosTorrentCache.Instance.init(CONFIG.CACHE.TORRENTS.SIZE, FILES_CACHE.TORRENTS.MAX_AGE)
// Enable Schedulers
ActorFollowScheduler.Instance.enable()
RemoveOldHistoryScheduler.Instance.enable()
RemoveOldViewsScheduler.Instance.enable()
PluginsCheckScheduler.Instance.enable()
+ PeerTubeVersionCheckScheduler.Instance.enable()
AutoFollowIndexInstances.Instance.enable()
// Redis initialization
updateStreamingPlaylistsInfohashesIfNeeded()
.catch(err => logger.error('Cannot update streaming playlist infohashes.', { err }))
- if (cli.plugins) await PluginManager.Instance.registerPluginsAndThemes()
+ if (cliOptions.plugins) await PluginManager.Instance.registerPluginsAndThemes()
LiveManager.Instance.init()
if (CONFIG.LIVE.ENABLED) LiveManager.Instance.run()
// Make server listening
server.listen(port, hostname, () => {
- logger.info('Server listening on %s:%d', hostname, port)
+ logger.info('HTTP server listening on %s:%d', hostname, port)
logger.info('Web server: %s', WEBSERVER.URL)
Hooks.runAction('action:application.listening')