Ejemplo n.º 1
0
        public async Task <bool> GetHost(string url, DNSState state)
        {
            try
            {
                IPHostEntry ret = await Dns.GetHostEntryAsync(url).ConfigureAwait(false);

                Log_Info("Success Lookup of " + url);
                state.AddAnswer(url, ret.AddressList[0].GetAddressBytes());
            }
            catch (SocketException ex)
            {
                Log_Error("Failed Lookup of " + url);
                if (ex.NativeErrorCode != 11001 & //Host not found (Authoritative)
                    ex.NativeErrorCode != 11002)  //Host not found (Non-Authoritative)
                {
                    Log_Error("Unexpected error of " + ex.NativeErrorCode);
                    lock (errSentry)
                        lastTaskError = ex;
                    return(false);
                }
            }
            if (state.DecCounter() == 0)
            {
                FinDNS(state);
            }

            return(true);
        }
Ejemplo n.º 2
0
 public bool CheckHost(string url, DNSState state)
 {
     if (hosts.ContainsKey(url.ToLower()))
     {
         state.AddAnswer(url, hosts[url]);
         Log_Info(url + " found in hosts");
         //Add entry to DNS state
         if (state.DecCounter() == 0)
         {
             FinDNS(state);
         }
         return(true);
     }
     return(false);
 }