def normalize_ip(ip)
      case ip
      when nil then nil
      when String then IPAddr.new(ip)
      when Integer then IPAddr.new(ip, Socket::AF_INET)
      when IPAddr then ip
      else raise ArgumentError, "IP must be a String, IPAddr, or Integer, not: #{ip.inspect}"
      end
    end
def normalize_ip(ip)
      case ip
      when nil then nil
      when String then IPAddr.new(ip)
      when Integer then IPAddr.new(ip, Socket::AF_INET)
      when IPAddr then ip
      else raise ArgumentError, "IP must be a String, IPAddr, or Integer, not: #{ip.inspect}"
      end
    end
Accepts an IP address (or nil) in String, Integer, or IPAddr formats, and returns an IPAddr (or nil).