agent: add GossipEncrypted function

Remove dead code and expose a GossipEncrypted() method
on the agent instead of accessing the internal delegate.
pull/3108/head
Frank Schroeder 8 years ago committed by Frank Schröder
parent 65bbad0975
commit 55a513da2e

@ -1817,6 +1817,10 @@ func (a *Agent) purgeCheckState(checkID types.CheckID) error {
return err
}
func (a *Agent) GossipEncrypted() bool {
return a.delegate.Encrypted()
}
// Stats is used to get various debugging state from the sub-systems
func (a *Agent) Stats() map[string]map[string]string {
toString := func(v uint64) string {

@ -17,7 +17,6 @@ import (
"github.com/armon/go-metrics/circonus"
"github.com/armon/go-metrics/datadog"
"github.com/hashicorp/consul/command/base"
"github.com/hashicorp/consul/consul"
"github.com/hashicorp/consul/consul/structs"
"github.com/hashicorp/consul/ipaddr"
"github.com/hashicorp/consul/lib"
@ -596,24 +595,6 @@ func (cmd *Command) retryJoinWan(cfg *Config, errCh chan<- struct{}) {
}
}
// gossipEncrypted determines if the consul instance is using symmetric
// encryption keys to protect gossip protocol messages.
func (cmd *Command) gossipEncrypted() bool {
if cmd.agent.config.EncryptKey != "" {
return true
}
server, ok := cmd.agent.delegate.(*consul.Server)
if ok {
return server.KeyManagerLAN() != nil || server.KeyManagerWAN() != nil
}
client, ok := cmd.agent.delegate.(*consul.Client)
if ok {
return client != nil && client.KeyManagerLAN() != nil
}
panic(fmt.Sprintf("delegate is neither server nor client: %T", cmd.agent.delegate))
}
func (cmd *Command) Run(args []string) int {
cmd.UI = &cli.PrefixedUi{
OutputPrefix: "==> ",
@ -817,9 +798,6 @@ func (cmd *Command) Run(args []string) int {
}(wp)
}
// Figure out if gossip is encrypted
gossipEncrypted := cmd.agent.delegate.Encrypted()
// Let the agent know we've finished registration
cmd.agent.StartSync()
@ -834,7 +812,7 @@ func (cmd *Command) Run(args []string) int {
cmd.UI.Info(fmt.Sprintf(" Cluster Addr: %v (LAN: %d, WAN: %d)", config.AdvertiseAddr,
config.Ports.SerfLan, config.Ports.SerfWan))
cmd.UI.Info(fmt.Sprintf("Gossip encrypt: %v, RPC-TLS: %v, TLS-Incoming: %v",
gossipEncrypted, config.VerifyOutgoing, config.VerifyIncoming))
cmd.agent.GossipEncrypted(), config.VerifyOutgoing, config.VerifyIncoming))
// Enable log streaming
cmd.UI.Info("")

Loading…
Cancel
Save