dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit b689d8650b046ddc294b375e049f6e35a8122443
parent 4cbe2f98f9f22a29b71b04c45a37f99f2ec59a45
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 23 May 2023 19:59:24 -0700

add rate limiter

Diffstat:
Mpkg/web/web.go | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pkg/web/web.go b/pkg/web/web.go @@ -143,7 +143,7 @@ func getMainServer(db *database.DkfDB, i18nBundle *i18n.Bundle, renderer *tmp.Te authGroup.GET("/api/v1/chat/top-bar/:roomName", v1.ChatTopBarHandler) authGroup.POST("/api/v1/chat/top-bar/:roomName", v1.ChatTopBarHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 3)) authGroup.GET("/api/v1/chat/messages/:roomName", v1.ChatMessagesHandler) - authGroup.GET("/api/v1/chat/messages/:roomName/stream", handlers.ChatStreamMessagesHandler) + authGroup.GET("/api/v1/chat/messages/:roomName/stream", handlers.ChatStreamMessagesHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 4)) authGroup.GET("/api/v1/chat/messages/:roomName/stream/menu", handlers.ChatStreamMenuHandler) authGroup.POST("/api/v1/notifications/delete/:notificationID", v1.DeleteNotificationHandler) authGroup.POST("/api/v1/session-notifications/delete/:sessionNotificationID", v1.DeleteSessionNotificationHandler) @@ -208,12 +208,12 @@ func getMainServer(db *database.DkfDB, i18nBundle *i18n.Bundle, renderer *tmp.Te authGroup.POST("/new-thread", handlers.NewThreadHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 2)) authGroup.GET("/red-room", handlers.RedRoomHandler) authGroup.GET("/rooms", handlers.RoomsHandler) - authGroup.GET("/chat", handlers.ChatHandler) + authGroup.GET("/chat", handlers.ChatHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 4)) authGroup.POST("/chat", handlers.ChatHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 2)) authGroup.GET("/chat/help", handlers.ChatHelpHandler) authGroup.GET("/chat/create-room", handlers.ChatCreateRoomHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 2)) authGroup.POST("/chat/create-room", handlers.ChatCreateRoomHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 2)) - authGroup.GET("/chat/:roomName/stream", handlers.ChatStreamHandler) + authGroup.GET("/chat/:roomName/stream", handlers.ChatStreamHandler, middlewares.AuthRateLimitMiddleware(1*time.Second, 4)) authGroup.GET("/chat/:roomName/archive", handlers.ChatArchiveHandler) authGroup.GET("/chat/:roomName/delete", handlers.ChatDeleteHandler) authGroup.POST("/chat/:roomName/delete", handlers.ChatDeleteHandler)