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/misc.ts | |
parent | 9901c8d6908a43ab4594406446eac770ee21176c (diff) | |
download | PeerTube-97583d00235d5e8f29d9c49ca13096521e394aa4.tar.gz PeerTube-97583d00235d5e8f29d9c49ca13096521e394aa4.tar.zst PeerTube-97583d00235d5e8f29d9c49ca13096521e394aa4.zip |
Add more rate limits
Diffstat (limited to 'server/controllers/misc.ts')
-rw-r--r-- | server/controllers/misc.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/server/controllers/misc.ts b/server/controllers/misc.ts index 163352ac5..a7dfc7867 100644 --- a/server/controllers/misc.ts +++ b/server/controllers/misc.ts | |||
@@ -7,7 +7,7 @@ import { HttpStatusCode } from '@shared/models' | |||
7 | import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' | 7 | import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' |
8 | import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION, ROUTE_CACHE_LIFETIME } from '../initializers/constants' | 8 | import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION, ROUTE_CACHE_LIFETIME } from '../initializers/constants' |
9 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' | 9 | import { getThemeOrDefault } from '../lib/plugins/theme-utils' |
10 | import { asyncMiddleware } from '../middlewares' | 10 | import { apiRateLimiter, asyncMiddleware } from '../middlewares' |
11 | import { cacheRoute } from '../middlewares/cache/cache' | 11 | import { cacheRoute } from '../middlewares/cache/cache' |
12 | import { UserModel } from '../models/user/user' | 12 | import { UserModel } from '../models/user/user' |
13 | import { VideoModel } from '../models/video/video' | 13 | import { VideoModel } from '../models/video/video' |
@@ -18,12 +18,14 @@ const miscRouter = express.Router() | |||
18 | miscRouter.use(cors()) | 18 | miscRouter.use(cors()) |
19 | 19 | ||
20 | miscRouter.use('/nodeinfo/:version.json', | 20 | miscRouter.use('/nodeinfo/:version.json', |
21 | apiRateLimiter, | ||
21 | cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO), | 22 | cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO), |
22 | asyncMiddleware(generateNodeinfo) | 23 | asyncMiddleware(generateNodeinfo) |
23 | ) | 24 | ) |
24 | 25 | ||
25 | // robots.txt service | 26 | // robots.txt service |
26 | miscRouter.get('/robots.txt', | 27 | miscRouter.get('/robots.txt', |
28 | apiRateLimiter, | ||
27 | cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS), | 29 | cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS), |
28 | (_, res: express.Response) => { | 30 | (_, res: express.Response) => { |
29 | res.type('text/plain') | 31 | res.type('text/plain') |
@@ -33,12 +35,14 @@ miscRouter.get('/robots.txt', | |||
33 | ) | 35 | ) |
34 | 36 | ||
35 | miscRouter.all('/teapot', | 37 | miscRouter.all('/teapot', |
38 | apiRateLimiter, | ||
36 | getCup, | 39 | getCup, |
37 | asyncMiddleware(serveIndexHTML) | 40 | asyncMiddleware(serveIndexHTML) |
38 | ) | 41 | ) |
39 | 42 | ||
40 | // security.txt service | 43 | // security.txt service |
41 | miscRouter.get('/security.txt', | 44 | miscRouter.get('/security.txt', |
45 | apiRateLimiter, | ||
42 | (_, res: express.Response) => { | 46 | (_, res: express.Response) => { |
43 | return res.redirect(HttpStatusCode.MOVED_PERMANENTLY_301, '/.well-known/security.txt') | 47 | return res.redirect(HttpStatusCode.MOVED_PERMANENTLY_301, '/.well-known/security.txt') |
44 | } | 48 | } |