mirror of https://github.com/status-im/consul.git
command: warn when passing -encrypt when keyring already exists
This commit is contained in:
parent
471ee9ce8f
commit
b1c0bb60ce
|
@ -219,6 +219,13 @@ func (c *Command) readConfig() *Config {
|
||||||
c.Ui.Error("WARNING: Windows is not recommended as a Consul server. Do not use in production.")
|
c.Ui.Error("WARNING: Windows is not recommended as a Consul server. Do not use in production.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn if an encryption key is passed while a keyring already exists
|
||||||
|
if config.EncryptKey != "" && config.CheckKeyringFiles() {
|
||||||
|
c.Ui.Error(fmt.Sprintf(
|
||||||
|
"WARNING: Keyring already exists, ignoring new key %s",
|
||||||
|
config.EncryptKey))
|
||||||
|
}
|
||||||
|
|
||||||
// Set the version info
|
// Set the version info
|
||||||
config.Revision = c.Revision
|
config.Revision = c.Revision
|
||||||
config.Version = c.Version
|
config.Version = c.Version
|
||||||
|
@ -586,6 +593,9 @@ func (c *Command) Run(args []string) int {
|
||||||
}(wp)
|
}(wp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine if gossip is encrypted
|
||||||
|
gossipEncrypted := (config.EncryptKey != "" || config.CheckKeyringFiles())
|
||||||
|
|
||||||
// Let the agent know we've finished registration
|
// Let the agent know we've finished registration
|
||||||
c.agent.StartSync()
|
c.agent.StartSync()
|
||||||
|
|
||||||
|
@ -598,7 +608,7 @@ func (c *Command) Run(args []string) int {
|
||||||
c.Ui.Info(fmt.Sprintf(" Cluster Addr: %v (LAN: %d, WAN: %d)", config.AdvertiseAddr,
|
c.Ui.Info(fmt.Sprintf(" Cluster Addr: %v (LAN: %d, WAN: %d)", config.AdvertiseAddr,
|
||||||
config.Ports.SerfLan, config.Ports.SerfWan))
|
config.Ports.SerfLan, config.Ports.SerfWan))
|
||||||
c.Ui.Info(fmt.Sprintf("Gossip encrypt: %v, RPC-TLS: %v, TLS-Incoming: %v",
|
c.Ui.Info(fmt.Sprintf("Gossip encrypt: %v, RPC-TLS: %v, TLS-Incoming: %v",
|
||||||
config.EncryptKey != "", config.VerifyOutgoing, config.VerifyIncoming))
|
gossipEncrypted, config.VerifyOutgoing, config.VerifyIncoming))
|
||||||
|
|
||||||
// Enable log streaming
|
// Enable log streaming
|
||||||
c.Ui.Info("")
|
c.Ui.Info("")
|
||||||
|
|
|
@ -411,6 +411,18 @@ func (c *Config) ClientListenerAddr(override string, port int) (string, error) {
|
||||||
return addr.String(), nil
|
return addr.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckKeyringFiles checks for existence of the keyring files for Serf
|
||||||
|
func (c *Config) CheckKeyringFiles() bool {
|
||||||
|
serfDir := filepath.Join(c.DataDir, "serf")
|
||||||
|
if _, err := os.Stat(filepath.Join(serfDir, "keyring_lan")); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if _, err := os.Stat(filepath.Join(serfDir, "keyring_wan")); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// DecodeConfig reads the configuration from the given reader in JSON
|
// DecodeConfig reads the configuration from the given reader in JSON
|
||||||
// format and decodes it into a proper Config structure.
|
// format and decodes it into a proper Config structure.
|
||||||
func DecodeConfig(r io.Reader) (*Config, error) {
|
func DecodeConfig(r io.Reader) (*Config, error) {
|
||||||
|
|
Loading…
Reference in New Issue