mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: copy all exported members in tls.Config
Without this, go vet complains assignment copies lock value to n: crypto/tls.Config contains sync.Once contains sync.Mutex
This commit is contained in:
parent
caffcb7fbb
commit
6557ef7cd8
@ -26,6 +26,7 @@ import (
|
||||
"github.com/coreos/etcd/etcdserver"
|
||||
"github.com/coreos/etcd/etcdserver/api/v3rpc"
|
||||
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||
"github.com/coreos/etcd/pkg/transport"
|
||||
|
||||
"github.com/cockroachdb/cmux"
|
||||
gw "github.com/gengo/grpc-gateway/runtime"
|
||||
@ -81,10 +82,10 @@ func serve(sctx *serveCtx, s *etcdserver.EtcdServer, tlscfg *tls.Config, handler
|
||||
gs := v3rpc.Server(s, tlscfg)
|
||||
handler = grpcHandlerFunc(gs, handler)
|
||||
|
||||
dtls := *tlscfg
|
||||
dtls := transport.ShallowCopyTLSConfig(tlscfg)
|
||||
// trust local server
|
||||
dtls.InsecureSkipVerify = true
|
||||
creds := credentials.NewTLS(&dtls)
|
||||
creds := credentials.NewTLS(dtls)
|
||||
opts := []grpc.DialOption{grpc.WithTransportCredentials(creds)}
|
||||
gwmux, err := registerGateway(sctx.l.Addr().String(), opts)
|
||||
if err != nil {
|
||||
|
@ -252,3 +252,32 @@ func (info TLSInfo) ClientConfig() (*tls.Config, error) {
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// ShallowCopyTLSConfig copies *tls.Config. This is only
|
||||
// work-around for go-vet tests, which complains
|
||||
//
|
||||
// assignment copies lock value to p: crypto/tls.Config contains sync.Once contains sync.Mutex
|
||||
//
|
||||
// Keep up-to-date with 'go/src/crypto/tls/common.go'
|
||||
func ShallowCopyTLSConfig(cfg *tls.Config) *tls.Config {
|
||||
ncfg := tls.Config{
|
||||
Time: cfg.Time,
|
||||
Certificates: cfg.Certificates,
|
||||
NameToCertificate: cfg.NameToCertificate,
|
||||
GetCertificate: cfg.GetCertificate,
|
||||
RootCAs: cfg.RootCAs,
|
||||
NextProtos: cfg.NextProtos,
|
||||
ServerName: cfg.ServerName,
|
||||
ClientAuth: cfg.ClientAuth,
|
||||
ClientCAs: cfg.ClientCAs,
|
||||
InsecureSkipVerify: cfg.InsecureSkipVerify,
|
||||
CipherSuites: cfg.CipherSuites,
|
||||
PreferServerCipherSuites: cfg.PreferServerCipherSuites,
|
||||
SessionTicketKey: cfg.SessionTicketKey,
|
||||
ClientSessionCache: cfg.ClientSessionCache,
|
||||
MinVersion: cfg.MinVersion,
|
||||
MaxVersion: cfg.MaxVersion,
|
||||
CurvePreferences: cfg.CurvePreferences,
|
||||
}
|
||||
return &ncfg
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user