示例#1
0
        public static string[] GetIPAddresses(string domain, DNS.Protocol.RecordType type)
        {
            // This client is probably heavy? Maybe I should have just one
            // NOTE: This is hardcoded to Google's DNS servers. I'd prefer to use
            // the system DNS but ATM (a) I don't know how to find it and (b)
            // .NET/mono is broken
            DNS.Client.DnsClient         client = new DNS.Client.DnsClient("8.8.8.8");
            IList <System.Net.IPAddress> ips    = client.Lookup(domain, type);
            List <string> addresses             = new List <string>();

            foreach (var ip in ips)
            {
                addresses.Add(ip.ToString());
            }
            return(addresses.ToArray());
        }
示例#2
0
 string[] GetIPAddresses(DNS.Protocol.RecordType type)
 {
     // This part sucks. Basically I don't know how to make ipv6 and ipv4 requests in .NET
     // so my hacky workaround is to look up the addresses directly
     // BUT, if the user specifices an address URL or a local URL I'm SOL basically
     // I just pass them through if I can't find them
     if (rendezvousUri_.HostNameType != System.UriHostNameType.IPv4 &&
         rendezvousUri_.HostNameType != System.UriHostNameType.IPv6)
     {
         string[] addresses = HFTDnsUtils.GetIPAddresses(rendezvousUri_.DnsSafeHost, type);
         if (addresses != null && addresses.Length > 0)
         {
             return(addresses);
         }
     }
     return(new string[] {
         rendezvousUri_.Host,
     });
 }
示例#3
0
        public static string[] GetIPAddresses(string domain, DNS.Protocol.RecordType type)
        {
            // This client is probably heavy? Maybe I should have just one
            // NOTE: This is hardcoded to Google's DNS servers. I'd prefer to use
            // the system DNS but ATM (a) I don't know how to find it and (b)
            // .NET/mono is broken
            DNS.Client.DnsClient client    = new DNS.Client.DnsClient("8.8.8.8");
            List <string>        addresses = new List <string>();

            try
            {
                IList <System.Net.IPAddress> ips = client.Lookup(domain, type);
                foreach (var ip in ips)
                {
                    addresses.Add(ip.ToString());
                }
            }
            catch (DNS.Client.ResponseException ex)
            {
                var log = new HFTLog("HFTDnsUtils");
                log.Warn(String.Format("error getting DNS {0} record for {1}: {2}", type, domain, ex.ToString()));
            }
            return(addresses.ToArray());
        }