consul: Server initializes pool with TLS settings

pull/28/head
Armon Dadgar 11 years ago
parent 00ec592dd1
commit f68d3160d2

@ -1,6 +1,7 @@
package consul package consul
import ( import (
"crypto/tls"
"fmt" "fmt"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
"github.com/hashicorp/serf/serf" "github.com/hashicorp/serf/serf"
@ -122,13 +123,22 @@ func NewServer(config *Config) (*Server, 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
s := &Server{ s := &Server{
config: config, config: config,
connPool: NewPool(time.Minute), connPool: NewPool(time.Minute, tlsConfig),
eventChLAN: make(chan serf.Event, 256), eventChLAN: make(chan serf.Event, 256),
eventChWAN: make(chan serf.Event, 256), eventChWAN: make(chan serf.Event, 256),
logger: logger, logger: logger,
@ -156,7 +166,6 @@ func NewServer(config *Config) (*Server, error) {
go s.wanEventHandler() go s.wanEventHandler()
// Initialize the lan Serf // Initialize the lan Serf
var err error
s.serfLAN, err = s.setupSerf(config.SerfLANConfig, s.serfLAN, err = s.setupSerf(config.SerfLANConfig,
s.eventChLAN, serfLANSnapshot) s.eventChLAN, serfLANSnapshot)
if err != nil { if err != nil {

Loading…
Cancel
Save