diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-25 15:18:10 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-26 08:37:50 +0200 |
commit | 97583d00235d5e8f29d9c49ca13096521e394aa4 (patch) | |
tree | 5f29ba8c8e5b2d2653a1173408151bb64f6a80a9 /server/controllers/feeds | |
parent | 9901c8d6908a43ab4594406446eac770ee21176c (diff) | |
download | PeerTube-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.ts | 2 | ||||
-rw-r--r-- | server/controllers/feeds/index.ts | 15 | ||||
-rw-r--r-- | server/controllers/feeds/video-feeds.ts | 4 | ||||
-rw-r--r-- | server/controllers/feeds/video-podcast-feeds.ts | 2 |
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 | ||
26 | commentFeedsRouter.get('/feeds/video-comments.:format', | 26 | commentFeedsRouter.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 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { CONFIG } from '@server/initializers/config' | ||
3 | import { buildRateLimiter } from '@server/middlewares' | ||
2 | import { commentFeedsRouter } from './comment-feeds' | 4 | import { commentFeedsRouter } from './comment-feeds' |
3 | import { videoFeedsRouter } from './video-feeds' | 5 | import { videoFeedsRouter } from './video-feeds' |
4 | import { videoPodcastFeedsRouter } from './video-podcast-feeds' | 6 | import { videoPodcastFeedsRouter } from './video-podcast-feeds' |
5 | 7 | ||
6 | const feedsRouter = express.Router() | 8 | const feedsRouter = express.Router() |
7 | 9 | ||
8 | feedsRouter.use('/', commentFeedsRouter) | 10 | const feedsRateLimiter = buildRateLimiter({ |
9 | feedsRouter.use('/', videoFeedsRouter) | 11 | windowMs: CONFIG.RATES_LIMIT.FEEDS.WINDOW_MS, |
10 | feedsRouter.use('/', videoPodcastFeedsRouter) | 12 | max: CONFIG.RATES_LIMIT.FEEDS.MAX |
13 | }) | ||
14 | |||
15 | feedsRouter.use('/feeds', feedsRateLimiter) | ||
16 | |||
17 | feedsRouter.use('/feeds', commentFeedsRouter) | ||
18 | feedsRouter.use('/feeds', videoFeedsRouter) | ||
19 | feedsRouter.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 | ||
29 | videoFeedsRouter.get('/feeds/videos.:format', | 29 | videoFeedsRouter.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 | ||
40 | videoFeedsRouter.get('/feeds/subscriptions.:format', | 40 | videoFeedsRouter.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 | ||
43 | videoPodcastFeedsRouter.get('/feeds/podcast/videos.xml', | 43 | videoPodcastFeedsRouter.get('/podcast/videos.xml', |
44 | setFeedPodcastContentType, | 44 | setFeedPodcastContentType, |
45 | videoFeedsPodcastSetCacheKey, | 45 | videoFeedsPodcastSetCacheKey, |
46 | podcastCacheRouteMiddleware(ROUTE_CACHE_LIFETIME.FEEDS), | 46 | podcastCacheRouteMiddleware(ROUTE_CACHE_LIFETIME.FEEDS), |