Adding utility method to parse consul nodes

This commit is contained in:
Armon Dadgar 2014-01-09 15:45:14 -08:00
parent a0338f14cd
commit 1f3934bcc0
1 changed files with 13 additions and 0 deletions

View File

@ -78,6 +78,19 @@ func isConsulServer(m serf.Member) (bool, string, int) {
return true, datacenter, port
}
// Returns if a member is a consul node. Returns a boo,
// and the data center.
func isConsulNode(m serf.Member) (bool, string) {
role := m.Role
if !strings.HasPrefix(role, "node:") {
return false, ""
}
parts := strings.SplitN(role, ":", 2)
datacenter := parts[1]
return true, datacenter
}
// Returns if the given IP is in a private block
func isPrivateIP(ip_str string) bool {
ip := net.ParseIP(ip_str)