Skip to content

Commit

Permalink
plugin/forward: init ClientSessionCache in tls.Config (#4108)
Browse files Browse the repository at this point in the history
* plugin/forward: init ClientSessionCache in tls.Config

 - ClientSessionCache may speed up a TLS handshake in upcoming connections
   to the same TLS server

Signed-off-by: Ruslan Drozhdzh <rdrozhdzh@infoblox.com>

* add comment

Signed-off-by: Ruslan Drozhdzh <rdrozhdzh@infoblox.com>
  • Loading branch information
rdrozhdzh committed Sep 8, 2020
1 parent ca43f84 commit 04af1c6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugin/forward/setup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package forward

import (
"crypto/tls"
"errors"
"fmt"
"strconv"
Expand Down Expand Up @@ -117,6 +118,11 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
if f.tlsServerName != "" {
f.tlsConfig.ServerName = f.tlsServerName
}

// Initialize ClientSessionCache in tls.Config. This may speed up a TLS handshake
// in upcoming connections to the same TLS server.
f.tlsConfig.ClientSessionCache = tls.NewLRUClientSessionCache(len(f.proxies))

for i := range f.proxies {
// Only set this for proxies that need it.
if transports[i] == transport.TLS {
Expand Down

0 comments on commit 04af1c6

Please sign in to comment.