Initial version

This commit is contained in:
EonaCat 2023-02-09 11:47:51 +01:00
parent 9d2d547d8a
commit 31ed3a99aa
15 changed files with 5458 additions and 0 deletions

25
EonaCat.DnsTester.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EonaCat.DnsTester", "EonaCat.DnsTester\EonaCat.DnsTester.csproj", "{CAA93B33-C1F4-46AE-ABD8-3802BCB6CB5F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CAA93B33-C1F4-46AE-ABD8-3802BCB6CB5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CAA93B33-C1F4-46AE-ABD8-3802BCB6CB5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAA93B33-C1F4-46AE-ABD8-3802BCB6CB5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAA93B33-C1F4-46AE-ABD8-3802BCB6CB5F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B94E103-A66E-4E75-B34A-C3BA2CDDCD9E}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CAA93B33-C1F4-46AE-ABD8-3802BCB6CB5F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>EonaCat.DnsTester</RootNamespace>
<AssemblyName>EonaCat.DnsTester</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>EonaCat.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Runtime.Serialization.Formatters.Soap" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="EonaCat.ico" />
<Content Include="Servers.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

281
EonaCat.DnsTester/MainForm.Designer.cs generated Normal file
View File

@ -0,0 +1,281 @@
namespace EonaCat.DnsTester
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.ResultView = new System.Windows.Forms.ListView();
this.WebName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DNS1IP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DNS1Timing = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DNS2IP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DNS2Timing = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.RunTest = new System.Windows.Forms.Button();
this.lblDns1 = new System.Windows.Forms.Label();
this.lblDns2 = new System.Windows.Forms.Label();
this.DnsList1 = new System.Windows.Forms.ComboBox();
this.DnsList2 = new System.Windows.Forms.ComboBox();
this.UseCustomServers = new System.Windows.Forms.CheckBox();
this.lblCustom1 = new System.Windows.Forms.Label();
this.lblCustom2 = new System.Windows.Forms.Label();
this.CustomDns1 = new System.Windows.Forms.TextBox();
this.CustomDns2 = new System.Windows.Forms.TextBox();
this.lslStatus = new System.Windows.Forms.Label();
this.StatusBox = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// ResultView
//
this.ResultView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.WebName,
this.DNS1IP,
this.DNS1Timing,
this.DNS2IP,
this.DNS2Timing});
this.ResultView.GridLines = true;
this.ResultView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.ResultView.HideSelection = false;
this.ResultView.Location = new System.Drawing.Point(155, 379);
this.ResultView.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.ResultView.MultiSelect = false;
this.ResultView.Name = "ResultView";
this.ResultView.Size = new System.Drawing.Size(2209, 753);
this.ResultView.TabIndex = 11;
this.ResultView.UseCompatibleStateImageBehavior = false;
this.ResultView.View = System.Windows.Forms.View.Details;
//
// WebName
//
this.WebName.Text = "URL";
this.WebName.Width = 160;
//
// DNS1IP
//
this.DNS1IP.Text = "IP Address from DNS 1";
this.DNS1IP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.DNS1IP.Width = 140;
//
// DNS1Timing
//
this.DNS1Timing.Text = "DNS 1 Timing";
this.DNS1Timing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.DNS1Timing.Width = 120;
//
// DNS2IP
//
this.DNS2IP.Text = "IP Address from DNS 2";
this.DNS2IP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.DNS2IP.Width = 140;
//
// DNS2Timing
//
this.DNS2Timing.Text = "DNS 2 Timing";
this.DNS2Timing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.DNS2Timing.Width = 120;
//
// RunTest
//
this.RunTest.Location = new System.Drawing.Point(1131, 1152);
this.RunTest.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.RunTest.Name = "RunTest";
this.RunTest.Size = new System.Drawing.Size(200, 55);
this.RunTest.TabIndex = 12;
this.RunTest.Text = "Run Test";
this.RunTest.Click += new System.EventHandler(this.RunTest_Click);
//
// lblDns1
//
this.lblDns1.AutoSize = true;
this.lblDns1.Location = new System.Drawing.Point(155, 167);
this.lblDns1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
this.lblDns1.Name = "lblDns1";
this.lblDns1.Size = new System.Drawing.Size(95, 32);
this.lblDns1.TabIndex = 13;
this.lblDns1.Text = "Dns 1:";
//
// lblDns2
//
this.lblDns2.AutoSize = true;
this.lblDns2.Location = new System.Drawing.Point(1096, 167);
this.lblDns2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
this.lblDns2.Name = "lblDns2";
this.lblDns2.Size = new System.Drawing.Size(95, 32);
this.lblDns2.TabIndex = 14;
this.lblDns2.Text = "Dns 2:";
//
// DnsList1
//
this.DnsList1.FormattingEnabled = true;
this.DnsList1.ItemHeight = 31;
this.DnsList1.Location = new System.Drawing.Point(277, 155);
this.DnsList1.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.DnsList1.Name = "DnsList1";
this.DnsList1.Size = new System.Drawing.Size(756, 39);
this.DnsList1.TabIndex = 15;
//
// DnsList2
//
this.DnsList2.FormattingEnabled = true;
this.DnsList2.ItemHeight = 31;
this.DnsList2.Location = new System.Drawing.Point(1229, 155);
this.DnsList2.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.DnsList2.Name = "DnsList2";
this.DnsList2.Size = new System.Drawing.Size(788, 39);
this.DnsList2.TabIndex = 16;
//
// UseCustomServers
//
this.UseCustomServers.AutoSize = true;
this.UseCustomServers.Location = new System.Drawing.Point(2091, 167);
this.UseCustomServers.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.UseCustomServers.Name = "UseCustomServers";
this.UseCustomServers.Size = new System.Drawing.Size(253, 36);
this.UseCustomServers.TabIndex = 17;
this.UseCustomServers.Text = "Custom Servers";
this.UseCustomServers.UseVisualStyleBackColor = true;
this.UseCustomServers.CheckedChanged += new System.EventHandler(this.UseCustomServers_CheckedChanged);
//
// lblCustom1
//
this.lblCustom1.AutoSize = true;
this.lblCustom1.Location = new System.Drawing.Point(155, 293);
this.lblCustom1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
this.lblCustom1.Name = "lblCustom1";
this.lblCustom1.Size = new System.Drawing.Size(206, 32);
this.lblCustom1.TabIndex = 18;
this.lblCustom1.Text = "Custom Dns 1: ";
this.lblCustom1.Visible = false;
//
// lblCustom2
//
this.lblCustom2.AutoSize = true;
this.lblCustom2.Location = new System.Drawing.Point(1096, 293);
this.lblCustom2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
this.lblCustom2.Name = "lblCustom2";
this.lblCustom2.Size = new System.Drawing.Size(206, 32);
this.lblCustom2.TabIndex = 19;
this.lblCustom2.Text = "Custom Dns 2: ";
this.lblCustom2.Visible = false;
//
// CustomDns1
//
this.CustomDns1.BackColor = System.Drawing.Color.White;
this.CustomDns1.Enabled = false;
this.CustomDns1.Location = new System.Drawing.Point(408, 289);
this.CustomDns1.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.CustomDns1.Name = "CustomDns1";
this.CustomDns1.Size = new System.Drawing.Size(625, 38);
this.CustomDns1.TabIndex = 20;
this.CustomDns1.Visible = false;
//
// CustomDns2
//
this.CustomDns2.Enabled = false;
this.CustomDns2.Location = new System.Drawing.Point(1349, 289);
this.CustomDns2.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.CustomDns2.Name = "CustomDns2";
this.CustomDns2.Size = new System.Drawing.Size(668, 38);
this.CustomDns2.TabIndex = 21;
this.CustomDns2.Visible = false;
//
// lslStatus
//
this.lslStatus.AutoSize = true;
this.lslStatus.Location = new System.Drawing.Point(155, 1219);
this.lslStatus.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
this.lslStatus.Name = "lslStatus";
this.lslStatus.Size = new System.Drawing.Size(103, 32);
this.lslStatus.TabIndex = 22;
this.lslStatus.Text = "Status:";
//
// StatusBox
//
this.StatusBox.FormattingEnabled = true;
this.StatusBox.HorizontalScrollbar = true;
this.StatusBox.ItemHeight = 31;
this.StatusBox.Location = new System.Drawing.Point(155, 1271);
this.StatusBox.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.StatusBox.Name = "StatusBox";
this.StatusBox.Size = new System.Drawing.Size(2209, 376);
this.StatusBox.TabIndex = 23;
//
// TesterUI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(2517, 1693);
this.Controls.Add(this.StatusBox);
this.Controls.Add(this.lslStatus);
this.Controls.Add(this.CustomDns2);
this.Controls.Add(this.CustomDns1);
this.Controls.Add(this.lblCustom2);
this.Controls.Add(this.lblCustom1);
this.Controls.Add(this.UseCustomServers);
this.Controls.Add(this.DnsList2);
this.Controls.Add(this.DnsList1);
this.Controls.Add(this.lblDns2);
this.Controls.Add(this.lblDns1);
this.Controls.Add(this.RunTest);
this.Controls.Add(this.ResultView);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
this.MaximizeBox = false;
this.Name = "TesterUI";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "EonaCat.DnsTester";
this.Load += new System.EventHandler(this.TesterUI_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListView ResultView;
private System.Windows.Forms.ColumnHeader WebName;
private System.Windows.Forms.ColumnHeader DNS1IP;
private System.Windows.Forms.ColumnHeader DNS1Timing;
private System.Windows.Forms.ColumnHeader DNS2IP;
private System.Windows.Forms.ColumnHeader DNS2Timing;
private System.Windows.Forms.Button RunTest;
private System.Windows.Forms.Label lblDns1;
private System.Windows.Forms.Label lblDns2;
private System.Windows.Forms.ComboBox DnsList1;
private System.Windows.Forms.ComboBox DnsList2;
private System.Windows.Forms.CheckBox UseCustomServers;
private System.Windows.Forms.Label lblCustom1;
private System.Windows.Forms.Label lblCustom2;
private System.Windows.Forms.TextBox CustomDns1;
private System.Windows.Forms.TextBox CustomDns2;
private System.Windows.Forms.Label lslStatus;
private System.Windows.Forms.ListBox StatusBox;
}
}

