import ipaddress


def ip_itoa(ip: int, v6: bool) -> str:
    """Converts an IP integer 'ip' to a string."""
    if v6:
        return str(ipaddress.IPv6Address(ip))
    else:
        return str(ipaddress.IPv4Address(ip))