static void WhoisDealing(string zone) { try { string whoisinfo = WhoisHelper.SearchAWhois(zone); string servername = WhoisHelper.GetDnsServersStr(whoisinfo); if (servername.ToLower().Contains("xundns.com")) { MySQLHelper.ExecuteSql("update zonestemp set isload=1 where zone='" + zone + "'"); } else { MySQLHelper.ExecuteSql("update zonestemp set isload=-1 where zone='" + zone + "'"); } } catch (Exception ex) { MySQLHelper.ExecuteSql("update zonestemp set isload=-2 where zone='" + zone + "'"); Write2File.WriteLogToFile(zone + " whoisException " + ex.ToString()); } }
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(); }