import socket


def ip_check(serverip):

    """ Taken from EARCIS code.
        Check if the server IP passed in is a valid IPv4/v6 address, if not, return False; otherwise, return True.
        Input: (serverip) % (str)
        Output: Boolean
    """

    try:
        socket.inet_aton(serverip) #Would fail if it is not a valid IPv4 address.
    
    except socket.error:
        
        try:
            socket.inet_pton(socket.AF_INET6, serverip) #Would fail if it is not a valid IPv6 address.
        
        except socket.error:
            return False
    
    return True