Skip to content

Commit

Permalink
Added idleTimout to config and to serve.go HTTP server (#635)
Browse files Browse the repository at this point in the history
* Added idleTimout to config and to serve.go HTTP server
* updated fabio.properties to include idle timeout doco
* added in testing for idle timeout
  • Loading branch information
galen0624 authored and Aaron Hurt committed Jan 27, 2020
1 parent 13c6ab2 commit 73c6eef
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Listen struct {
Proto string
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
CertSource CertSource
StrictMatch bool
TLSMinVersion uint16
Expand Down
1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var defaultValues = struct {
AuthSchemesValue string
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
UIListenerValue string
GZIPContentTypesValue string
}{
Expand Down
6 changes: 6 additions & 0 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ func parseListen(cfg map[string]string, cs map[string]CertSource, readTimeout, w
return Listen{}, err
}
l.WriteTimeout = d
case "it": // idle timeout
d, err := time.ParseDuration(v)
if err != nil {
return Listen{}, err
}
l.IdleTimeout = d
case "cs": // cert source
csName = v
c, ok := cs[v]
Expand Down
6 changes: 4 additions & 2 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@ func TestLoad(t *testing.T) {
},
{
desc: "-proxy.addr with tls configs",
args: []string{"-proxy.addr", `:5555;rt=1s;wt=2s;tlsmin=0x0300;tlsmax=0x305;tlsciphers="0x123,0x456"`},
args: []string{"-proxy.addr", `:5555;rt=1s;wt=2s;it=3s;tlsmin=0x0300;tlsmax=0x305;tlsciphers="0x123,0x456"`},
cfg: func(cfg *Config) *Config {
cfg.Listen = []Listen{
{
Addr: ":5555",
Proto: "http",
ReadTimeout: 1 * time.Second,
WriteTimeout: 2 * time.Second,
IdleTimeout: 3 * time.Second,
TLSMinVersion: 0x300,
TLSMaxVersion: 0x305,
TLSCiphers: []uint16{0x123, 0x456},
Expand All @@ -132,14 +133,15 @@ func TestLoad(t *testing.T) {
},
{
desc: "-proxy.addr with named tls configs",
args: []string{"-proxy.addr", `:5555;rt=1s;wt=2s;tlsmin=tls10;tlsmax=TLS11;tlsciphers="TLS_RSA_WITH_RC4_128_SHA,tls_ecdhe_ecdsa_with_aes_256_gcm_sha384"`},
args: []string{"-proxy.addr", `:5555;rt=1s;wt=2s;it=3s;tlsmin=tls10;tlsmax=TLS11;tlsciphers="TLS_RSA_WITH_RC4_128_SHA,tls_ecdhe_ecdsa_with_aes_256_gcm_sha384"`},
cfg: func(cfg *Config) *Config {
cfg.Listen = []Listen{
{
Addr: ":5555",
Proto: "http",
ReadTimeout: 1 * time.Second,
WriteTimeout: 2 * time.Second,
IdleTimeout: 3 * time.Second,
TLSMinVersion: tls.VersionTLS10,
TLSMaxVersion: tls.VersionTLS11,
TLSCiphers: []uint16{tls.TLS_RSA_WITH_RC4_128_SHA, tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384},
Expand Down
2 changes: 2 additions & 0 deletions docs/content/ref/proxy.addr.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ to the destination without decrypting the traffic.

* `wt`: Sets the write timeout as a duration value (e.g. `3s`)

* `it`: Sets the idle timeout as a duration value (e.g. `3s`)

* `strictmatch`: When set to `true` the certificate source must provide
a certificate that matches the hostname for the connection
to be established. Otherwise, the first certificate is used
Expand Down
2 changes: 2 additions & 0 deletions fabio.properties
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@
#
# wt: Sets the write timeout as a duration value (e.g. '3s')
#
# it: Sets the idle timeout as a duration value (e.g. '3s')
#
# strictmatch: When set to 'true' the certificate source must provide
# a certificate that matches the hostname for the connection
# to be established. Otherwise, the first certificate is used
Expand Down
1 change: 1 addition & 0 deletions proxy/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func ListenAndServeHTTP(l config.Listen, h http.Handler, cfg *tls.Config) error
Handler: h,
ReadTimeout: l.ReadTimeout,
WriteTimeout: l.WriteTimeout,
IdleTimeout: l.IdleTimeout,
TLSConfig: cfg,
}
return serve(ln, srv)
Expand Down

0 comments on commit 73c6eef

Please sign in to comment.