mirror of https://github.com/status-im/consul.git
Adding utility method to parse consul nodes
This commit is contained in:
parent
a0338f14cd
commit
1f3934bcc0
|
@ -78,6 +78,19 @@ func isConsulServer(m serf.Member) (bool, string, int) {
|
||||||
return true, datacenter, port
|
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
|
// Returns if the given IP is in a private block
|
||||||
func isPrivateIP(ip_str string) bool {
|
func isPrivateIP(ip_str string) bool {
|
||||||
ip := net.ParseIP(ip_str)
|
ip := net.ParseIP(ip_str)
|
||||||
|
|
Loading…
Reference in New Issue