Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent setting readTimeout / writeTimeout to zero #3750

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading