def _index_remote(cfg, remote_def):
    """ Finds the index of the remote_def in cfg. Returns None if the
    server is not contained in the cfg.
    
    Note that the index is only looking for host and port. TLS usage
    does not affect the remote index.
    """
    if 'remotes' not in cfg:
        return None
    for index, server in enumerate(cfg['remotes']):
        if server.host == remote_def.host and server.port == remote_def.port:
            return index
    else:
        return None
