def get_ips()

in zktraffic/cli/zk.py [0:0]


def get_ips(host, port=0):
  """ lookup all IPs (v4 and v6) """
  ips = set()

  for af_type in (socket.AF_INET, socket.AF_INET6):
    try:
      records = socket.getaddrinfo(host, port, af_type, socket.SOCK_STREAM)
      ips.update(rec[4][0] for rec in records)
    except socket.gaierror as ex:
      if af_type == socket.AF_INET:
        sys.stderr.write("Skipping host: no IPv4s for %s\n" % host)
      else:
        sys.stderr.write("Skipping host: no IPv6s for %s\n" % host)

  return ips