Skip to content

Commit

Permalink
embed: check 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 9, 2017
1 parent 0441345 commit a5dc6ed
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions embed/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ func (cfg *Config) Validate() error {
if err := checkBindURLs(cfg.ListenMetricsUrls); err != nil {
return err
}
if err := checkHostURLs(cfg.APUrls); err != nil {
return err
}
if err := checkHostURLs(cfg.ACUrls); err != nil {
return err
}

// Check if conflicting flags are passed.
nSet := 0
Expand Down Expand Up @@ -484,3 +490,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 a5dc6ed

Please sign in to comment.