Updated
This commit is contained in:
parent
31ed3a99aa
commit
c795fd71f5
|
@ -47,6 +47,8 @@
|
||||||
this.CustomDns2 = new System.Windows.Forms.TextBox();
|
this.CustomDns2 = new System.Windows.Forms.TextBox();
|
||||||
this.lslStatus = new System.Windows.Forms.Label();
|
this.lslStatus = new System.Windows.Forms.Label();
|
||||||
this.StatusBox = new System.Windows.Forms.ListBox();
|
this.StatusBox = new System.Windows.Forms.ListBox();
|
||||||
|
this.chkDns1 = new System.Windows.Forms.CheckBox();
|
||||||
|
this.chkDns2 = new System.Windows.Forms.CheckBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// ResultView
|
// ResultView
|
||||||
|
@ -224,13 +226,39 @@
|
||||||
this.StatusBox.Size = new System.Drawing.Size(2209, 376);
|
this.StatusBox.Size = new System.Drawing.Size(2209, 376);
|
||||||
this.StatusBox.TabIndex = 23;
|
this.StatusBox.TabIndex = 23;
|
||||||
//
|
//
|
||||||
// TesterUI
|
// chkDns1
|
||||||
|
//
|
||||||
|
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.Name = "chkDns1";
|
||||||
|
this.chkDns1.Size = new System.Drawing.Size(245, 36);
|
||||||
|
this.chkDns1.TabIndex = 24;
|
||||||
|
this.chkDns1.Text = "Test dns server";
|
||||||
|
this.chkDns1.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// chkDns2
|
||||||
|
//
|
||||||
|
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.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;
|
||||||
|
//
|
||||||
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.AutoSize = true;
|
this.AutoSize = true;
|
||||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||||
this.ClientSize = new System.Drawing.Size(2517, 1693);
|
this.ClientSize = new System.Drawing.Size(2517, 1693);
|
||||||
|
this.Controls.Add(this.chkDns2);
|
||||||
|
this.Controls.Add(this.chkDns1);
|
||||||
this.Controls.Add(this.StatusBox);
|
this.Controls.Add(this.StatusBox);
|
||||||
this.Controls.Add(this.lslStatus);
|
this.Controls.Add(this.lslStatus);
|
||||||
this.Controls.Add(this.CustomDns2);
|
this.Controls.Add(this.CustomDns2);
|
||||||
|
@ -247,7 +275,7 @@
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
this.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "TesterUI";
|
this.Name = "MainForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "EonaCat.DnsTester";
|
this.Text = "EonaCat.DnsTester";
|
||||||
this.Load += new System.EventHandler(this.TesterUI_Load);
|
this.Load += new System.EventHandler(this.TesterUI_Load);
|
||||||
|
@ -276,6 +304,8 @@
|
||||||
private System.Windows.Forms.TextBox CustomDns2;
|
private System.Windows.Forms.TextBox CustomDns2;
|
||||||
private System.Windows.Forms.Label lslStatus;
|
private System.Windows.Forms.Label lslStatus;
|
||||||
private System.Windows.Forms.ListBox StatusBox;
|
private System.Windows.Forms.ListBox StatusBox;
|
||||||
|
private System.Windows.Forms.CheckBox chkDns1;
|
||||||
|
private System.Windows.Forms.CheckBox chkDns2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Net.Sockets;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace EonaCat.DnsTester
|
namespace EonaCat.DnsTester
|
||||||
|
@ -15,6 +16,8 @@ namespace EonaCat.DnsTester
|
||||||
private bool UseCustomDnsServers = false;
|
private bool UseCustomDnsServers = false;
|
||||||
public string DNS1, DNS2;
|
public string DNS1, DNS2;
|
||||||
|
|
||||||
|
public bool IsRunning { get; private set; }
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -28,13 +31,27 @@ namespace EonaCat.DnsTester
|
||||||
|
|
||||||
if (this.UseCustomDnsServers)
|
if (this.UseCustomDnsServers)
|
||||||
{
|
{
|
||||||
DNS1 = CustomDns1.Text;
|
if (chkDns1.Checked)
|
||||||
DNS2 = CustomDns2.Text;
|
{
|
||||||
|
DNS1 = CustomDns1.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chkDns2.Checked)
|
||||||
|
{
|
||||||
|
DNS2 = CustomDns2.Text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DNS1 = DnsList1.SelectedValue.ToString();
|
if (chkDns1.Checked)
|
||||||
DNS2 = DnsList2.SelectedValue.ToString();
|
{
|
||||||
|
DNS1 = DnsList1.SelectedValue.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chkDns2.Checked)
|
||||||
|
{
|
||||||
|
DNS2 = DnsList2.SelectedValue.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +79,17 @@ namespace EonaCat.DnsTester
|
||||||
ResultView.Update();
|
ResultView.Update();
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
CheckDNS(CleanNames, CleanNamesCount, DNS1, DNS2);
|
if (IsRunning)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
IsRunning = true;
|
||||||
|
CheckDNS(CleanNames, CleanNamesCount, DNS1, DNS2);
|
||||||
|
IsRunning = false;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,13 +260,13 @@ namespace EonaCat.DnsTester
|
||||||
DNSsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, DNSReceiveTimeout);
|
DNSsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, DNSReceiveTimeout);
|
||||||
|
|
||||||
IPEndPoint dnsEP1 = null;
|
IPEndPoint dnsEP1 = null;
|
||||||
if (!string.IsNullOrWhiteSpace(DNSAddress1))
|
if (chkDns1.Checked && !string.IsNullOrWhiteSpace(DNSAddress1))
|
||||||
{
|
{
|
||||||
dnsEP1 = new IPEndPoint(IPAddress.Parse(DNSAddress1), IPPort);
|
dnsEP1 = new IPEndPoint(IPAddress.Parse(DNSAddress1), IPPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPEndPoint dnsEP2 = null;
|
IPEndPoint dnsEP2 = null;
|
||||||
if (!string.IsNullOrWhiteSpace(DNSAddress2))
|
if (chkDns2.Checked && !string.IsNullOrWhiteSpace(DNSAddress2))
|
||||||
{
|
{
|
||||||
dnsEP2 = new IPEndPoint(IPAddress.Parse(DNSAddress2), IPPort);
|
dnsEP2 = new IPEndPoint(IPAddress.Parse(DNSAddress2), IPPort);
|
||||||
}
|
}
|
||||||
|
@ -247,25 +274,29 @@ namespace EonaCat.DnsTester
|
||||||
// Start the clock
|
// Start the clock
|
||||||
StartTime = DateTime.Now.Ticks;
|
StartTime = DateTime.Now.Ticks;
|
||||||
|
|
||||||
// i=0; // for testing - do one
|
|
||||||
for (i = 0; i < URLNamescount; i++)
|
for (i = 0; i < URLNamescount; i++)
|
||||||
{
|
{
|
||||||
URLNameStart = URLNames[i].Substring(0, URLNames[i].IndexOf("."));
|
URLNameStart = URLNames[i].Substring(0, URLNames[i].IndexOf("."));
|
||||||
DomainName = URLNames[i].Substring(URLNames[i].IndexOf(".") + 1, URLNames[i].Length - URLNames[i].IndexOf(".") - 1);
|
DomainName = URLNames[i].Substring(URLNames[i].IndexOf(".") + 1, URLNames[i].Length - URLNames[i].IndexOf(".") - 1);
|
||||||
// Build the query
|
|
||||||
QueryString = TransactionID1 + TypeString + (char)URLNameStart.Length + URLNameStart + (char)DomainName.Length + DomainName + TrailerString;
|
if (chkDns1.Checked)
|
||||||
Sendbytes = Encoding.ASCII.GetBytes(QueryString);
|
|
||||||
if (dnsEP1 != null)
|
|
||||||
{
|
{
|
||||||
DNSsocket.SendTo(Sendbytes, Sendbytes.Length, SocketFlags.None, dnsEP1);
|
QueryString = TransactionID1 + TypeString + (char)URLNameStart.Length + URLNameStart + (char)DomainName.Length + DomainName + TrailerString;
|
||||||
|
Sendbytes = Encoding.ASCII.GetBytes(QueryString);
|
||||||
|
if (dnsEP1 != null)
|
||||||
|
{
|
||||||
|
DNSsocket.SendTo(Sendbytes, Sendbytes.Length, SocketFlags.None, dnsEP1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the same message to both DNS servers except for the transaction ID
|
if (chkDns2.Checked)
|
||||||
QueryString = TransactionID2 + TypeString + (char)URLNameStart.Length + URLNameStart + (char)DomainName.Length + DomainName + TrailerString;
|
|
||||||
Sendbytes = Encoding.ASCII.GetBytes(QueryString);
|
|
||||||
if (dnsEP2 != null)
|
|
||||||
{
|
{
|
||||||
DNSsocket.SendTo(Sendbytes, Sendbytes.Length, SocketFlags.None, dnsEP2);
|
QueryString = TransactionID2 + TypeString + (char)URLNameStart.Length + URLNameStart + (char)DomainName.Length + DomainName + TrailerString;
|
||||||
|
Sendbytes = Encoding.ASCII.GetBytes(QueryString);
|
||||||
|
if (dnsEP2 != null)
|
||||||
|
{
|
||||||
|
DNSsocket.SendTo(Sendbytes, Sendbytes.Length, SocketFlags.None, dnsEP2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,8 +306,6 @@ namespace EonaCat.DnsTester
|
||||||
{
|
{
|
||||||
// wait for a response up to timeout
|
// wait for a response up to timeout
|
||||||
more: DNSsocket.Receive(Receivebytes);
|
more: DNSsocket.Receive(Receivebytes);
|
||||||
|
|
||||||
|
|
||||||
// make sure the message returned is ours
|
// make sure the message returned is ours
|
||||||
if (Receivebytes[0] == Sendbytes[0] && (Receivebytes[1] == 0x31) || (Receivebytes[1] == 0x32))
|
if (Receivebytes[0] == Sendbytes[0] && (Receivebytes[1] == 0x31) || (Receivebytes[1] == 0x32))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue