mirror of https://github.com/status-im/consul.git
consul: Client initializes TLS settings
This commit is contained in:
parent
7beac2a1bc
commit
00ec592dd1
|
@ -1,6 +1,7 @@
|
||||||
package consul
|
package consul
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hashicorp/consul/consul/structs"
|
"github.com/hashicorp/consul/consul/structs"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
|
@ -78,13 +79,22 @@ func NewClient(config *Config) (*Client, error) {
|
||||||
config.LogOutput = os.Stderr
|
config.LogOutput = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the tlsConfig
|
||||||
|
var tlsConfig *tls.Config
|
||||||
|
var err error
|
||||||
|
if config.VerifyOutgoing {
|
||||||
|
if tlsConfig, err = config.OutgoingTLSConfig(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create a logger
|
// Create a logger
|
||||||
logger := log.New(config.LogOutput, "", log.LstdFlags)
|
logger := log.New(config.LogOutput, "", log.LstdFlags)
|
||||||
|
|
||||||
// Create server
|
// Create server
|
||||||
c := &Client{
|
c := &Client{
|
||||||
config: config,
|
config: config,
|
||||||
connPool: NewPool(clientRPCCache),
|
connPool: NewPool(clientRPCCache, tlsConfig),
|
||||||
eventCh: make(chan serf.Event, 256),
|
eventCh: make(chan serf.Event, 256),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
shutdownCh: make(chan struct{}),
|
shutdownCh: make(chan struct{}),
|
||||||
|
@ -94,7 +104,6 @@ func NewClient(config *Config) (*Client, error) {
|
||||||
go c.lanEventHandler()
|
go c.lanEventHandler()
|
||||||
|
|
||||||
// Initialize the lan Serf
|
// Initialize the lan Serf
|
||||||
var err error
|
|
||||||
c.serf, err = c.setupSerf(config.SerfLANConfig,
|
c.serf, err = c.setupSerf(config.SerfLANConfig,
|
||||||
c.eventCh, serfLANSnapshot)
|
c.eventCh, serfLANSnapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue