MM-22049: Add idle timeout to the HTTP server (#13788)
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bfaf4fa5dc
Коммит
435d43049f
@@ -515,6 +515,7 @@ func (s *Server) Start() error {
|
|||||||
Handler: handler,
|
Handler: handler,
|
||||||
ReadTimeout: time.Duration(*s.Config().ServiceSettings.ReadTimeout) * time.Second,
|
ReadTimeout: time.Duration(*s.Config().ServiceSettings.ReadTimeout) * time.Second,
|
||||||
WriteTimeout: time.Duration(*s.Config().ServiceSettings.WriteTimeout) * time.Second,
|
WriteTimeout: time.Duration(*s.Config().ServiceSettings.WriteTimeout) * time.Second,
|
||||||
|
IdleTimeout: time.Duration(*s.Config().ServiceSettings.IdleTimeout) * time.Second,
|
||||||
ErrorLog: errStdLog,
|
ErrorLog: errStdLog,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ const (
|
|||||||
SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE = ""
|
SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE = ""
|
||||||
SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT = 300
|
SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT = 300
|
||||||
SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT = 300
|
SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT = 300
|
||||||
|
SERVICE_SETTINGS_DEFAULT_IDLE_TIMEOUT = 60
|
||||||
SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS = 10
|
SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS = 10
|
||||||
SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM = ""
|
SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM = ""
|
||||||
SERVICE_SETTINGS_DEFAULT_LISTEN_AND_ADDRESS = ":8065"
|
SERVICE_SETTINGS_DEFAULT_LISTEN_AND_ADDRESS = ":8065"
|
||||||
@@ -256,6 +257,7 @@ type ServiceSettings struct {
|
|||||||
TrustedProxyIPHeader []string `restricted:"true"`
|
TrustedProxyIPHeader []string `restricted:"true"`
|
||||||
ReadTimeout *int `restricted:"true"`
|
ReadTimeout *int `restricted:"true"`
|
||||||
WriteTimeout *int `restricted:"true"`
|
WriteTimeout *int `restricted:"true"`
|
||||||
|
IdleTimeout *int `restricted:"true"`
|
||||||
MaximumLoginAttempts *int `restricted:"true"`
|
MaximumLoginAttempts *int `restricted:"true"`
|
||||||
GoroutineHealthThreshold *int `restricted:"true"`
|
GoroutineHealthThreshold *int `restricted:"true"`
|
||||||
GoogleDeveloperKey *string `restricted:"true"`
|
GoogleDeveloperKey *string `restricted:"true"`
|
||||||
@@ -459,6 +461,10 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
|||||||
s.WriteTimeout = NewInt(SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT)
|
s.WriteTimeout = NewInt(SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.IdleTimeout == nil {
|
||||||
|
s.IdleTimeout = NewInt(SERVICE_SETTINGS_DEFAULT_IDLE_TIMEOUT)
|
||||||
|
}
|
||||||
|
|
||||||
if s.MaximumLoginAttempts == nil {
|
if s.MaximumLoginAttempts == nil {
|
||||||
s.MaximumLoginAttempts = NewInt(SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS)
|
s.MaximumLoginAttempts = NewInt(SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user