Ejemplo n.º 1
0
        protected void Button1_Click(object sender, System.EventArgs e)
        {
            dnsquery1.Server = edtServer.Text;

            string type = cbType.SelectedValue;

            if (type == "MX")
            {
                dnsquery1.ResolveMX(edtName.Text);
            }
            else if (type == "A")
            {
                dnsquery1.ResolveIP(edtName.Text);
            }
            else if (type == "PTR")
            {
                dnsquery1.ResolveHost(edtName.Text);
            }
            else if (type == "NS")
            {
                dnsquery1.ResolveNS(edtName.Text);
            }

            edtResult.Text = "";

            if (dnsquery1.MailServers.Count > 0)
            {
                edtResult.Text += "Mail Servers:\r\n";
            }
            foreach (MailServerInfo mx in dnsquery1.MailServers)
            {
                edtResult.Text += mx.Preference.ToString() + " - " + mx.Name + " - " + mx.IPAddress + "\r\n";
            }

            if (dnsquery1.Hosts.Count > 0)
            {
                edtResult.Text += "Hosts:\r\n";
            }
            foreach (HostInfo host in dnsquery1.Hosts)
            {
                edtResult.Text += host.Name + " - " + host.IPAddress + "\r\n";
            }

            if (dnsquery1.NameServers.Length > 0)
            {
                edtResult.Text += "Name Servers:\r\n";
            }
            foreach (string ns in dnsquery1.NameServers)
            {
                edtResult.Text += ns + "\r\n";
            }
        }
        private void btnResolve_Click(object sender, System.EventArgs e)
        {
            dnsQuery1.Server  = edtDnsServer.Text;
            dnsQuery1.Port    = Convert.ToInt32(edtPort.Text);
            dnsQuery1.TimeOut = Convert.ToInt32(edtTimeOut.Text) * 1000;

            try {
                switch (cbNameType.SelectedIndex)
                {
                case 0: dnsQuery1.ResolveMX(edtName.Text); break;

                case 1: dnsQuery1.ResolveIP(edtName.Text); break;

                case 2: dnsQuery1.ResolveHost(edtName.Text); break;

                case 3: dnsQuery1.ResolveNS(edtName.Text); break;
                }

                memResult.Text = "";

                FillMXResult();
                FillHostResult();
                FillNameServerResult();
                FillAliasResult();

                if (StringUtils.IsEmpty(edtDnsServer.Text))
                {
                    edtDnsServer.Text = dnsQuery1.Server;
                }

                MessageBox.Show("Done");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }