From 440aa4139614b7aa8e67802c10648a2a57f7d124 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Fri, 4 Feb 2022 15:06:56 +0100 Subject: [PATCH] added timeouts to config --- config_example.yaml | 10 +++++++++- main.go | 12 ++++++------ utils/utils.go | 5 +++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/config_example.yaml b/config_example.yaml index e3f27f1..fba3d15 100644 --- a/config_example.yaml +++ b/config_example.yaml @@ -42,4 +42,12 @@ csgowtfd: # days in which demos expire demos_expire: 30 # ms between shots to count as spray - spray_timeout: 500 \ No newline at end of file + spray_timeout: 500 + # timeouts + timeout: + # seconds before incoming request with no data send timeout + read: 5 + # seconds to write a response before timeout + write: 30 + # seconds before closing idle connections + idle: 120 \ No newline at end of file diff --git a/main.go b/main.go index 3e77256..80edd7d 100644 --- a/main.go +++ b/main.go @@ -1152,9 +1152,9 @@ func main() { sockets = append(sockets, sL) go func() { srv := &http.Server{ - ReadTimeout: 5 * time.Second, - WriteTimeout: 10 * time.Second, - IdleTimeout: 120 * time.Second, + ReadTimeout: time.Duration(conf.Csgowtfd.Timeout.Read) * time.Second, + WriteTimeout: time.Duration(conf.Csgowtfd.Timeout.Write) * time.Second, + IdleTimeout: time.Duration(conf.Csgowtfd.Timeout.Idle) * time.Second, Handler: cors(proxyRouter), } _ = srv.Serve(sL) @@ -1167,9 +1167,9 @@ func main() { } go func() { srv := &http.Server{ - ReadTimeout: 5 * time.Second, - WriteTimeout: 10 * time.Second, - IdleTimeout: 120 * time.Second, + ReadTimeout: time.Duration(conf.Csgowtfd.Timeout.Read) * time.Second, + WriteTimeout: time.Duration(conf.Csgowtfd.Timeout.Write) * time.Second, + IdleTimeout: time.Duration(conf.Csgowtfd.Timeout.Idle) * time.Second, Handler: cors(proxyRouter), } err = srv.Serve(tL) diff --git a/utils/utils.go b/utils/utils.go index 2ab07a5..5502eeb 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -64,6 +64,11 @@ type Conf struct { SharecodeUpdate string `yaml:"sharecode_update"` DemosExpire int `yaml:"demos_expire"` SprayTimeout int `yaml:"spray_timeout"` + Timeout struct { + Read int + Write int + Idle int + } } }