def ip_str_to_bin(ip_str):
    """
    转化ip格式，从str转为bin
    支持ipv4/ipv6
    :param ip_str:
    :return: client_ip_num, ipv6
    """
    import socket
    if ':' in ip_str:
        client_ip_num = socket.inet_pton(socket.AF_INET6, ip_str)
        ipv6 = True
    else:
        client_ip_num = socket.inet_pton(socket.AF_INET, ip_str)
        ipv6 = False
    return client_ip_num, ipv6
