From 97583d00235d5e8f29d9c49ca13096521e394aa4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 25 Jul 2023 15:18:10 +0200 Subject: Add more rate limits --- server/controllers/misc.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'server/controllers/misc.ts') 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' import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION, ROUTE_CACHE_LIFETIME } from '../initializers/constants' import { getThemeOrDefault } from '../lib/plugins/theme-utils' -import { asyncMiddleware } from '../middlewares' +import { apiRateLimiter, asyncMiddleware } from '../middlewares' import { cacheRoute } from '../middlewares/cache/cache' import { UserModel } from '../models/user/user' import { VideoModel } from '../models/video/video' @@ -18,12 +18,14 @@ const miscRouter = express.Router() miscRouter.use(cors()) miscRouter.use('/nodeinfo/:version.json', + apiRateLimiter, cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO), asyncMiddleware(generateNodeinfo) ) // robots.txt service miscRouter.get('/robots.txt', + apiRateLimiter, cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS), (_, res: express.Response) => { res.type('text/plain') @@ -33,12 +35,14 @@ miscRouter.get('/robots.txt', ) miscRouter.all('/teapot', + apiRateLimiter, getCup, asyncMiddleware(serveIndexHTML) ) // security.txt service miscRouter.get('/security.txt', + apiRateLimiter, (_, res: express.Response) => { return res.redirect(HttpStatusCode.MOVED_PERMANENTLY_301, '/.well-known/security.txt') } -- cgit v1.2.3