Ejemplo n.º 1
0
        private static List <String> DnsProbeTXT(string value)
        {
            List <String> ret = new List <string>();

            DnDns.Query.DnsQueryRequest  r   = new DnDns.Query.DnsQueryRequest();
            DnDns.Query.DnsQueryResponse res = null;
            try
            {
                res = r.Resolve(value, DnDns.Enums.NsType.TXT, DnDns.Enums.NsClass.INET, System.Net.Sockets.ProtocolType.Udp);
            }
            catch (Exception ex)
            {
            }
            if (res == null)
            {
                return(ret);
            }
            if (res.Answers == null)
            {
                return(ret);
            }

            foreach (IDnsRecord r1 in res.Answers)
            {
                string s = r1.Answer;
                try
                {
                    if (!String.IsNullOrEmpty(s))
                    {
                        s = s.Trim();
                        if (!String.IsNullOrEmpty(s))
                        {
                            Uri u = null;
                            u = new Uri(s);
                            ret.Add(s);
                        }
                    }
                }
                catch
                {
                    Logger.warn("DNS Discovery, throwing out the value " + r1.Answer + " as it is not a valid uri");
                }
            }

            return(ret);
        }
Ejemplo n.º 2
0
        private static List<String> DnsProbeTXT(string value)
        {
            List<String> ret = new List<string>();
            DnDns.Query.DnsQueryRequest r = new DnDns.Query.DnsQueryRequest();
            DnDns.Query.DnsQueryResponse res = null;
            try
            {
                res = r.Resolve(value, DnDns.Enums.NsType.TXT, DnDns.Enums.NsClass.INET, System.Net.Sockets.ProtocolType.Udp);
            }
            catch (Exception ex)
            {

            }
            if (res == null)
                return ret;
            if (res.Answers == null)
                return ret;

            foreach (IDnsRecord r1 in res.Answers)
            {
                string s = r1.Answer;
                try
                {
                    if (!String.IsNullOrEmpty(s))
                    {
                        s = s.Trim();
                        if (!String.IsNullOrEmpty(s))
                        {
                            Uri u = null;
                            u = new Uri(s);
                            ret.Add(s);
                        }
                    }
                }
                catch
                {
                    Logger.warn("DNS Discovery, throwing out the value " + r1.Answer + " as it is not a valid uri");
                }
            }

            return ret;
        }