From 1a25f0f713c2a0b763d2ccece687bfc8c456fff4 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Mon, 24 Apr 2023 21:44:18 -0400 Subject: [PATCH] Minor GPT4 fixes --- cluster/join.go | 3 +-- cmd/rqlited/flags.go | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cluster/join.go b/cluster/join.go index ef233d57..ff678837 100644 --- a/cluster/join.go +++ b/cluster/join.go @@ -104,9 +104,8 @@ func (j *Joiner) Do(joinAddrs []string, id, addr string, voter bool) (string, er if err == nil { // Success! return joinee, nil - } else { - j.logger.Printf("failed to join via node at %s: %s", a, err) } + j.logger.Printf("failed to join via node at %s: %s", a, err) } if i+1 < j.numAttempts { // This logic message only make sense if performing more than 1 join-attempt. diff --git a/cmd/rqlited/flags.go b/cmd/rqlited/flags.go index 7cad5a4a..108edef4 100644 --- a/cmd/rqlited/flags.go +++ b/cmd/rqlited/flags.go @@ -287,7 +287,7 @@ func (c *Config) Validate() error { return errors.New("bootstrapping only applicable to voting nodes") } - // Join addresses OK? + // Join parameters OK? if c.JoinAddr != "" { addrs := strings.Split(c.JoinAddr, ",") for i := range addrs { @@ -302,6 +302,9 @@ func (c *Config) Validate() error { } } } + if c.JoinSrcIP != "" && net.ParseIP(c.JoinSrcIP) == nil { + return fmt.Errorf("invalid join source IP address: %s", c.JoinSrcIP) + } // Valid disco mode? switch c.DiscoMode { @@ -394,7 +397,7 @@ func ParseFlags(name, desc string, build *BuildInfo) (*Config, error) { flag.StringVar(&config.AuthFile, "auth", "", "Path to authentication and authorization file. If not set, not enabled") flag.StringVar(&config.RaftAddr, RaftAddrFlag, "localhost:4002", "Raft communication bind address") flag.StringVar(&config.RaftAdv, RaftAdvAddrFlag, "", "Advertised Raft communication address. If not set, same as Raft bind") - flag.StringVar(&config.JoinSrcIP, "join-source-ip", "", "Set source IP address during Join request") + flag.StringVar(&config.JoinSrcIP, "join-source-ip", "", "Set source IP address during HTTP Join request") flag.StringVar(&config.JoinAddr, "join", "", "Comma-delimited list of nodes, through which a cluster can be joined (proto://host:port)") flag.StringVar(&config.JoinAs, "join-as", "", "Username in authentication file to join as. If not set, joins anonymously") flag.IntVar(&config.JoinAttempts, "join-attempts", 5, "Number of join attempts to make")