Esempio n. 1
0
        private async Task <IP4Addr> Resolve(ParsedDomain domain)
        {
            if (domain.IsTopLevelDomain())
            {
                int     rootServerIndex = Interlocked.Increment(ref rootServerCounter) % dnsClient.GetRootServers().Count;
                IP4Addr rootServerIP    = dnsClient.GetRootServers()[rootServerIndex];
                return(dnsClient.Resolve(rootServerIP, domain.GetThisLevelSubdomain()).Result);
            }
            else
            {
                var upperLevelIP = await AssignResolverAndResolve(domain.GetUpperLevel());

                return(dnsClient.Resolve(upperLevelIP, domain.GetThisLevelSubdomain()).Result);
            }
        }
Esempio n. 2
0
 public Task <IP4Addr> ResolveRecursive(string domain)
 {
     return(Task <IP4Addr> .Run(() => {
         string[] domains = domain.Split('.');
         Array.Reverse(domains);
         IP4Addr res = dnsClient.GetRootServers()[0];
         foreach (var sub in domains)
         {
             var t = dnsClient.Resolve(res, sub);
             t.Wait();
             res = t.Result;
         }
         return res;
     }));
 }
Esempio n. 3
0
        private IP4Addr ResolveWithCache(string domain)
        {
            IP4Addr res = dnsClient.GetRootServers()[0];

            return(resolveSubDomain(domain, res));
        }