Пример #1
0
        static void QueryDNSAnalysis()
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Start();//开始计时
            DataSet ds = MySQLHelper.Query("select zone from zonestemp where nsstate not in(1,2,4) and isload=0 limit 0,100");

            DataTable dt      = ds.Tables[0];
            long      count   = dt.Rows.Count;
            int       isright = 0;

            string[] dnsserver = new string[] { "114.114.114.114", "117.50.11.11", "180.76.76.76", "210.2.4.8", "101.226.4.6", "123.125.81.6", "202.141.162.123", "123.206.61.167", "101.6.6.6", "123.206.61.167" };
            for (int idx = 0; idx < count; idx++)
            {
                string zone = dt.Rows[idx][0].ToString();
                int    aidx = idx % 10;
                try
                {
                    DNS.Client.ClientResponse respon = new DNS.Client.DnsClient(dnsserver[aidx]).Resolve(zone, DNS.Protocol.RecordType.NS);
                    if (respon.AnswerRecords.Count > 0)
                    {
                        DNS.Protocol.ResourceRecords.NameServerResourceRecord r = (DNS.Protocol.ResourceRecords.NameServerResourceRecord)respon.AnswerRecords[0];
                        if (r.NSDomainName.ToString().ToLower().Contains("xundns.com"))
                        {
                            MySQLHelper.ExecuteSql("update zonestemp set isload=1 where zone='" + zone + "'");
                            isright++;
                        }
                        else
                        {
                            MySQLHelper.ExecuteSql("update zonestemp set isload=-1 where zone='" + zone + "'");
                        }
                    }
                    else
                    {
                        WhoisDealing(zone);
                    }
                    Thread.Sleep(200);
                }
                catch (Exception ex)
                {
                    Write2File.WriteLogToFile(zone + "   use " + dnsserver[aidx] + "   " + ex.ToString());
                    Console.WriteLine(zone + " use " + dnsserver[aidx] + " query faile");
                    WhoisDealing(zone);
                    Console.WriteLine("mission restart");
                    QueryDNSAnalysis();
                }
            }
            Console.WriteLine("mission over");
            if (Convert.ToInt32(MySQLHelper.Query("select count(1) from zonestemp where nsstate not in(1,2,4) and isload=0 limit 0,100").Tables[0].Rows[0][0]) > 0)
            {
                QueryDNSAnalysis();
            }
            watch.Stop();
        }
Пример #2
0
        static void WhoisInfoDeal()
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            watch.Start();//开始计时
            DataSet ds = MySQLHelper.Query("select zone from zones where nsstate=1 limit 0,100");

            DataTable dt    = ds.Tables[0];
            long      count = dt.Rows.Count;

            Console.WriteLine("Query Success " + count.ToString() + "   use time " + watch.ElapsedMilliseconds.ToString());
            int isright = 0;
            int iswrong = 0;

            string[] dnsserver = new string[] { "114.114.114.114", "223.5.5.5", "180.76.76.76", "119.29.29.29", "101.226.4.6", "123.125.81.6", "202.141.162.123", "123.206.61.167", "101.6.6.6", "8.8.8.8" };
            for (int idx = 0; idx < count; idx++)
            {
                DataRow dr   = dt.Rows[idx];
                string  zone = dr[0].ToString();
                if (zone.EndsWith(".info") || zone.EndsWith(".cn"))
                {
                    string nsname = WhoisHelper.GetDnsServersStr(WhoisHelper.SearchAWhois(zone));

                    if (nsname.ToLower().Contains("xundns.com"))
                    {
                        //Write2File.WriteToFile("update zonestemp set isload=1 where zone='" + zone + "'");
                        MySQLHelper.ExecuteSql("update zonestemp set isload=1 where zone='" + zone + "'");
                        Console.WriteLine(zone + " is here use time" + watch.ElapsedMilliseconds);
                        isright++;
                    }
                    else
                    {
                        iswrong++;
                    }
                }
                else
                {
                    try
                    {
                        int aidx = idx % 10;
                        DNS.Client.ClientResponse respon = new DNS.Client.DnsClient(dnsserver[aidx]).Resolve(zone, DNS.Protocol.RecordType.NS);
                        if (respon.AnswerRecords.Count > 0)
                        {
                            DNS.Protocol.ResourceRecords.NameServerResourceRecord r = (DNS.Protocol.ResourceRecords.NameServerResourceRecord)respon.AnswerRecords[0];

                            if (r.NSDomainName.ToString().ToLower().Contains("xundns.com"))
                            {
                                Write2File.WriteToFile("update zonestemp set isload=1 where zone='" + zone + "'");
                                Console.WriteLine(zone + " is here use time" + watch.ElapsedMilliseconds);
                                isright++;
                            }
                        }
                        else
                        {
                            iswrong++;
                        }
                        Thread.Sleep(500);
                    }
                    catch (Exception ex) {
                        string re = ex.ToString();
                    }
                }
                if (iswrong % 10 == 0 && iswrong > 0)
                {
                    Console.WriteLine(iswrong.ToString() + " is not here use time" + watch.ElapsedMilliseconds);
                }
            }
            Console.WriteLine(isright.ToString() + " Rows Updated;   use time" + watch.ElapsedMilliseconds.ToString());
            watch.Stop();
        }