コード例 #1
0
ファイル: DnsQueryRequest.cs プロジェクト: Kim-SSi/DnDns
 public DnsQueryResponse Resolve(string host, NsType queryType, NsClass queryClass, ProtocolType protocol, TsigMessageSecurityProvider provider)
 {
     foreach (var server in GetDnsServers())
     {
         try {
             return(Resolve(server, host, queryType, queryClass, protocol, provider));
         } catch (Exception ex) {
             Console.WriteLine(string.Format("DnsQueryRequest.Resolve: Could not resolve host {0}: {1}", host, ex));
         }
     }
     return(null);
 }
コード例 #2
0
        public async Task <DnsQueryResponse> Resolve(string host, NsType queryType, NsClass queryClass, ProtocolType protocol, TsigMessageSecurityProvider provider)
        {
            string dnsServer = string.Empty;

            IPAddressCollection dnsServerCollection = Tools.DiscoverDnsServerAddresses();

            if (dnsServerCollection.Count == 0)
            {
                throw new Exception("Couldn't detect local DNS Server.");
            }

            dnsServer = dnsServerCollection[0].ToString();

            if (String.IsNullOrEmpty(dnsServer))
            {
                throw new Exception("Couldn't detect local DNS Server.");
            }

            return(await Resolve(dnsServer, host, queryType, queryClass, protocol, provider));
        }
コード例 #3
0
        public DnsQueryResponse Resolve(string host, NsType queryType, NsClass queryClass, ProtocolType protocol, TsigMessageSecurityProvider provider)
        {
            string dnsServer = string.Empty;

            // Test for Unix/Linux OS
            if (Tools.IsPlatformLinuxUnix())
            {
                dnsServer = Tools.DiscoverUnixDnsServerAddress();
            }
            else
            {
                IPAddressCollection dnsServerCollection = Tools.DiscoverDnsServerAddresses();
                if (dnsServerCollection.Count == 0)
                {
                    throw new Exception("Couldn't detect local DNS Server.");
                }

                dnsServer = dnsServerCollection[0].ToString();
            }

            if (String.IsNullOrEmpty(dnsServer))
            {
                throw new Exception("Couldn't detect local DNS Server.");
            }

            return(Resolve(dnsServer, host, queryType, queryClass, protocol, provider));
        }