Add rate limit for upload url requests

This commit is contained in:
bcmmbaga
2026-09-10 17:56:40 +03:00
parent cb074a3b14
commit d29cce2c82
8 changed files with 107 additions and 18 deletions
+4 -2
View File
@@ -12,6 +12,8 @@ import (
log "github.com/sirupsen/logrus"
"github.com/netbirdio/netbird/management/server/http/middleware"
"github.com/netbirdio/netbird/upload-server/types"
)
@@ -26,7 +28,7 @@ type local struct {
signer *signer
}
func configureLocalHandlers(mux *http.ServeMux) error {
func configureLocalHandlers(mux *http.ServeMux, limiter *middleware.APIRateLimiter) error {
envURL, ok := os.LookupEnv("SERVER_URL")
if !ok {
return fmt.Errorf("SERVER_URL environment variable is required")
@@ -56,7 +58,7 @@ func configureLocalHandlers(mux *http.ServeMux) error {
dir: dir,
signer: uploadSigner,
}
mux.HandleFunc(types.GetURLPath, l.handlerGetUploadURL)
mux.Handle(types.GetURLPath, limiter.Middleware(http.HandlerFunc(l.handlerGetUploadURL)))
mux.HandleFunc(putURLPath+putHandler, l.handlePutRequest)
return nil