def parse_url(url):
    """Parse a Elk connection string """
    scheme, dest = url.split('://')
    host = None
    ssl_context = None
    if scheme == 'elk':
        host, port = dest.split(':') if ':' in dest else (dest, 2101)
    elif scheme == 'elks':
        host, port = dest.split(':') if ':' in dest else (dest, 2601)
        ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        ssl_context.verify_mode = ssl.CERT_NONE
    elif scheme == 'serial':
        host, port = dest.split(':') if ':' in dest else (dest, 115200)
    else:
        raise ValueError("Invalid scheme '%s'" % scheme)
    return (scheme, host, int(port), ssl_context)
Parse a Elk connection string