View File

@ -0,0 +1,392 @@
using System;
using System.Data;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace EonaCat.DnsTester
{
public partial class MainForm : Form
{
private bool UseCustomDnsServers = false;
public string DNS1, DNS2;
public MainForm()
{
InitializeComponent();
}
private void RunTest_Click(object sender, EventArgs e)
{
int i;
string[] CleanNames = new string[500];
int CleanNamesCount = 0;
if (this.UseCustomDnsServers)
{
DNS1 = CustomDns1.Text;
DNS2 = CustomDns2.Text;
}
else
{
DNS1 = DnsList1.SelectedValue.ToString();
DNS2 = DnsList2.SelectedValue.ToString();
}
ResultView.Items.Clear();
ResultView.Update();
Application.DoEvents();
GetWebAddresses(ref CleanNames, ref CleanNamesCount);
for (i = 0; i < CleanNamesCount; i++)
{
ListViewItem listURL = new ListViewItem(CleanNames[i]);
listURL.SubItems.Add(" ");
listURL.SubItems.Add(" ");
listURL.SubItems.Add(" ");
listURL.SubItems.Add(" ");
ResultView.Items.Add(listURL);
}
if (ResultView.Items.Count > 1)
{
ResultView.EnsureVisible(ResultView.Items.Count - 1);
}
ResultView.Update();
Application.DoEvents();
CheckDNS(CleanNames, CleanNamesCount, DNS1, DNS2);
}
private void TesterUI_Load(object sender, EventArgs e)
{
FillDnsList();
}
private void FillDnsList()
{
DnsList1.ValueMember = "ip";
DnsList1.DisplayMember = "name";
DnsList2.ValueMember = "ip";
DnsList2.DisplayMember = "name";
DataSet servers1 = new DataSet();
DataSet servers2 = new DataSet();
servers1.ReadXml(Path.Combine(Application.StartupPath, "Servers.xml"));
servers2.ReadXml(Path.Combine(Application.StartupPath, "Servers.xml"));
DataTable ns1 = servers1.Tables[0];
DataTable ns2 = servers2.Tables[0];
DnsList1.DataSource = ns1;
DnsList2.DataSource = ns2;
}
private void UseCustomServers_CheckedChanged(object sender, EventArgs e)
{
this.UseCustomDnsServers = UseCustomServers.Checked;
SetUI();
}
private void SetUI()
{
if (this.UseCustomDnsServers)
{
this.DnsList1.Enabled = false;
this.DnsList2.Enabled = false;
this.CustomDns1.Enabled = true;
this.CustomDns2.Enabled = true;
this.CustomDns1.Visible = true;
this.CustomDns2.Visible = true;
this.lblCustom1.Visible = true;
this.lblCustom2.Visible = true;
}
else
{
this.DnsList1.Enabled = true;
this.DnsList2.Enabled = true;
this.CustomDns1.Enabled = false; ;
this.CustomDns2.Enabled = false;
this.CustomDns1.Visible = false;
this.CustomDns2.Visible = false;
this.lblCustom1.Visible = false;
this.lblCustom2.Visible = false;
}
}
private void GetWebAddresses(ref string[] CleanNames, ref int CleanNamesCount)
{
int i, j;
byte[] random = new Byte[256];
string Letters = "";
// Make a 3 letter random string
//RNGCryptoServiceProvider is an implementation of a random number generator.
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(random); // The array is now filled with cryptographically strong random bytes.
for (i = 1; i < 256; i++)
{
// Just take the first three letters
if (random[i] > 0x40 && random[i] < 0x5b) Letters = Letters + Convert.ToChar(random[i]);
if (Letters.Length == 3) break;
}
// Use Google to get random addresses for DNS testing
// Initialize the WebRequest.
StatusBoxPrint("Getting Google request");
try
{
WebRequest GoogleRequest = WebRequest.Create("http://www.google.com/search?num=100&q=" + Letters); //Letters);
WebResponse GoogleResponse = GoogleRequest.GetResponse();
Application.DoEvents();
// Get the response stream.
Stream GoogleStream = GoogleResponse.GetResponseStream();
StatusBoxPrint("Google response received");
// Use a StreamReader to read the entire response.
StreamReader GoogleReader = new StreamReader(GoogleStream, Encoding.ASCII);
string GoogleString = GoogleReader.ReadToEnd();
// Close the response stream and response to free resources.
GoogleStream.Close();
GoogleResponse.Close();
Application.DoEvents();
// find all .xxx.com addresses
MatchCollection HostNames;
string[] Names = new string[1000];
// Create a new Regex object and define the regular expression.
Regex Dotcom = new Regex("[.]([A-Za-z]*)[.]com");
// Use the Matches method to find all matches in the input string.
HostNames = Dotcom.Matches(GoogleString);
Application.DoEvents();
// Loop through the match collection to retrieve all
// matches and delete the leading "."
for (i = 0; i < HostNames.Count; i++)
{
Names[i] = HostNames[i].Value.Remove(0, 1);
}
// eliminate google.com and repeated entries
for (i = 0; i < HostNames.Count - 1; i++)
{
if (Names[i] == "google.com") Names[i] = "";
for (j = i + 1; j < HostNames.Count; j++)
{
if (Names[i] == Names[j]) Names[j] = "";
}
}
// count list and compact
j = 0;
for (i = 0; i < HostNames.Count; i++)
{
if (Names[i] != "")
{
CleanNames[j] = Names[i];
j++;
}
}
CleanNamesCount = j;
StatusBoxPrint(CleanNamesCount + " Random URL's found");
}
catch
{
StatusBoxPrint("Host Google.com not found - are you connected ?");
}
}
private void CheckDNS(string[] URLNames, int URLNamescount, string DNSAddress1, string DNSAddress2)
{
int i;
const int IPPort = 53;
const string TransactionID1 = "Q1"; // Use transaction ID of Q1 and Q2 to identify our packet and DNS
const string TransactionID2 = "Q2";
const string TypeString = "\u0001" + "\u0000" + "\u0000" + "\u0001" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u0000" + "\u0000";
const string TrailerString = "\u0000" + "\u0000" + "\u0001" + "\u0000" + "\u0001";
const int DNSReceiveTimeout = 5000;
string URLNameStart, DomainName, QueryString, ReceiveString, IPResponse, sDeltaTime;
int URLNameStartLength, DomainNameLength, index, TransactionDNS;
byte[] Sendbytes = new byte[256];
long StartTime, StopTime;
string DeltaTime;
Socket DNSsocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
DNSsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, DNSReceiveTimeout);
IPEndPoint dnsEP1 = null;
if (!string.IsNullOrWhiteSpace(DNSAddress1))
{
dnsEP1 = new IPEndPoint(IPAddress.Parse(DNSAddress1), IPPort);
}
IPEndPoint dnsEP2 = null;
if (!string.IsNullOrWhiteSpace(DNSAddress2))
{
dnsEP2 = new IPEndPoint(IPAddress.Parse(DNSAddress2), IPPort);
}
// Start the clock
StartTime = DateTime.Now.Ticks;
// i=0; // for testing - do one
for (i = 0; i < URLNamescount; i++)
{
URLNameStart = URLNames[i].Substring(0, URLNames[i].IndexOf("."));
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;
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
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);
}
}
byte[] Receivebytes = new byte[512];
try
{
// wait for a response up to timeout
more: DNSsocket.Receive(Receivebytes);
// make sure the message returned is ours
if (Receivebytes[0] == Sendbytes[0] && (Receivebytes[1] == 0x31) || (Receivebytes[1] == 0x32))
{
if (Receivebytes[2] == 0x81 && Receivebytes[3] == 0x80)
{
// Get the time now
StopTime = DateTime.Now.Ticks;
DeltaTime = Convert.ToString((double)(StopTime - StartTime) / 10000000);
// Decode the answers
// Find the URL that was returned
TransactionDNS = Receivebytes[1];
ReceiveString = Encoding.ASCII.GetString(Receivebytes);
index = 12;
URLNameStartLength = Receivebytes[index];
index++;
URLNameStart = ReceiveString.Substring(index, URLNameStartLength);
index = index + URLNameStartLength;
DomainNameLength = Receivebytes[index];
index++;
DomainName = ReceiveString.Substring(index, DomainNameLength);
index = index + DomainNameLength;
index = index + 8;
// Get the record type
int ResponseType = Receivebytes[index];
index = index + 9;
// Get the IP address if applicable
IPResponse = "";
switch (ResponseType)
{
case 1:
IPResponse = Convert.ToString(Receivebytes[index]) + "."
+ Convert.ToString(Receivebytes[index + 1]) + "."
+ Convert.ToString(Receivebytes[index + 2]) + "."
+ Convert.ToString(Receivebytes[index + 3]); break;
case 5: IPResponse = "CNAME"; break;
case 6: IPResponse = "SOA"; break;
}
StatusBoxPrint("DNS Answer: " + URLNameStart + "." + DomainName + " = " + IPResponse);
// Find the URL entry in the list
for (i = 0; i < ResultView.Items.Count; i++)
{
if (ResultView.Items[i].Text == URLNameStart + "." + DomainName)
{
switch (TransactionDNS)
{
case 0x31:
ResultView.Items[i].SubItems[1].Text = Convert.ToString(IPResponse);
sDeltaTime = Convert.ToString(DeltaTime);
if (sDeltaTime.Length > 5) ResultView.Items[i].SubItems[2].Text = sDeltaTime.Substring(0, 5);
else ResultView.Items[i].SubItems[2].Text = sDeltaTime;
ResultView.Items[i].ForeColor = System.Drawing.Color.Red;
ResultView.EnsureVisible(i);
ResultView.Update();
Application.DoEvents();
ResultView.Items[i].ForeColor = System.Drawing.Color.Black;
break;
case 0x32:
ResultView.Items[i].SubItems[3].Text = Convert.ToString(IPResponse);
sDeltaTime = Convert.ToString(DeltaTime);
if (sDeltaTime.Length > 5) ResultView.Items[i].SubItems[4].Text = sDeltaTime.Substring(0, 5);
else ResultView.Items[i].SubItems[4].Text = sDeltaTime;
ResultView.Items[i].ForeColor = System.Drawing.Color.Red;
ResultView.EnsureVisible(i);
ResultView.Update();
Application.DoEvents();
ResultView.Items[i].ForeColor = System.Drawing.Color.Black;
break;
}
}
}
}
goto more;
}
}
catch (SocketException e)
{
if (Convert.ToString(e).IndexOf("time") > 0)
{
StatusBoxPrint("Timeout - No response received for " + Convert.ToString(DNSReceiveTimeout / 1000) + " seconds");
}
else
{
StatusBoxPrint(Convert.ToString(e)); // for testing
}
}
finally
{
// close the socket
DNSsocket.Close();
}
}
private void StatusBoxPrint(string LogText)
{
StatusBox.Items.Add(DateTime.Now + " " + LogText);
StatusBox.TopIndex = StatusBox.Items.Count - 1;
if (StatusBox.Items.Count > 5000)
{
StatusBox.Items.RemoveAt(0);
}
StatusBox.Update();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
using System;
using System.Windows.Forms;
namespace EonaCat.DnsTester
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EonaCat.EonaCat.DnsTester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EonaCat.EonaCat.DnsTester")]
[assembly: AssemblyCopyright("Copyright © EonaCat (Jeroen Saey) 2027")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("caa93b33-c1f4-46ae-abd8-3802bcb6cb5f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace EonaCat.EonaCat.DnsTester.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EonaCat.EonaCat.DnsTester.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace EonaCat.EonaCat.DnsTester.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<Servers>
<!-- My Local Blocky Dns -->
<server name="Local Blocky" ip="127.0.0.1"></server>
<!-- My External Blocky Dns -->
<server name="External Blocky" ip="192.168.1.10"></server>
<!-- My Remote Blocky Dns -->
<server name="Remote Blocky" ip="192.168.1.254"></server>
<!--Google Dns Servers-->
<server name="Google (8.8.8.8)" ip="8.8.8.8"></server>
<server name="Google (8.8.4.4)" ip="8.8.8.8"></server>
<!--CloudFlare Dns servers-->
<server name="CloudFlare Standard (1.1.1.1)" ip="1.1.1.1"></server>
<server name="CloudFlare Standard (1.0.0.1)" ip="1.0.0.1"></server>
<!--Quad9 DNS-->
<server name="Quad9 DNS 1 (9.9.9.9)" ip="9.9.9.9"></server>
<server name="Quad9 DNS 2 (149.112.112.9)" ip="149.112.112.9"></server>
<!--Verisign-->
<server name="Verisign (64.6.64.6)" ip="64.6.64.6"></server>
<server name="Verisign (64.6.65.6)" ip="64.6.65.6"></server>
<!--AdGuard DNS-->
<server name="AdGuard DNS (94.140.14.15)" ip="94.140.14.15"></server>
<server name="AdGuard DNS (94.140.15.15)" ip="94.140.15.15"></server>
</Servers>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>