Skip to content

Commit

Permalink
embed: warns about empty hosts in advertise urls
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Aug 10, 2017
1 parent 0441345 commit 6ad85d3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ func (cfg *Config) Validate() error {
if err := checkBindURLs(cfg.ListenMetricsUrls); err != nil {
return err
}
if err := checkHostURLs(cfg.APUrls); err != nil {
// TODO: return err in v3.4
plog.Warningf("advertise-peer-urls %+v is deprecated (%v)", cfg.APUrls, err)
}
if err := checkHostURLs(cfg.ACUrls); err != nil {
// TODO: return err in v3.4
plog.Warningf("advertise-client-urls %+v is deprecated (%v)", cfg.ACUrls, err)
}

// Check if conflicting flags are passed.
nSet := 0
Expand Down Expand Up @@ -484,3 +492,16 @@ func checkBindURLs(urls []url.URL) error {
}
return nil
}

func checkHostURLs(urls []url.URL) error {
for _, url := range urls {
host, _, err := net.SplitHostPort(url.Host)
if err != nil {
return err
}
if host == "" {
return fmt.Errorf("unexpected empty host (%s)", url.String())
}
}
return nil
}

0 comments on commit 6ad85d3

Please sign in to comment.