vendor/github.com/gorilla/websocket/client_clone_legacy.go
changeset 260 445e01aede7e
parent 259 db4911b0c721
child 261 270cc4dda0c5
equal deleted inserted replaced
259:db4911b0c721 260:445e01aede7e
     1 // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
       
     2 // Use of this source code is governed by a BSD-style
       
     3 // license that can be found in the LICENSE file.
       
     4 
       
     5 // +build !go1.8
       
     6 
       
     7 package websocket
       
     8 
       
     9 import "crypto/tls"
       
    10 
       
    11 // cloneTLSConfig clones all public fields except the fields
       
    12 // SessionTicketsDisabled and SessionTicketKey. This avoids copying the
       
    13 // sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
       
    14 // config in active use.
       
    15 func cloneTLSConfig(cfg *tls.Config) *tls.Config {
       
    16 	if cfg == nil {
       
    17 		return &tls.Config{}
       
    18 	}
       
    19 	return &tls.Config{
       
    20 		Rand:                     cfg.Rand,
       
    21 		Time:                     cfg.Time,
       
    22 		Certificates:             cfg.Certificates,
       
    23 		NameToCertificate:        cfg.NameToCertificate,
       
    24 		GetCertificate:           cfg.GetCertificate,
       
    25 		RootCAs:                  cfg.RootCAs,
       
    26 		NextProtos:               cfg.NextProtos,
       
    27 		ServerName:               cfg.ServerName,
       
    28 		ClientAuth:               cfg.ClientAuth,
       
    29 		ClientCAs:                cfg.ClientCAs,
       
    30 		InsecureSkipVerify:       cfg.InsecureSkipVerify,
       
    31 		CipherSuites:             cfg.CipherSuites,
       
    32 		PreferServerCipherSuites: cfg.PreferServerCipherSuites,
       
    33 		ClientSessionCache:       cfg.ClientSessionCache,
       
    34 		MinVersion:               cfg.MinVersion,
       
    35 		MaxVersion:               cfg.MaxVersion,
       
    36 		CurvePreferences:         cfg.CurvePreferences,
       
    37 	}
       
    38 }