Example #1
0
    private async IAsyncEnumerable <string> SearchNode(IDnsClient client, string query, SearchContext searchContext)
    {
        if (!searchContext.VisitedRefs.Contains(query))
        {
            searchContext.VisitedRefs.Add(query);
            IEnumerable <string> lookupResult = await client.Lookup(query);

            foreach (string node in lookupResult)
            {
                EnrTreeNode treeNode = EnrTreeParser.ParseNode(node);
                foreach (string link in treeNode.Links)
                {
                    DnsClient linkedTreeLookup = new(link);
                    await foreach (string nodeRecordText in SearchTree(linkedTreeLookup, searchContext))
                    {
                        yield return(nodeRecordText);
                    }
                }

                foreach (string nodeRecordText in treeNode.Records)
                {
                    yield return(nodeRecordText);
                }

                foreach (string nodeRef in treeNode.Refs)
                {
                    searchContext.RefsToVisit.Enqueue(nodeRef);
                }
            }
        }
    }