Updated
This commit is contained in:
parent
c795fd71f5
commit
c3441efd31
|
@ -49,6 +49,12 @@
|
|||
this.StatusBox = new System.Windows.Forms.ListBox();
|
||||
this.chkDns1 = new System.Windows.Forms.CheckBox();
|
||||
this.chkDns2 = new System.Windows.Forms.CheckBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtResolveIP = new System.Windows.Forms.TextBox();
|
||||
this.txtResolveHost = new System.Windows.Forms.TextBox();
|
||||
this.btnResolveIP = new System.Windows.Forms.Button();
|
||||
this.btnResolveHost = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ResultView
|
||||
|
@ -231,7 +237,7 @@
|
|||
this.chkDns1.AutoSize = true;
|
||||
this.chkDns1.Checked = true;
|
||||
this.chkDns1.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkDns1.Location = new System.Drawing.Point(277, 205);
|
||||
this.chkDns1.Location = new System.Drawing.Point(277, 220);
|
||||
this.chkDns1.Name = "chkDns1";
|
||||
this.chkDns1.Size = new System.Drawing.Size(245, 36);
|
||||
this.chkDns1.TabIndex = 24;
|
||||
|
@ -243,13 +249,65 @@
|
|||
this.chkDns2.AutoSize = true;
|
||||
this.chkDns2.Checked = true;
|
||||
this.chkDns2.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkDns2.Location = new System.Drawing.Point(1229, 205);
|
||||
this.chkDns2.Location = new System.Drawing.Point(1229, 220);
|
||||
this.chkDns2.Name = "chkDns2";
|
||||
this.chkDns2.Size = new System.Drawing.Size(245, 36);
|
||||
this.chkDns2.TabIndex = 25;
|
||||
this.chkDns2.Text = "Test dns server";
|
||||
this.chkDns2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(155, 27);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(263, 32);
|
||||
this.label1.TabIndex = 26;
|
||||
this.label1.Text = "Resolve ip address:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(1102, 27);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(257, 32);
|
||||
this.label2.TabIndex = 27;
|
||||
this.label2.Text = "Resolve hostname:";
|
||||
//
|
||||
// txtResolveIP
|
||||
//
|
||||
this.txtResolveIP.Location = new System.Drawing.Point(425, 21);
|
||||
this.txtResolveIP.Name = "txtResolveIP";
|
||||
this.txtResolveIP.Size = new System.Drawing.Size(608, 38);
|
||||
this.txtResolveIP.TabIndex = 28;
|
||||
//
|
||||
// txtResolveHost
|
||||
//
|
||||
this.txtResolveHost.Location = new System.Drawing.Point(1365, 21);
|
||||
this.txtResolveHost.Name = "txtResolveHost";
|
||||
this.txtResolveHost.Size = new System.Drawing.Size(651, 38);
|
||||
this.txtResolveHost.TabIndex = 29;
|
||||
//
|
||||
// btnResolveIP
|
||||
//
|
||||
this.btnResolveIP.Location = new System.Drawing.Point(425, 75);
|
||||
this.btnResolveIP.Name = "btnResolveIP";
|
||||
this.btnResolveIP.Size = new System.Drawing.Size(195, 70);
|
||||
this.btnResolveIP.TabIndex = 30;
|
||||
this.btnResolveIP.Text = "Resolve";
|
||||
this.btnResolveIP.UseVisualStyleBackColor = true;
|
||||
this.btnResolveIP.Click += new System.EventHandler(this.btnResolveIP_Click);
|
||||
//
|
||||
// btnResolveHost
|
||||
//
|
||||
this.btnResolveHost.Location = new System.Drawing.Point(1366, 75);
|
||||
this.btnResolveHost.Name = "btnResolveHost";
|
||||
this.btnResolveHost.Size = new System.Drawing.Size(221, 70);
|
||||
this.btnResolveHost.TabIndex = 31;
|
||||
this.btnResolveHost.Text = "Resolve";
|
||||
this.btnResolveHost.UseVisualStyleBackColor = true;
|
||||
this.btnResolveHost.Click += new System.EventHandler(this.btnResolveHost_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
|
||||
|
@ -257,6 +315,12 @@
|
|||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(2517, 1693);
|
||||
this.Controls.Add(this.btnResolveHost);
|
||||
this.Controls.Add(this.btnResolveIP);
|
||||
this.Controls.Add(this.txtResolveHost);
|
||||
this.Controls.Add(this.txtResolveIP);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.chkDns2);
|
||||
this.Controls.Add(this.chkDns1);
|
||||
this.Controls.Add(this.StatusBox);
|
||||
|
@ -306,6 +370,12 @@
|
|||
private System.Windows.Forms.ListBox StatusBox;
|
||||
private System.Windows.Forms.CheckBox chkDns1;
|
||||
private System.Windows.Forms.CheckBox chkDns2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox txtResolveIP;
|
||||
private System.Windows.Forms.TextBox txtResolveHost;
|
||||
private System.Windows.Forms.Button btnResolveIP;
|
||||
private System.Windows.Forms.Button btnResolveHost;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
|
@ -8,6 +9,7 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace EonaCat.DnsTester
|
||||
{
|
||||
|
@ -405,7 +407,64 @@ namespace EonaCat.DnsTester
|
|||
|
||||
}
|
||||
|
||||
private void StatusBoxPrint(string LogText)
|
||||
private async void btnResolveIP_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(txtResolveIP.Text))
|
||||
{
|
||||
MessageBox.Show("Please enter an IP address to resolve");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IPAddress.TryParse(txtResolveIP.Text , out IPAddress iPAddress))
|
||||
{
|
||||
MessageBox.Show("Please enter a valid IP address");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var dnsEntry = Dns.GetHostEntry(iPAddress);
|
||||
Dispatcher.CurrentDispatcher.Invoke(() =>
|
||||
{
|
||||
txtResolveHost.Text = dnsEntry.HostName;
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show($"Could not get hostname for IP address '{txtResolveIP.Text}'");
|
||||
}
|
||||
}
|
||||
|
||||
private async void btnResolveHost_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(txtResolveHost.Text))
|
||||
{
|
||||
MessageBox.Show("Please enter an hostname to resolve");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var dnsEntry = Dns.GetHostEntry(txtResolveHost.Text);
|
||||
|
||||
Dispatcher.CurrentDispatcher.Invoke(() =>
|
||||
{
|
||||
txtResolveIP.Text = dnsEntry.AddressList.Where(x => x.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault().Address.ToString();
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show($"Could not get hostname for IP address '{txtResolveIP.Text}'");
|
||||
}
|
||||
}
|
||||
|
||||
private void StatusBoxPrint(string LogText)
|
||||
{
|
||||
StatusBox.Items.Add(DateTime.Now + " " + LogText);
|
||||
StatusBox.TopIndex = StatusBox.Items.Count - 1;
|
||||
|
|
Loading…
Reference in New Issue