Commit 04af1c69 authored by Ruslan Drozhdzh's avatar Ruslan Drozhdzh Committed by GitHub

plugin/forward: init ClientSessionCache in tls.Config (#4108)

* 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: default avatarRuslan Drozhdzh <rdrozhdzh@infoblox.com>

* add comment
Signed-off-by: default avatarRuslan Drozhdzh <rdrozhdzh@infoblox.com>
parent ca43f845
package forward package forward
import ( import (
"crypto/tls"
"errors" "errors"
"fmt" "fmt"
"strconv" "strconv"
...@@ -117,6 +118,11 @@ func parseStanza(c *caddy.Controller) (*Forward, error) { ...@@ -117,6 +118,11 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
if f.tlsServerName != "" { if f.tlsServerName != "" {
f.tlsConfig.ServerName = 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 { for i := range f.proxies {
// Only set this for proxies that need it. // Only set this for proxies that need it.
if transports[i] == transport.TLS { if transports[i] == transport.TLS {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment