fix(http): set ReadHeaderTimeout to mitigate Slowloris (#946)

* fix(http): add header timeout for connections

* fix: add import

---------

Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
Kyle Sanderson 2023-05-21 17:27:07 +03:00 committed by GitHub
parent ccabe96bdf
commit 8bef297841
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
"time"
"github.com/autobrr/autobrr/internal/config" "github.com/autobrr/autobrr/internal/config"
"github.com/autobrr/autobrr/internal/database" "github.com/autobrr/autobrr/internal/database"
@ -81,6 +82,7 @@ func (s Server) Open() error {
server := http.Server{ server := http.Server{
Handler: s.Handler(), Handler: s.Handler(),
ReadHeaderTimeout: time.Second * 15,
} }
s.log.Info().Msgf("Starting server. Listening on %s", listener.Addr().String()) s.log.Info().Msgf("Starting server. Listening on %s", listener.Addr().String())