aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/feeds
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-25 15:18:10 +0200
committerChocobozzz <me@florianbigard.com>2023-07-26 08:37:50 +0200
commit97583d00235d5e8f29d9c49ca13096521e394aa4 (patch)
tree5f29ba8c8e5b2d2653a1173408151bb64f6a80a9 /server/controllers/feeds
parent9901c8d6908a43ab4594406446eac770ee21176c (diff)
downloadPeerTube-97583d00235d5e8f29d9c49ca13096521e394aa4.tar.gz
PeerTube-97583d00235d5e8f29d9c49ca13096521e394aa4.tar.zst
PeerTube-97583d00235d5e8f29d9c49ca13096521e394aa4.zip
Add more rate limits
Diffstat (limited to 'server/controllers/feeds')
-rw-r--r--server/controllers/feeds/comment-feeds.ts2
-rw-r--r--server/controllers/feeds/index.ts15
-rw-r--r--server/controllers/feeds/video-feeds.ts4
-rw-r--r--server/controllers/feeds/video-podcast-feeds.ts2
4 files changed, 16 insertions, 7 deletions
diff --git a/server/controllers/feeds/comment-feeds.ts b/server/controllers/feeds/comment-feeds.ts
index bdc53b51f..68dc9ef90 100644
--- a/server/controllers/feeds/comment-feeds.ts
+++ b/server/controllers/feeds/comment-feeds.ts
@@ -23,7 +23,7 @@ const { middleware: cacheRouteMiddleware } = cacheRouteFactory({
23 23
24// --------------------------------------------------------------------------- 24// ---------------------------------------------------------------------------
25 25
26commentFeedsRouter.get('/feeds/video-comments.:format', 26commentFeedsRouter.get('/video-comments.:format',
27 feedsFormatValidator, 27 feedsFormatValidator,
28 setFeedFormatContentType, 28 setFeedFormatContentType,
29 cacheRouteMiddleware(ROUTE_CACHE_LIFETIME.FEEDS), 29 cacheRouteMiddleware(ROUTE_CACHE_LIFETIME.FEEDS),
diff --git a/server/controllers/feeds/index.ts b/server/controllers/feeds/index.ts
index e344a1448..19352318d 100644
--- a/server/controllers/feeds/index.ts
+++ b/server/controllers/feeds/index.ts
@@ -1,13 +1,22 @@
1import express from 'express' 1import express from 'express'
2import { CONFIG } from '@server/initializers/config'
3import { buildRateLimiter } from '@server/middlewares'
2import { commentFeedsRouter } from './comment-feeds' 4import { commentFeedsRouter } from './comment-feeds'
3import { videoFeedsRouter } from './video-feeds' 5import { videoFeedsRouter } from './video-feeds'
4import { videoPodcastFeedsRouter } from './video-podcast-feeds' 6import { videoPodcastFeedsRouter } from './video-podcast-feeds'
5 7
6const feedsRouter = express.Router() 8const feedsRouter = express.Router()
7 9
8feedsRouter.use('/', commentFeedsRouter) 10const feedsRateLimiter = buildRateLimiter({
9feedsRouter.use('/', videoFeedsRouter) 11 windowMs: CONFIG.RATES_LIMIT.FEEDS.WINDOW_MS,
10feedsRouter.use('/', videoPodcastFeedsRouter) 12 max: CONFIG.RATES_LIMIT.FEEDS.MAX
13})
14
15feedsRouter.use('/feeds', feedsRateLimiter)
16
17feedsRouter.use('/feeds', commentFeedsRouter)
18feedsRouter.use('/feeds', videoFeedsRouter)
19feedsRouter.use('/feeds', videoPodcastFeedsRouter)
11 20
12// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
13 22
diff --git a/server/controllers/feeds/video-feeds.ts b/server/controllers/feeds/video-feeds.ts
index b6e0663eb..97ac594ec 100644
--- a/server/controllers/feeds/video-feeds.ts
+++ b/server/controllers/feeds/video-feeds.ts
@@ -26,7 +26,7 @@ const { middleware: cacheRouteMiddleware } = cacheRouteFactory({
26 26
27// --------------------------------------------------------------------------- 27// ---------------------------------------------------------------------------
28 28
29videoFeedsRouter.get('/feeds/videos.:format', 29videoFeedsRouter.get('/videos.:format',
30 videosSortValidator, 30 videosSortValidator,
31 setDefaultVideosSort, 31 setDefaultVideosSort,
32 feedsFormatValidator, 32 feedsFormatValidator,
@@ -37,7 +37,7 @@ videoFeedsRouter.get('/feeds/videos.:format',
37 asyncMiddleware(generateVideoFeed) 37 asyncMiddleware(generateVideoFeed)
38) 38)
39 39
40videoFeedsRouter.get('/feeds/subscriptions.:format', 40videoFeedsRouter.get('/subscriptions.:format',
41 videosSortValidator, 41 videosSortValidator,
42 setDefaultVideosSort, 42 setDefaultVideosSort,
43 feedsFormatValidator, 43 feedsFormatValidator,
diff --git a/server/controllers/feeds/video-podcast-feeds.ts b/server/controllers/feeds/video-podcast-feeds.ts
index bd399580e..fca82ba68 100644
--- a/server/controllers/feeds/video-podcast-feeds.ts
+++ b/server/controllers/feeds/video-podcast-feeds.ts
@@ -40,7 +40,7 @@ for (const event of ([ 'channel-updated', 'channel-deleted' ] as const)) {
40 40
41// --------------------------------------------------------------------------- 41// ---------------------------------------------------------------------------
42 42
43videoPodcastFeedsRouter.get('/feeds/podcast/videos.xml', 43videoPodcastFeedsRouter.get('/podcast/videos.xml',
44 setFeedPodcastContentType, 44 setFeedPodcastContentType,
45 videoFeedsPodcastSetCacheKey, 45 videoFeedsPodcastSetCacheKey,
46 podcastCacheRouteMiddleware(ROUTE_CACHE_LIFETIME.FEEDS), 46 podcastCacheRouteMiddleware(ROUTE_CACHE_LIFETIME.FEEDS),