Skip to content

Commit

Permalink
Re-use unique function to check resolver validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Aug 10, 2015
1 parent 8cbdc56 commit 21c43d0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions records/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,14 @@ func validateResolvers(rs []string) error {
if len(rs) == 0 {
return nil
}
ips := make(map[string]struct{}, len(rs))
if len(rs) != len(unique(rs)) {
return fmt.Errorf("duplicate resolver IP specified")
}
for _, r := range rs {
ip := net.ParseIP(r)
if ip == nil {
return fmt.Errorf("illegal IP specified for resolver %q", r)
}
ipstr := ip.String()
if _, found := ips[ipstr]; found {
return fmt.Errorf("duplicate resolver IP specified: %v", r)
}
ips[ipstr] = struct{}{}
}
return nil
}
Expand Down

0 comments on commit 21c43d0

Please sign in to comment.