Skip to content

Commit

Permalink
prevent setting readTimeout / writeTimeout to zero (#3750)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Sep 9, 2024
1 parent e665385 commit 7b01f48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ func (conf Conf) Clone() *Conf {
func (conf *Conf) Validate() error {
// General

if conf.ReadTimeout <= 0 {
return fmt.Errorf("'readTimeout' must be greater than zero")
}
if conf.WriteTimeout <= 0 {
return fmt.Errorf("'writeTimeout' must be greater than zero")
}
if conf.ReadBufferCount != nil {
conf.WriteQueueSize = *conf.ReadBufferCount
}
Expand All @@ -506,6 +512,7 @@ func (conf *Conf) Validate() error {
}

// Authentication

if conf.ExternalAuthenticationURL != nil {
conf.AuthMethod = AuthMethodHTTP
conf.AuthHTTPAddress = *conf.ExternalAuthenticationURL
Expand Down Expand Up @@ -658,6 +665,7 @@ func (conf *Conf) Validate() error {
}

// Record (deprecated)

if conf.Record != nil {
conf.PathDefaults.Record = *conf.Record
}
Expand Down
10 changes: 10 additions & 0 deletions internal/conf/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ func TestConfErrors(t *testing.T) {
`invalid: param`,
"json: unknown field \"invalid\"",
},
{
"invalid readTimeout",
"readTimeout: 0s\n",
"'readTimeout' must be greater than zero",
},
{
"invalid writeTimeout",
"writeTimeout: 0s\n",
"'writeTimeout' must be greater than zero",
},
{
"invalid writeQueueSize",
"writeQueueSize: 1001\n",
Expand Down

0 comments on commit 7b01f48

Please sign in to comment.