C # Implementing the DNS Resolution service

Source: Internet
Author: User

Using ARSoft.Tools.Net to implement a client-side DNS resolution service, this tool allows you to see if the current client resolves a domain name with the correct address.

ARSoft.Tools.Net is a very powerful library of open source DNS controls, including. Net SPF validation, SenderID validation, and DNS Client, DNS server interfaces.

This interface makes it easy to implement DNS client-side and server-side resolution. Project address: http://arsofttoolsnet.codeplex.com/or reference: http://i.isclab.org/?p=327

The main code of the tool:

1         Private voidBtndns_click (Objectsender, EventArgs e)2         {3             intQuery_timeout =10000;4             stringDomain =Txtdomain.text;5             stringDNSADDR =Txtdnsaddr.text;6 txtresult.clear ();7btndns.enabled =false;8Btndns.text ="parsing ...";9             NewThread (() =Ten             { One                 if(string. Isnullorwhitespace (domain)) A                 { -MessageBox.Show ("the domain name to be resolved cannot be empty"); -                     return; the                 } -                 if(string. Isnullorwhitespace (DNSADDR)) -                 { -MessageBox.Show ("DNS address is not nullable"); +                     return; -                 } +                 //Initialize dnsclient, the first parameter is the IP of the DNS server, the second parameter is the time-out A                 //dnsclient dnsclient = new Dnsclient (Ipaddress.parse ("8.8.8.8"), query_timeout); atDnsclient dnsclient =Newdnsclient (Ipaddress.parse (DNSADDR), query_timeout); -                 //resolves the domain name. Send the domain request to the DNS server resolution, the first parameter is the domain name that needs to be resolved, the second parameter is the resolution type, RECORDTYPE.A is the IPV4 type -                 //dnsmessage dnsmessage = dnsclient.resolve ("sso.zt-express.com", recordtype.a); -Dnsmessage Dnsmessage =dnsclient.resolve (domain, recordtype.a); -                 //If the returned result is empty, or if there is an error, the request fails.  -                 if(Dnsmessage = =NULL|| (Dnsmessage.returncode! = Returncode.noerror && Dnsmessage.returncode! =returncode.nxdomain)) in                 { -                     //return null; to                     //Console.WriteLine ("No resolution succeeded"); +                      This. Invoke (NewAction (() = -                     { theTxtresult.text ="No resolution succeeded"; *btndns.enabled =true; $Btndns.text ="parsing";Panax Notoginseng  -                     })); the                 } +                 Else A                 { the                     //loops through the returned results, adding the returned IPV4 records to the result set list.  +                     foreach(Dnsrecordbase Dnsrecordinchdnsmessage.answerrecords) -                     { $Arecord Arecord = Dnsrecord asArecord; $                         if(Arecord! =NULL) -                         { -                             //Resultiplist.add (aRecord.Address.ToString ()); the                             //Console.WriteLine (aRecord.Address.ToString ()); -                              This. Invoke (NewAction (() =Wuyi                                     { theTxtresult.appendtext (aRecord.Address.ToString () +"\ r \ n"); -                                 })); Wu                         } -                         Else About                         { $                             Continue; -                         } -                     } -                      This. Invoke (NewAction (() = A                     { +btndns.enabled =true; theBtndns.text ="parsing"; -                     })); $  the                 } the  the             }). Start (); the  -}

Tool: Http://files.cnblogs.com/files/hnsongbiao/Release.rar

C # Implementing the DNS Resolution service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.