コード例 #1
0
ファイル: frmDnsCheck.cs プロジェクト: slavat/MailSystem.NET
        private void btnLookUp_Click(object sender, EventArgs e)
        {
            //Lookup Resource Record,
            //Enter App in Wait State
            //Print Result, Exit

            if (txtHost.Text == null || txtHost.Text.Length == 0)
            {
                MessageBox.Show("Enter valid Host!");
                txtHost.Focus();
                return;
            }

            Application.DoEvents();
            sbrResult.Text = "Please wait...";
            this.Enabled   = false;
            Application.DoEvents();


            DnsQuery query = new DnsQuery();

            query.Domain    = txtHost.Text;
            query.DnsServer = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(txtDNS.Text.Trim()), 53);
            try
            {
                DnsAnswer answer = query.QueryServer(ParseEnumFromCombo());
                if (answer != null)
                {
                    DNS.frmDNSResult result = new ActiveUp.Net.Samples.Compact.DNS.frmDNSResult();
                    result.Output = answer;
                    result.ShowDialog();
                    result.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            sbrResult.Text = "Ready";
            this.Enabled   = true;
            EnableControls();
            Application.DoEvents();
        }
コード例 #2
0
        /// <summary>
        /// Get the MX records for the specified domain name using the specified DNS server.
        /// </summary>
        /// <param name="address">The domain name.</param>
        /// <param name="host">The host name of the DNS server to use.</param>
        /// <param name="port">The port number of the DNS server to use.</param>
        /// <param name="timeout">The timeout in miliseconds.</param>
        /// <returns>A collection of Mx Records.</returns>
        public static MxRecordCollection GetMxRecords(string address, string host, int port, int timeout)
        {
            var mxRecords = new MxRecordCollection();
            var query     = new DnsQuery(IPAddress.Parse(host))
            {
                RecursiveQuery = true,
                DnsServer      = { Port = port },
                Domain         = address
            };
            DnsAnswer answer = query.QueryServer(RecordType.MX, timeout);

            foreach (Answer entry in answer.Answers)
            {
                var mxRecord = (MXRecord)entry.Data;
                mxRecords.Add(mxRecord.Domain, mxRecord.Preference);
            }

            return(mxRecords);
        }
コード例 #3
0
ファイル: RblServer.cs プロジェクト: zvit-cc/MailSystem.NET
        /// <summary>
        /// Gets the RBL ip.
        /// </summary>
        /// <param name="rblServer">The RBL server.</param>
        /// <param name="ip">The ip.</param>
        /// <returns></returns>
        public IPAddress GetRblIp(string rblServer, IPAddress ip)
        {
            DnsQuery query = new DnsQuery("213.254.203.215");

            byte[] addressBytes = ip.GetAddressBytes();
            string domain       = string.Format("{0}.{1}.{2}.{3}.{4}", addressBytes[3].ToString(),
                                                addressBytes[2].ToString(), addressBytes[1].ToString(), addressBytes[0].ToString(), rblServer);

            query.Domain = domain;
            DnsAnswer answer = query.QueryServer(RecordType.A);

            if (answer == null || answer.Answers.Count == 0)
            {
                return(null);
            }

            string result = answer.Answers[0].Data.ToString().Replace("IP Address: ", "");

            return(IPAddress.Parse(result));
        }
コード例 #4
0
ファイル: Validator.cs プロジェクト: slavat/MailSystem.NET
        /// <summary>
        /// Get the MX records for the specified domain name using the specified DNS server.
        /// </summary>
        /// <param name="address">The domain name.</param>
        /// <param name="host">The host name of the DNS server to use.</param>
        /// <param name="port">The port number of the DNS server to use.</param>
        /// <param name="timeout">The timeout in miliseconds.</param>
        /// <returns>A collection of Mx Records.</returns>
        public static ActiveUp.Net.Mail.MxRecordCollection GetMxRecords(string address, string host, int port, int timeout)
        {
            MxRecordCollection mxRecords = new MxRecordCollection();

            DnsQuery query = new DnsQuery(IPAddress.Parse(host));

            query.RecursiveQuery = true;
            query.DnsServer.Port = port;
            query.Domain         = address;

            DnsAnswer answer = query.QueryServer(RecordType.MX, timeout);

            foreach (DnsEntry entry in answer.Answers)
            {
                MXRecord mxRecord = (MXRecord)entry.Data;

                mxRecords.Add(mxRecord.Domain, mxRecord.Preference);
            }

            return(mxRecords);
        }