aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
authorbuoyantair <buoyantair@protonmail.com>2018-11-16 02:37:16 +0530
committerbuoyantair <buoyantair@protonmail.com>2018-11-16 02:37:16 +0530
commitae28cdf327d782e629379eee1999096ca2a5d74b (patch)
treebfe0d4b3a232d75161fe5bba9196553a388fc02a /server.ts
parentd4681c0074ba51c62a3aeb9fb3f2cd071dd21e32 (diff)
parent8cf998733496d44fa564e2e252356b871756c984 (diff)
downloadPeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.gz
PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.zst
PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.zip
Merge from upstream
Diffstat (limited to 'server.ts')
-rw-r--r--server.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/server.ts b/server.ts
index 59fb820b4..f3514cf9c 100644
--- a/server.ts
+++ b/server.ts
@@ -16,6 +16,7 @@ import * as cookieParser from 'cookie-parser'
16import * as helmet from 'helmet' 16import * as helmet from 'helmet'
17import * as useragent from 'useragent' 17import * as useragent from 'useragent'
18import * as anonymize from 'ip-anonymize' 18import * as anonymize from 'ip-anonymize'
19import * as cli from 'commander'
19 20
20process.title = 'peertube' 21process.title = 'peertube'
21 22
@@ -27,7 +28,7 @@ import { checkMissedConfig, checkFFmpeg } from './server/initializers/checker-be
27 28
28// Do not use barrels because we don't want to load all modules here (we need to initialize database first) 29// Do not use barrels because we don't want to load all modules here (we need to initialize database first)
29import { logger } from './server/helpers/logger' 30import { logger } from './server/helpers/logger'
30import { API_VERSION, CONFIG, CACHE } from './server/initializers/constants' 31import { API_VERSION, CONFIG, CACHE, HTTP_SIGNATURE } from './server/initializers/constants'
31 32
32const missed = checkMissedConfig() 33const missed = checkMissedConfig()
33if (missed.length !== 0) { 34if (missed.length !== 0) {
@@ -95,9 +96,14 @@ import { RemoveOldJobsScheduler } from './server/lib/schedulers/remove-old-jobs-
95import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-scheduler' 96import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-scheduler'
96import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler' 97import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler'
97import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler' 98import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler'
99import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto'
98 100
99// ----------- Command line ----------- 101// ----------- Command line -----------
100 102
103cli
104 .option('--no-client', 'Start PeerTube without client interface')
105 .parse(process.argv)
106
101// ----------- App ----------- 107// ----------- App -----------
102 108
103// Enable CORS for develop 109// Enable CORS for develop
@@ -126,7 +132,11 @@ app.use(morgan('combined', {
126app.use(bodyParser.urlencoded({ extended: false })) 132app.use(bodyParser.urlencoded({ extended: false }))
127app.use(bodyParser.json({ 133app.use(bodyParser.json({
128 type: [ 'application/json', 'application/*+json' ], 134 type: [ 'application/json', 'application/*+json' ],
129 limit: '500kb' 135 limit: '500kb',
136 verify: (req: express.Request, _, buf: Buffer, encoding: string) => {
137 const valid = isHTTPSignatureDigestValid(buf, req)
138 if (valid !== true) throw new Error('Invalid digest')
139 }
130})) 140}))
131// Cookies 141// Cookies
132app.use(cookieParser()) 142app.use(cookieParser())
@@ -151,7 +161,7 @@ app.use('/', trackerRouter)
151app.use('/', staticRouter) 161app.use('/', staticRouter)
152 162
153// Client files, last valid routes! 163// Client files, last valid routes!
154app.use('/', clientsRouter) 164if (cli.client) app.use('/', clientsRouter)
155 165
156// ----------- Errors ----------- 166// ----------- Errors -----------
157 167