Updated
This commit is contained in:
parent
2ba9705b66
commit
150a3f226b
|
@ -1,6 +1,18 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
|
<section name="EonaCat.DnsTester.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||||
</startup>
|
</startup>
|
||||||
|
<userSettings>
|
||||||
|
<EonaCat.DnsTester.Properties.Settings>
|
||||||
|
<setting name="EonaCat" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
</EonaCat.DnsTester.Properties.Settings>
|
||||||
|
</userSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -14,4 +14,19 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="EonaCat.ico" />
|
<Content Include="EonaCat.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Settings.Designer.cs">
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,118 +1,400 @@
|
||||||
using Microsoft.VisualBasic.Logging;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace EonaCat.DnsTester.Helpers
|
namespace EonaCat.DnsTester.Helpers
|
||||||
{
|
{
|
||||||
internal class DnsHelper
|
class DnsHelper
|
||||||
{
|
{
|
||||||
public static event EventHandler<string> Log;
|
public static event EventHandler<string> OnLog;
|
||||||
|
public static async Task<DnsResponse> SendDnsQueryPacket(string dnsId, string server, int port, byte[] queryBytes)
|
||||||
public static void ProcessDns(string startOfUrl, string domain, int urlsTotal, Socket dnsSocket, byte[] bytesSend,
|
|
||||||
long startTime, int totalDnsToUse, ListView result)
|
|
||||||
{
|
{
|
||||||
var bytesReceived = new byte[512];
|
// Start the clock
|
||||||
var totalReceived = 0;
|
var startTime = DateTime.Now.Ticks;
|
||||||
|
|
||||||
// wait for a response up to timeout
|
var endPoint = new IPEndPoint(IPAddress.Parse(server), port);
|
||||||
while (totalReceived < urlsTotal * totalDnsToUse)
|
using (var client = new UdpClient(endPoint.AddressFamily))
|
||||||
{
|
{
|
||||||
dnsSocket.Receive(bytesReceived);
|
client.DontFragment = true;
|
||||||
|
client.EnableBroadcast = false;
|
||||||
|
client.Client.ReceiveTimeout = DnsReceiveTimeout;
|
||||||
|
await client.SendAsync(queryBytes, queryBytes.Length, endPoint);
|
||||||
|
var responseResult = await client.ReceiveAsync();
|
||||||
|
DnsResponse response = ParseDnsResponsePacket(dnsId, startTime, server, responseResult.Buffer);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the error is ours
|
public static int DnsReceiveTimeout { get; set; } = 5;
|
||||||
if ((bytesReceived[0] != bytesSend[0] || bytesReceived[1] != 0x31) &&
|
|
||||||
bytesReceived[1] != 0x32)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (bytesReceived[2] != 0x81 || bytesReceived[3] != 0x80) continue;
|
|
||||||
|
|
||||||
// Get the time now
|
public static byte[] CreateDnsQueryPacket(string domainName, DnsRecordType recordType)
|
||||||
var stopTime = DateTime.Now.Ticks;
|
|
||||||
var deltaTime = Convert.ToString((double)(stopTime - startTime) / 10000000);
|
|
||||||
|
|
||||||
// Decode the answers
|
|
||||||
// Find the URL that was returned
|
|
||||||
int dnsId = bytesReceived[1];
|
|
||||||
var receiveString = Encoding.ASCII.GetString(bytesReceived);
|
|
||||||
var index = 12;
|
|
||||||
int startOfUrlLength = bytesReceived[index];
|
|
||||||
index++;
|
|
||||||
startOfUrl = receiveString.Substring(index, startOfUrlLength);
|
|
||||||
index += startOfUrlLength;
|
|
||||||
int domainLength = bytesReceived[index];
|
|
||||||
index++;
|
|
||||||
domain = receiveString.Substring(index, domainLength);
|
|
||||||
index += domainLength;
|
|
||||||
index += 8;
|
|
||||||
|
|
||||||
// Get the record type
|
|
||||||
int ResponseType = bytesReceived[index];
|
|
||||||
index += 9;
|
|
||||||
|
|
||||||
// Get the IP address if applicable
|
|
||||||
var ipResponse = "";
|
|
||||||
switch (ResponseType)
|
|
||||||
{
|
{
|
||||||
case 1:
|
Random random = new Random();
|
||||||
ipResponse =
|
|
||||||
$"{Convert.ToString(bytesReceived[index])}.{Convert.ToString(bytesReceived[index + 1])}.{Convert.ToString(bytesReceived[index + 2])}.{Convert.ToString(bytesReceived[index + 3])}";
|
// DNS header
|
||||||
|
ushort id = (ushort)random.Next(0, 65536);
|
||||||
|
ushort flags = (ushort)0x0100; // recursion desired
|
||||||
|
ushort qdcount = 1;
|
||||||
|
ushort ancount = 0;
|
||||||
|
ushort nscount = 0;
|
||||||
|
ushort arcount = 0;
|
||||||
|
byte[] headerBytes = new byte[]
|
||||||
|
{
|
||||||
|
(byte)(id >> 8), (byte)(id & 0xff),
|
||||||
|
(byte)(flags >> 8), (byte)(flags & 0xff),
|
||||||
|
(byte)(qdcount >> 8), (byte)(qdcount & 0xff),
|
||||||
|
(byte)(ancount >> 8), (byte)(ancount & 0xff),
|
||||||
|
(byte)(nscount >> 8), (byte)(nscount & 0xff),
|
||||||
|
(byte)(arcount >> 8), (byte)(arcount & 0xff),
|
||||||
|
};
|
||||||
|
|
||||||
|
// DNS question
|
||||||
|
string[] labels = domainName.Split('.');
|
||||||
|
byte[] qnameBytes = new byte[domainName.Length + 2];
|
||||||
|
int qnameIndex = 0;
|
||||||
|
foreach (string label in labels)
|
||||||
|
{
|
||||||
|
qnameBytes[qnameIndex++] = (byte)label.Length;
|
||||||
|
foreach (char c in label)
|
||||||
|
{
|
||||||
|
qnameBytes[qnameIndex++] = (byte)c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qnameBytes[qnameIndex++] = 0;
|
||||||
|
|
||||||
|
byte[] qtypeBytes = new byte[] { (byte)((ushort)recordType >> 8), (byte)((ushort)recordType & 0xff) };
|
||||||
|
byte[] qclassBytes = new byte[] { 0, 1 }; // internet class
|
||||||
|
byte[] questionBytes = new byte[qnameBytes.Length + qtypeBytes.Length + qclassBytes.Length];
|
||||||
|
qnameBytes.CopyTo(questionBytes, 0);
|
||||||
|
qtypeBytes.CopyTo(questionBytes, qnameBytes.Length);
|
||||||
|
qclassBytes.CopyTo(questionBytes, qnameBytes.Length + qtypeBytes.Length);
|
||||||
|
|
||||||
|
// Combine the header and question to form the DNS query packet
|
||||||
|
byte[] queryBytes = new byte[headerBytes.Length + questionBytes.Length];
|
||||||
|
headerBytes.CopyTo(queryBytes, 0);
|
||||||
|
questionBytes.CopyTo(queryBytes, headerBytes.Length);
|
||||||
|
|
||||||
|
return queryBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DnsQuestion ParseDnsQuestionRecord(byte[] queryBytes, ref int offset)
|
||||||
|
{
|
||||||
|
// Parse the DNS name
|
||||||
|
string name = ParseDnsName(queryBytes, ref offset);
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the DNS type and class
|
||||||
|
ushort type = (ushort)((queryBytes[offset] << 8) | queryBytes[offset + 1]);
|
||||||
|
ushort qclass = (ushort)((queryBytes[offset + 2] << 8) | queryBytes[offset + 3]);
|
||||||
|
offset += 4;
|
||||||
|
|
||||||
|
return new DnsQuestion
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
Type = (DnsRecordType)type,
|
||||||
|
Class = (DnsRecordClass)qclass,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static DnsResponse ParseDnsResponsePacket(string dnsId, long startTime, string server, byte[] responseBytes)
|
||||||
|
{
|
||||||
|
// Parse the DNS header
|
||||||
|
ushort id = (ushort)((responseBytes[0] << 8) | responseBytes[1]);
|
||||||
|
ushort flags = (ushort)((responseBytes[2] << 8) | responseBytes[3]);
|
||||||
|
ushort qdcount = (ushort)((responseBytes[4] << 8) | responseBytes[5]);
|
||||||
|
ushort ancount = (ushort)((responseBytes[6] << 8) | responseBytes[7]);
|
||||||
|
ushort nscount = (ushort)((responseBytes[8] << 8) | responseBytes[9]);
|
||||||
|
ushort arcount = (ushort)((responseBytes[10] << 8) | responseBytes[11]);
|
||||||
|
|
||||||
|
List<DnsQuestion> questions = new List<DnsQuestion>();
|
||||||
|
|
||||||
|
//for (int i = 0; i < qdcount; i++)
|
||||||
|
//{
|
||||||
|
// DnsQuestion question = ParseDnsQuestionRecord(responseBytes, ref offset);
|
||||||
|
// if (question != null)
|
||||||
|
// {
|
||||||
|
// questions.Add(question);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
int offset = 12;
|
||||||
|
|
||||||
|
// Parse the DNS answer records
|
||||||
|
List<ResourceRecord> answers = new List<ResourceRecord>();
|
||||||
|
for (int i = 0; i < ancount; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResourceRecord answer = ParseDnsAnswerRecord(responseBytes, ref offset);
|
||||||
|
if (answer != null)
|
||||||
|
{
|
||||||
|
answers.Add(answer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
OnLog?.Invoke(null, $"Answer exception: " + exception.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the DNS authority records
|
||||||
|
List<ResourceRecord> authorities = new List<ResourceRecord>();
|
||||||
|
for (int i = 0; i < nscount; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResourceRecord authority = ParseDnsAnswerRecord(responseBytes, ref offset);
|
||||||
|
if (authority != null)
|
||||||
|
{
|
||||||
|
authorities.Add(authority);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
OnLog?.Invoke(null, $"Authority answer exception: " + exception.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the DNS additional records
|
||||||
|
List<ResourceRecord> additionals = new List<ResourceRecord>();
|
||||||
|
for (int i = 0; i < arcount; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResourceRecord additional = ParseDnsAnswerRecord(responseBytes, ref offset);
|
||||||
|
if (additional != null)
|
||||||
|
{
|
||||||
|
additionals.Add(additional);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
OnLog?.Invoke(null, $"Additional answer exception: " + exception.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DnsResponse
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
StartTime = startTime,
|
||||||
|
Resolver = server,
|
||||||
|
Flags = flags,
|
||||||
|
Class = (DnsRecordClass)((flags >> 3) & 0x0f),
|
||||||
|
DnsId = dnsId,
|
||||||
|
Questions = questions,
|
||||||
|
Answers = answers,
|
||||||
|
Authorities = authorities,
|
||||||
|
Additionals = additionals,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static ResourceRecord ParseDnsAnswerRecord(byte[] responseBytes, ref int offset)
|
||||||
|
{
|
||||||
|
// Parse the DNS name
|
||||||
|
string name = ParseDnsName(responseBytes, ref offset);
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the DNS type, class, ttl, and data length
|
||||||
|
DnsRecordType type = (DnsRecordType)((responseBytes[offset++] << 8) | responseBytes[offset++]);
|
||||||
|
DnsRecordClass klass = (DnsRecordClass)((responseBytes[offset++] << 8) | responseBytes[offset++]);
|
||||||
|
uint ttl = (uint)((responseBytes[offset++] << 24) | (responseBytes[offset++] << 16) | (responseBytes[offset++] << 8) | responseBytes[offset++]);
|
||||||
|
ushort rdlen = (ushort)((responseBytes[responseBytes.Length - 5]));
|
||||||
|
offset += 10;
|
||||||
|
|
||||||
|
// Parse the DNS data
|
||||||
|
string data = null;
|
||||||
|
switch ((DnsRecordType)type)
|
||||||
|
{
|
||||||
|
case DnsRecordType.A:
|
||||||
|
if (rdlen != 4)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = new IPAddress(new byte[]
|
||||||
|
{
|
||||||
|
responseBytes[offset], responseBytes[offset + 1], responseBytes[offset + 2],
|
||||||
|
responseBytes[offset + 3]
|
||||||
|
}).ToString();
|
||||||
|
offset += rdlen;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case DnsRecordType.CNAME:
|
||||||
ipResponse = "CNAME";
|
case DnsRecordType.NS:
|
||||||
|
data = ParseDnsName(responseBytes, ref offset);
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 6:
|
case DnsRecordType.MX:
|
||||||
ipResponse = "SOA";
|
ushort preference = (ushort)((responseBytes[offset] << 8) | responseBytes[offset + 1]);
|
||||||
|
offset += 2;
|
||||||
|
string exchange = ParseDnsName(responseBytes, ref offset);
|
||||||
|
if (exchange == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = $"{preference} {exchange}";
|
||||||
|
break;
|
||||||
|
case DnsRecordType.TXT:
|
||||||
|
data = Encoding.ASCII.GetString(responseBytes, offset, rdlen);
|
||||||
|
offset += rdlen;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
offset += rdlen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStatus($"Answer: {startOfUrl}.{domain} : {ipResponse}");
|
return new ResourceRecord
|
||||||
|
|
||||||
// Find the url in the list
|
|
||||||
for (int i = 0; i < result.Items.Count; i++)
|
|
||||||
{
|
{
|
||||||
if (result.Items[i].Text != $"{startOfUrl}.{domain}") continue;
|
Name = name,
|
||||||
|
Type = type,
|
||||||
|
Class = klass,
|
||||||
|
Ttl = TimeSpan.FromSeconds(ttl),
|
||||||
|
Data = data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
string sDeltaTime;
|
static string ParseDnsName(byte[] responseBytes, ref int offset)
|
||||||
switch (dnsId)
|
{
|
||||||
|
StringBuilder name = new StringBuilder();
|
||||||
|
int originalOffset = offset;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
byte len = responseBytes[offset++];
|
||||||
|
if (len == 0)
|
||||||
{
|
{
|
||||||
case 49:
|
|
||||||
result.Items[i].SubItems[1].Text = Convert.ToString(ipResponse);
|
|
||||||
sDeltaTime = Convert.ToString(deltaTime);
|
|
||||||
result.Items[i].SubItems[2].Text =
|
|
||||||
sDeltaTime.Length > 5 ? sDeltaTime.Substring(0, 5) : sDeltaTime;
|
|
||||||
result.Items[i].ForeColor = System.Drawing.Color.Red;
|
|
||||||
result.EnsureVisible(i);
|
|
||||||
result.Update();
|
|
||||||
Application.DoEvents();
|
|
||||||
result.Items[i].ForeColor = System.Drawing.Color.Black;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 50:
|
|
||||||
result.Items[i].SubItems[3].Text = Convert.ToString(ipResponse);
|
|
||||||
sDeltaTime = Convert.ToString(deltaTime);
|
|
||||||
result.Items[i].SubItems[4].Text =
|
|
||||||
sDeltaTime.Length > 5 ? sDeltaTime.Substring(0, 5) : sDeltaTime;
|
|
||||||
result.Items[i].ForeColor = System.Drawing.Color.Red;
|
|
||||||
result.EnsureVisible(i);
|
|
||||||
result.Update();
|
|
||||||
Application.DoEvents();
|
|
||||||
result.Items[i].ForeColor = System.Drawing.Color.Black;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
totalReceived++;
|
if ((len & 0xc0) == 0xc0)
|
||||||
|
{
|
||||||
|
ushort pointer = (ushort)(((len & 0x3f) << 8) | responseBytes[offset++]);
|
||||||
|
int pointerOffset = pointer & 0x3fff;
|
||||||
|
if (pointerOffset >= responseBytes.Length)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pointerEnd = offset;
|
||||||
|
offset = pointerOffset;
|
||||||
|
if (offset < originalOffset)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
name.Append(ParseDnsName(responseBytes, ref offset));
|
||||||
|
offset = pointerEnd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > 63)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
name.Append(Encoding.ASCII.GetString(responseBytes, offset, len));
|
||||||
|
offset += len;
|
||||||
|
if (responseBytes[offset - 1] != 0)
|
||||||
|
{
|
||||||
|
name.Append(".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetStatus(string text)
|
if (originalOffset == offset)
|
||||||
{
|
{
|
||||||
Log?.Invoke(null, text);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return name.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DnsQuestion
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public DnsRecordType Type { get; set; }
|
||||||
|
public DnsRecordClass Class { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ResourceRecord
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public DnsRecordType Type { get; set; }
|
||||||
|
public string Data { get; set; }
|
||||||
|
public DnsRecordClass Class { get; set; }
|
||||||
|
public TimeSpan Ttl { get; set; }
|
||||||
|
public ushort DataLength { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DnsResponse
|
||||||
|
{
|
||||||
|
public ushort Id { get; set; }
|
||||||
|
public ushort Flags { get; set; }
|
||||||
|
public DnsRecordClass Class { get; set; }
|
||||||
|
public List<ResourceRecord> Answers { get; set; }
|
||||||
|
public long StartTime { get; set; }
|
||||||
|
public string Resolver { get; set; }
|
||||||
|
public string DnsId { get; set; }
|
||||||
|
public List<DnsQuestion> Questions { get; set; }
|
||||||
|
public List<ResourceRecord> Authorities { get; set; }
|
||||||
|
public List<ResourceRecord> Additionals { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DnsRecordType : ushort
|
||||||
|
{
|
||||||
|
A = 1,
|
||||||
|
NS = 2,
|
||||||
|
CNAME = 5,
|
||||||
|
MX = 15,
|
||||||
|
TXT = 16,
|
||||||
|
AAAA = 28,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DnsRecordClass : ushort
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The Internet.
|
||||||
|
/// </summary>
|
||||||
|
Internet = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The CSNET class (Obsolete - used only for examples insome obsolete RFCs).
|
||||||
|
/// </summary>
|
||||||
|
CS = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The CHAOS class.
|
||||||
|
/// </summary>
|
||||||
|
CH = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hesiod[Dyer 87].
|
||||||
|
/// </summary>
|
||||||
|
HS = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used in UPDATE message to signify no class.
|
||||||
|
/// </summary>
|
||||||
|
None = 254,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Only used in QCLASS.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="Question.Class"/>
|
||||||
|
ANY = 255
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,7 @@ namespace EonaCat.DnsTester.Helpers
|
||||||
|
|
||||||
public static void GetRandomUrls(ref List<string> urlList, int totalUrls)
|
public static void GetRandomUrls(ref List<string> urlList, int totalUrls)
|
||||||
{
|
{
|
||||||
// Generate a cryptographically strong random string
|
var letters = GetRandomLetters();
|
||||||
byte[] randomBytes = new byte[32];
|
|
||||||
_randomNumberGenerator.GetBytes(randomBytes);
|
|
||||||
string letters = Convert.ToBase64String(randomBytes);
|
|
||||||
|
|
||||||
Dictionary<string, string> searchEngineUrls = new Dictionary<string, string>
|
Dictionary<string, string> searchEngineUrls = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
@ -81,14 +78,27 @@ namespace EonaCat.DnsTester.Helpers
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
searchEngineUrls.Remove(searchEngine.Key);
|
||||||
SetStatus($"{searchEngine.Key}: {ex.Message}");
|
SetStatus($"{searchEngine.Key}: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
letters = GetRandomLetters();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
urlList = localCleanNames; // Update the reference to the list
|
urlList = localCleanNames; // Update the reference to the list
|
||||||
SetStatus($"{urlList.Count} Random URL's found");
|
SetStatus($"{urlList.Count} Random URL's found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetRandomLetters()
|
||||||
|
{
|
||||||
|
// Generate a cryptographically strong random string
|
||||||
|
byte[] randomBytes = new byte[32];
|
||||||
|
_randomNumberGenerator.GetBytes(randomBytes);
|
||||||
|
return Convert.ToBase64String(randomBytes);
|
||||||
|
}
|
||||||
|
|
||||||
private static void SetStatus(string text)
|
private static void SetStatus(string text)
|
||||||
{
|
{
|
||||||
Log?.Invoke(null, text);
|
Log?.Invoke(null, text);
|
||||||
|
|
|
@ -29,360 +29,353 @@
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
this.ResultView = new System.Windows.Forms.ListView();
|
ResultView = new System.Windows.Forms.ListView();
|
||||||
this.WebName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
WebName = new System.Windows.Forms.ColumnHeader();
|
||||||
this.DNS1IP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
DNS1IP = new System.Windows.Forms.ColumnHeader();
|
||||||
this.DNS1Timing = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
DNS1Timing = new System.Windows.Forms.ColumnHeader();
|
||||||
this.DNS2IP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
DNS2IP = new System.Windows.Forms.ColumnHeader();
|
||||||
this.DNS2Timing = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
DNS2Timing = new System.Windows.Forms.ColumnHeader();
|
||||||
this.RunTest = new System.Windows.Forms.Button();
|
RunTest = new System.Windows.Forms.Button();
|
||||||
this.lblDns1 = new System.Windows.Forms.Label();
|
lblDns1 = new System.Windows.Forms.Label();
|
||||||
this.lblDns2 = new System.Windows.Forms.Label();
|
lblDns2 = new System.Windows.Forms.Label();
|
||||||
this.dnsList1 = new System.Windows.Forms.ComboBox();
|
dnsList1 = new System.Windows.Forms.ComboBox();
|
||||||
this.dnsList2 = new System.Windows.Forms.ComboBox();
|
dnsList2 = new System.Windows.Forms.ComboBox();
|
||||||
this.UseCustomServers = new System.Windows.Forms.CheckBox();
|
UseCustomServers = new System.Windows.Forms.CheckBox();
|
||||||
this.lblCustom1 = new System.Windows.Forms.Label();
|
lblCustom1 = new System.Windows.Forms.Label();
|
||||||
this.lblCustom2 = new System.Windows.Forms.Label();
|
lblCustom2 = new System.Windows.Forms.Label();
|
||||||
this.CustomDns1 = new System.Windows.Forms.TextBox();
|
CustomDns1 = new System.Windows.Forms.TextBox();
|
||||||
this.CustomDns2 = new System.Windows.Forms.TextBox();
|
CustomDns2 = new System.Windows.Forms.TextBox();
|
||||||
this.lslStatus = new System.Windows.Forms.Label();
|
lslStatus = new System.Windows.Forms.Label();
|
||||||
this.StatusBox = new System.Windows.Forms.ListBox();
|
StatusBox = new System.Windows.Forms.ListBox();
|
||||||
this.chkDns1 = new System.Windows.Forms.CheckBox();
|
chkDns1 = new System.Windows.Forms.CheckBox();
|
||||||
this.chkDns2 = new System.Windows.Forms.CheckBox();
|
chkDns2 = new System.Windows.Forms.CheckBox();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
label1 = new System.Windows.Forms.Label();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
label2 = new System.Windows.Forms.Label();
|
||||||
this.txtResolveIP = new System.Windows.Forms.TextBox();
|
txtResolveIP = new System.Windows.Forms.TextBox();
|
||||||
this.txtResolveHost = new System.Windows.Forms.TextBox();
|
txtResolveHost = new System.Windows.Forms.TextBox();
|
||||||
this.btnResolveIP = new System.Windows.Forms.Button();
|
btnResolveIP = new System.Windows.Forms.Button();
|
||||||
this.btnResolveHost = new System.Windows.Forms.Button();
|
btnResolveHost = new System.Windows.Forms.Button();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
label3 = new System.Windows.Forms.Label();
|
||||||
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
comboBox1 = new System.Windows.Forms.ComboBox();
|
||||||
this.SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// ResultView
|
// ResultView
|
||||||
//
|
//
|
||||||
this.ResultView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
ResultView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { WebName, DNS1IP, DNS1Timing, DNS2IP, DNS2Timing });
|
||||||
this.WebName,
|
ResultView.GridLines = true;
|
||||||
this.DNS1IP,
|
ResultView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||||
this.DNS1Timing,
|
ResultView.Location = new System.Drawing.Point(155, 469);
|
||||||
this.DNS2IP,
|
ResultView.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.DNS2Timing});
|
ResultView.MultiSelect = false;
|
||||||
this.ResultView.GridLines = true;
|
ResultView.Name = "ResultView";
|
||||||
this.ResultView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
ResultView.Size = new System.Drawing.Size(2209, 663);
|
||||||
this.ResultView.HideSelection = false;
|
ResultView.TabIndex = 11;
|
||||||
this.ResultView.Location = new System.Drawing.Point(155, 379);
|
ResultView.UseCompatibleStateImageBehavior = false;
|
||||||
this.ResultView.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
ResultView.View = System.Windows.Forms.View.Details;
|
||||||
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
|
// WebName
|
||||||
//
|
//
|
||||||
this.WebName.Text = "URL";
|
WebName.Text = "URL";
|
||||||
this.WebName.Width = 160;
|
WebName.Width = 160;
|
||||||
//
|
//
|
||||||
// DNS1IP
|
// DNS1IP
|
||||||
//
|
//
|
||||||
this.DNS1IP.Text = "IP Address from DNS 1";
|
DNS1IP.Text = "IP Address from DNS 1";
|
||||||
this.DNS1IP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
DNS1IP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
this.DNS1IP.Width = 140;
|
DNS1IP.Width = 140;
|
||||||
//
|
//
|
||||||
// DNS1Timing
|
// DNS1Timing
|
||||||
//
|
//
|
||||||
this.DNS1Timing.Text = "DNS 1 Timing";
|
DNS1Timing.Text = "DNS 1 Timing";
|
||||||
this.DNS1Timing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
DNS1Timing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
this.DNS1Timing.Width = 120;
|
DNS1Timing.Width = 120;
|
||||||
//
|
//
|
||||||
// DNS2IP
|
// DNS2IP
|
||||||
//
|
//
|
||||||
this.DNS2IP.Text = "IP Address from DNS 2";
|
DNS2IP.Text = "IP Address from DNS 2";
|
||||||
this.DNS2IP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
DNS2IP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
this.DNS2IP.Width = 140;
|
DNS2IP.Width = 140;
|
||||||
//
|
//
|
||||||
// DNS2Timing
|
// DNS2Timing
|
||||||
//
|
//
|
||||||
this.DNS2Timing.Text = "DNS 2 Timing";
|
DNS2Timing.Text = "DNS 2 Timing";
|
||||||
this.DNS2Timing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
DNS2Timing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
this.DNS2Timing.Width = 120;
|
DNS2Timing.Width = 120;
|
||||||
//
|
//
|
||||||
// RunTest
|
// RunTest
|
||||||
//
|
//
|
||||||
this.RunTest.Location = new System.Drawing.Point(1131, 1152);
|
RunTest.Location = new System.Drawing.Point(1131, 1152);
|
||||||
this.RunTest.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
RunTest.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.RunTest.Name = "RunTest";
|
RunTest.Name = "RunTest";
|
||||||
this.RunTest.Size = new System.Drawing.Size(200, 55);
|
RunTest.Size = new System.Drawing.Size(200, 55);
|
||||||
this.RunTest.TabIndex = 12;
|
RunTest.TabIndex = 12;
|
||||||
this.RunTest.Text = "Run Test";
|
RunTest.Text = "Run Test";
|
||||||
this.RunTest.Click += new System.EventHandler(this.RunTest_Click);
|
RunTest.Click += RunTest_Click;
|
||||||
//
|
//
|
||||||
// lblDns1
|
// lblDns1
|
||||||
//
|
//
|
||||||
this.lblDns1.AutoSize = true;
|
lblDns1.AutoSize = true;
|
||||||
this.lblDns1.Location = new System.Drawing.Point(155, 167);
|
lblDns1.Location = new System.Drawing.Point(155, 167);
|
||||||
this.lblDns1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
lblDns1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
||||||
this.lblDns1.Name = "lblDns1";
|
lblDns1.Name = "lblDns1";
|
||||||
this.lblDns1.Size = new System.Drawing.Size(95, 32);
|
lblDns1.Size = new System.Drawing.Size(100, 41);
|
||||||
this.lblDns1.TabIndex = 13;
|
lblDns1.TabIndex = 13;
|
||||||
this.lblDns1.Text = "Dns 1:";
|
lblDns1.Text = "Dns 1:";
|
||||||
//
|
//
|
||||||
// lblDns2
|
// lblDns2
|
||||||
//
|
//
|
||||||
this.lblDns2.AutoSize = true;
|
lblDns2.AutoSize = true;
|
||||||
this.lblDns2.Location = new System.Drawing.Point(1096, 167);
|
lblDns2.Location = new System.Drawing.Point(1174, 173);
|
||||||
this.lblDns2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
lblDns2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
||||||
this.lblDns2.Name = "lblDns2";
|
lblDns2.Name = "lblDns2";
|
||||||
this.lblDns2.Size = new System.Drawing.Size(95, 32);
|
lblDns2.Size = new System.Drawing.Size(100, 41);
|
||||||
this.lblDns2.TabIndex = 14;
|
lblDns2.TabIndex = 14;
|
||||||
this.lblDns2.Text = "Dns 2:";
|
lblDns2.Text = "Dns 2:";
|
||||||
//
|
//
|
||||||
// dnsList1
|
// dnsList1
|
||||||
//
|
//
|
||||||
this.dnsList1.FormattingEnabled = true;
|
dnsList1.FormattingEnabled = true;
|
||||||
this.dnsList1.ItemHeight = 31;
|
dnsList1.ItemHeight = 41;
|
||||||
this.dnsList1.Location = new System.Drawing.Point(277, 155);
|
dnsList1.Location = new System.Drawing.Point(277, 155);
|
||||||
this.dnsList1.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
dnsList1.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.dnsList1.Name = "dnsList1";
|
dnsList1.Name = "dnsList1";
|
||||||
this.dnsList1.Size = new System.Drawing.Size(756, 39);
|
dnsList1.Size = new System.Drawing.Size(756, 49);
|
||||||
this.dnsList1.TabIndex = 15;
|
dnsList1.TabIndex = 15;
|
||||||
//
|
//
|
||||||
// dnsList2
|
// dnsList2
|
||||||
//
|
//
|
||||||
this.dnsList2.FormattingEnabled = true;
|
dnsList2.FormattingEnabled = true;
|
||||||
this.dnsList2.ItemHeight = 31;
|
dnsList2.ItemHeight = 41;
|
||||||
this.dnsList2.Location = new System.Drawing.Point(1229, 155);
|
dnsList2.Location = new System.Drawing.Point(1307, 161);
|
||||||
this.dnsList2.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
dnsList2.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.dnsList2.Name = "dnsList2";
|
dnsList2.Name = "dnsList2";
|
||||||
this.dnsList2.Size = new System.Drawing.Size(788, 39);
|
dnsList2.Size = new System.Drawing.Size(788, 49);
|
||||||
this.dnsList2.TabIndex = 16;
|
dnsList2.TabIndex = 16;
|
||||||
//
|
//
|
||||||
// UseCustomServers
|
// UseCustomServers
|
||||||
//
|
//
|
||||||
this.UseCustomServers.AutoSize = true;
|
UseCustomServers.AutoSize = true;
|
||||||
this.UseCustomServers.Location = new System.Drawing.Point(2091, 167);
|
UseCustomServers.Location = new System.Drawing.Point(2169, 173);
|
||||||
this.UseCustomServers.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
UseCustomServers.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.UseCustomServers.Name = "UseCustomServers";
|
UseCustomServers.Name = "UseCustomServers";
|
||||||
this.UseCustomServers.Size = new System.Drawing.Size(253, 36);
|
UseCustomServers.Size = new System.Drawing.Size(262, 45);
|
||||||
this.UseCustomServers.TabIndex = 17;
|
UseCustomServers.TabIndex = 17;
|
||||||
this.UseCustomServers.Text = "Custom Servers";
|
UseCustomServers.Text = "Custom Servers";
|
||||||
this.UseCustomServers.UseVisualStyleBackColor = true;
|
UseCustomServers.UseVisualStyleBackColor = true;
|
||||||
this.UseCustomServers.CheckedChanged += new System.EventHandler(this.UseCustomServers_CheckedChanged);
|
UseCustomServers.CheckedChanged += UseCustomServers_CheckedChanged;
|
||||||
//
|
//
|
||||||
// lblCustom1
|
// lblCustom1
|
||||||
//
|
//
|
||||||
this.lblCustom1.AutoSize = true;
|
lblCustom1.AutoSize = true;
|
||||||
this.lblCustom1.Location = new System.Drawing.Point(155, 293);
|
lblCustom1.Location = new System.Drawing.Point(155, 328);
|
||||||
this.lblCustom1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
lblCustom1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
||||||
this.lblCustom1.Name = "lblCustom1";
|
lblCustom1.Name = "lblCustom1";
|
||||||
this.lblCustom1.Size = new System.Drawing.Size(206, 32);
|
lblCustom1.Size = new System.Drawing.Size(219, 41);
|
||||||
this.lblCustom1.TabIndex = 18;
|
lblCustom1.TabIndex = 18;
|
||||||
this.lblCustom1.Text = "Custom Dns 1: ";
|
lblCustom1.Text = "Custom Dns 1: ";
|
||||||
this.lblCustom1.Visible = false;
|
lblCustom1.Visible = false;
|
||||||
//
|
//
|
||||||
// lblCustom2
|
// lblCustom2
|
||||||
//
|
//
|
||||||
this.lblCustom2.AutoSize = true;
|
lblCustom2.AutoSize = true;
|
||||||
this.lblCustom2.Location = new System.Drawing.Point(1096, 293);
|
lblCustom2.Location = new System.Drawing.Point(1174, 334);
|
||||||
this.lblCustom2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
lblCustom2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
||||||
this.lblCustom2.Name = "lblCustom2";
|
lblCustom2.Name = "lblCustom2";
|
||||||
this.lblCustom2.Size = new System.Drawing.Size(206, 32);
|
lblCustom2.Size = new System.Drawing.Size(219, 41);
|
||||||
this.lblCustom2.TabIndex = 19;
|
lblCustom2.TabIndex = 19;
|
||||||
this.lblCustom2.Text = "Custom Dns 2: ";
|
lblCustom2.Text = "Custom Dns 2: ";
|
||||||
this.lblCustom2.Visible = false;
|
lblCustom2.Visible = false;
|
||||||
//
|
//
|
||||||
// CustomDns1
|
// CustomDns1
|
||||||
//
|
//
|
||||||
this.CustomDns1.BackColor = System.Drawing.Color.White;
|
CustomDns1.BackColor = System.Drawing.Color.White;
|
||||||
this.CustomDns1.Enabled = false;
|
CustomDns1.Enabled = false;
|
||||||
this.CustomDns1.Location = new System.Drawing.Point(408, 289);
|
CustomDns1.Location = new System.Drawing.Point(408, 324);
|
||||||
this.CustomDns1.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
CustomDns1.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.CustomDns1.Name = "CustomDns1";
|
CustomDns1.Name = "CustomDns1";
|
||||||
this.CustomDns1.Size = new System.Drawing.Size(625, 38);
|
CustomDns1.Size = new System.Drawing.Size(625, 47);
|
||||||
this.CustomDns1.TabIndex = 20;
|
CustomDns1.TabIndex = 20;
|
||||||
this.CustomDns1.Visible = false;
|
CustomDns1.Visible = false;
|
||||||
//
|
//
|
||||||
// CustomDns2
|
// CustomDns2
|
||||||
//
|
//
|
||||||
this.CustomDns2.Enabled = false;
|
CustomDns2.Enabled = false;
|
||||||
this.CustomDns2.Location = new System.Drawing.Point(1349, 289);
|
CustomDns2.Location = new System.Drawing.Point(1427, 330);
|
||||||
this.CustomDns2.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
CustomDns2.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.CustomDns2.Name = "CustomDns2";
|
CustomDns2.Name = "CustomDns2";
|
||||||
this.CustomDns2.Size = new System.Drawing.Size(668, 38);
|
CustomDns2.Size = new System.Drawing.Size(668, 47);
|
||||||
this.CustomDns2.TabIndex = 21;
|
CustomDns2.TabIndex = 21;
|
||||||
this.CustomDns2.Visible = false;
|
CustomDns2.Visible = false;
|
||||||
//
|
//
|
||||||
// lslStatus
|
// lslStatus
|
||||||
//
|
//
|
||||||
this.lslStatus.AutoSize = true;
|
lslStatus.AutoSize = true;
|
||||||
this.lslStatus.Location = new System.Drawing.Point(155, 1219);
|
lslStatus.Location = new System.Drawing.Point(155, 1219);
|
||||||
this.lslStatus.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
lslStatus.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0);
|
||||||
this.lslStatus.Name = "lslStatus";
|
lslStatus.Name = "lslStatus";
|
||||||
this.lslStatus.Size = new System.Drawing.Size(103, 32);
|
lslStatus.Size = new System.Drawing.Size(105, 41);
|
||||||
this.lslStatus.TabIndex = 22;
|
lslStatus.TabIndex = 22;
|
||||||
this.lslStatus.Text = "Status:";
|
lslStatus.Text = "Status:";
|
||||||
//
|
//
|
||||||
// StatusBox
|
// StatusBox
|
||||||
//
|
//
|
||||||
this.StatusBox.FormattingEnabled = true;
|
StatusBox.FormattingEnabled = true;
|
||||||
this.StatusBox.HorizontalScrollbar = true;
|
StatusBox.HorizontalScrollbar = true;
|
||||||
this.StatusBox.ItemHeight = 31;
|
StatusBox.ItemHeight = 41;
|
||||||
this.StatusBox.Location = new System.Drawing.Point(155, 1271);
|
StatusBox.Location = new System.Drawing.Point(155, 1271);
|
||||||
this.StatusBox.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
StatusBox.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.StatusBox.Name = "StatusBox";
|
StatusBox.Name = "StatusBox";
|
||||||
this.StatusBox.Size = new System.Drawing.Size(2209, 376);
|
StatusBox.Size = new System.Drawing.Size(2209, 373);
|
||||||
this.StatusBox.TabIndex = 23;
|
StatusBox.TabIndex = 23;
|
||||||
//
|
//
|
||||||
// chkDns1
|
// chkDns1
|
||||||
//
|
//
|
||||||
this.chkDns1.AutoSize = true;
|
chkDns1.AutoSize = true;
|
||||||
this.chkDns1.Checked = true;
|
chkDns1.Checked = true;
|
||||||
this.chkDns1.CheckState = System.Windows.Forms.CheckState.Checked;
|
chkDns1.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.chkDns1.Location = new System.Drawing.Point(277, 220);
|
chkDns1.Location = new System.Drawing.Point(277, 235);
|
||||||
this.chkDns1.Name = "chkDns1";
|
chkDns1.Name = "chkDns1";
|
||||||
this.chkDns1.Size = new System.Drawing.Size(245, 36);
|
chkDns1.Size = new System.Drawing.Size(251, 45);
|
||||||
this.chkDns1.TabIndex = 24;
|
chkDns1.TabIndex = 24;
|
||||||
this.chkDns1.Text = "Test dns server";
|
chkDns1.Text = "Test dns server";
|
||||||
this.chkDns1.UseVisualStyleBackColor = true;
|
chkDns1.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// chkDns2
|
// chkDns2
|
||||||
//
|
//
|
||||||
this.chkDns2.AutoSize = true;
|
chkDns2.AutoSize = true;
|
||||||
this.chkDns2.Checked = true;
|
chkDns2.Checked = true;
|
||||||
this.chkDns2.CheckState = System.Windows.Forms.CheckState.Checked;
|
chkDns2.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.chkDns2.Location = new System.Drawing.Point(1229, 220);
|
chkDns2.Location = new System.Drawing.Point(1307, 241);
|
||||||
this.chkDns2.Name = "chkDns2";
|
chkDns2.Name = "chkDns2";
|
||||||
this.chkDns2.Size = new System.Drawing.Size(245, 36);
|
chkDns2.Size = new System.Drawing.Size(251, 45);
|
||||||
this.chkDns2.TabIndex = 25;
|
chkDns2.TabIndex = 25;
|
||||||
this.chkDns2.Text = "Test dns server";
|
chkDns2.Text = "Test dns server";
|
||||||
this.chkDns2.UseVisualStyleBackColor = true;
|
chkDns2.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(155, 27);
|
label1.Location = new System.Drawing.Point(155, 27);
|
||||||
this.label1.Name = "label1";
|
label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(263, 32);
|
label1.Size = new System.Drawing.Size(270, 41);
|
||||||
this.label1.TabIndex = 26;
|
label1.TabIndex = 26;
|
||||||
this.label1.Text = "Resolve ip address:";
|
label1.Text = "Resolve ip address:";
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
this.label2.Location = new System.Drawing.Point(1102, 27);
|
label2.Location = new System.Drawing.Point(1180, 33);
|
||||||
this.label2.Name = "label2";
|
label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(257, 32);
|
label2.Size = new System.Drawing.Size(266, 41);
|
||||||
this.label2.TabIndex = 27;
|
label2.TabIndex = 27;
|
||||||
this.label2.Text = "Resolve hostname:";
|
label2.Text = "Resolve hostname:";
|
||||||
//
|
//
|
||||||
// txtResolveIP
|
// txtResolveIP
|
||||||
//
|
//
|
||||||
this.txtResolveIP.Location = new System.Drawing.Point(425, 21);
|
txtResolveIP.Location = new System.Drawing.Point(425, 21);
|
||||||
this.txtResolveIP.Name = "txtResolveIP";
|
txtResolveIP.Name = "txtResolveIP";
|
||||||
this.txtResolveIP.Size = new System.Drawing.Size(608, 38);
|
txtResolveIP.Size = new System.Drawing.Size(608, 47);
|
||||||
this.txtResolveIP.TabIndex = 28;
|
txtResolveIP.TabIndex = 28;
|
||||||
//
|
//
|
||||||
// txtResolveHost
|
// txtResolveHost
|
||||||
//
|
//
|
||||||
this.txtResolveHost.Location = new System.Drawing.Point(1365, 21);
|
txtResolveHost.Location = new System.Drawing.Point(1443, 27);
|
||||||
this.txtResolveHost.Name = "txtResolveHost";
|
txtResolveHost.Name = "txtResolveHost";
|
||||||
this.txtResolveHost.Size = new System.Drawing.Size(651, 38);
|
txtResolveHost.Size = new System.Drawing.Size(651, 47);
|
||||||
this.txtResolveHost.TabIndex = 29;
|
txtResolveHost.TabIndex = 29;
|
||||||
//
|
//
|
||||||
// btnResolveIP
|
// btnResolveIP
|
||||||
//
|
//
|
||||||
this.btnResolveIP.Location = new System.Drawing.Point(425, 75);
|
btnResolveIP.Location = new System.Drawing.Point(425, 75);
|
||||||
this.btnResolveIP.Name = "btnResolveIP";
|
btnResolveIP.Name = "btnResolveIP";
|
||||||
this.btnResolveIP.Size = new System.Drawing.Size(195, 70);
|
btnResolveIP.Size = new System.Drawing.Size(205, 51);
|
||||||
this.btnResolveIP.TabIndex = 30;
|
btnResolveIP.TabIndex = 30;
|
||||||
this.btnResolveIP.Text = "Resolve";
|
btnResolveIP.Text = "Resolve";
|
||||||
this.btnResolveIP.UseVisualStyleBackColor = true;
|
btnResolveIP.UseVisualStyleBackColor = true;
|
||||||
this.btnResolveIP.Click += new System.EventHandler(this.btnResolveIP_Click);
|
btnResolveIP.Click += btnResolveIP_Click;
|
||||||
//
|
//
|
||||||
// btnResolveHost
|
// btnResolveHost
|
||||||
//
|
//
|
||||||
this.btnResolveHost.Location = new System.Drawing.Point(1366, 75);
|
btnResolveHost.Location = new System.Drawing.Point(1443, 81);
|
||||||
this.btnResolveHost.Name = "btnResolveHost";
|
btnResolveHost.Name = "btnResolveHost";
|
||||||
this.btnResolveHost.Size = new System.Drawing.Size(221, 70);
|
btnResolveHost.Size = new System.Drawing.Size(167, 45);
|
||||||
this.btnResolveHost.TabIndex = 31;
|
btnResolveHost.TabIndex = 31;
|
||||||
this.btnResolveHost.Text = "Resolve";
|
btnResolveHost.Text = "Resolve";
|
||||||
this.btnResolveHost.UseVisualStyleBackColor = true;
|
btnResolveHost.UseVisualStyleBackColor = true;
|
||||||
this.btnResolveHost.Click += new System.EventHandler(this.btnResolveHost_Click);
|
btnResolveHost.Click += btnResolveHost_Click;
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(675, 223);
|
label3.Location = new System.Drawing.Point(675, 238);
|
||||||
this.label3.Name = "label3";
|
label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(201, 32);
|
label3.Size = new System.Drawing.Size(210, 41);
|
||||||
this.label3.TabIndex = 32;
|
label3.TabIndex = 32;
|
||||||
this.label3.Text = "Total domains:";
|
label3.Text = "Total domains:";
|
||||||
//
|
//
|
||||||
// numericUpDown1
|
// numericUpDown1
|
||||||
//
|
//
|
||||||
this.numericUpDown1.Location = new System.Drawing.Point(913, 223);
|
numericUpDown1.Location = new System.Drawing.Point(913, 238);
|
||||||
this.numericUpDown1.Maximum = new decimal(new int[] {
|
numericUpDown1.Maximum = new decimal(new int[] { 1000000000, 0, 0, 0 });
|
||||||
1000000000,
|
numericUpDown1.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
0,
|
numericUpDown1.Name = "numericUpDown1";
|
||||||
0,
|
numericUpDown1.Size = new System.Drawing.Size(120, 47);
|
||||||
0});
|
numericUpDown1.TabIndex = 33;
|
||||||
this.numericUpDown1.Minimum = new decimal(new int[] {
|
numericUpDown1.Value = new decimal(new int[] { 20, 0, 0, 0 });
|
||||||
1,
|
//
|
||||||
0,
|
// comboBox1
|
||||||
0,
|
//
|
||||||
0});
|
comboBox1.FormattingEnabled = true;
|
||||||
this.numericUpDown1.Name = "numericUpDown1";
|
comboBox1.Items.AddRange(new object[] { "A", "NS", "CNAME", "MX", "TXT" });
|
||||||
this.numericUpDown1.Size = new System.Drawing.Size(120, 38);
|
comboBox1.Location = new System.Drawing.Point(2129, 251);
|
||||||
this.numericUpDown1.TabIndex = 33;
|
comboBox1.Name = "comboBox1";
|
||||||
this.numericUpDown1.Value = new decimal(new int[] {
|
comboBox1.Size = new System.Drawing.Size(302, 49);
|
||||||
20,
|
comboBox1.TabIndex = 34;
|
||||||
0,
|
comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
|
||||||
0,
|
|
||||||
0});
|
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
|
AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.AutoSize = true;
|
AutoSize = true;
|
||||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||||
this.ClientSize = new System.Drawing.Size(2517, 1693);
|
ClientSize = new System.Drawing.Size(2517, 1693);
|
||||||
this.Controls.Add(this.numericUpDown1);
|
Controls.Add(comboBox1);
|
||||||
this.Controls.Add(this.label3);
|
Controls.Add(numericUpDown1);
|
||||||
this.Controls.Add(this.btnResolveHost);
|
Controls.Add(label3);
|
||||||
this.Controls.Add(this.btnResolveIP);
|
Controls.Add(btnResolveHost);
|
||||||
this.Controls.Add(this.txtResolveHost);
|
Controls.Add(btnResolveIP);
|
||||||
this.Controls.Add(this.txtResolveIP);
|
Controls.Add(txtResolveHost);
|
||||||
this.Controls.Add(this.label2);
|
Controls.Add(txtResolveIP);
|
||||||
this.Controls.Add(this.label1);
|
Controls.Add(label2);
|
||||||
this.Controls.Add(this.chkDns2);
|
Controls.Add(label1);
|
||||||
this.Controls.Add(this.chkDns1);
|
Controls.Add(chkDns2);
|
||||||
this.Controls.Add(this.StatusBox);
|
Controls.Add(chkDns1);
|
||||||
this.Controls.Add(this.lslStatus);
|
Controls.Add(StatusBox);
|
||||||
this.Controls.Add(this.CustomDns2);
|
Controls.Add(lslStatus);
|
||||||
this.Controls.Add(this.CustomDns1);
|
Controls.Add(CustomDns2);
|
||||||
this.Controls.Add(this.lblCustom2);
|
Controls.Add(CustomDns1);
|
||||||
this.Controls.Add(this.lblCustom1);
|
Controls.Add(lblCustom2);
|
||||||
this.Controls.Add(this.UseCustomServers);
|
Controls.Add(lblCustom1);
|
||||||
this.Controls.Add(this.dnsList2);
|
Controls.Add(UseCustomServers);
|
||||||
this.Controls.Add(this.dnsList1);
|
Controls.Add(dnsList2);
|
||||||
this.Controls.Add(this.lblDns2);
|
Controls.Add(dnsList1);
|
||||||
this.Controls.Add(this.lblDns1);
|
Controls.Add(lblDns2);
|
||||||
this.Controls.Add(this.RunTest);
|
Controls.Add(lblDns1);
|
||||||
this.Controls.Add(this.ResultView);
|
Controls.Add(RunTest);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
Controls.Add(ResultView);
|
||||||
this.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
|
||||||
this.MaximizeBox = false;
|
Margin = new System.Windows.Forms.Padding(8, 7, 8, 7);
|
||||||
this.Name = "MainForm";
|
MaximizeBox = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
Name = "MainForm";
|
||||||
this.Text = "EonaCat.DnsTester";
|
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Load += new System.EventHandler(this.TesterUI_Load);
|
Text = "EonaCat.DnsTester";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
Load += TesterUI_Load;
|
||||||
this.ResumeLayout(false);
|
((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit();
|
||||||
this.PerformLayout();
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -415,6 +408,7 @@
|
||||||
private System.Windows.Forms.Button btnResolveHost;
|
private System.Windows.Forms.Button btnResolveHost;
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||||
|
private System.Windows.Forms.ComboBox comboBox1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.DirectoryServices.ActiveDirectory;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -19,6 +20,7 @@ namespace EonaCat.DnsTester
|
||||||
{
|
{
|
||||||
private bool useCustomDnsServers;
|
private bool useCustomDnsServers;
|
||||||
private string _dnsServer1, _dnsServer2;
|
private string _dnsServer1, _dnsServer2;
|
||||||
|
private DnsRecordType _recordType;
|
||||||
private int _dnsTotalChecked;
|
private int _dnsTotalChecked;
|
||||||
|
|
||||||
public bool IsRunning { get; private set; }
|
public bool IsRunning { get; private set; }
|
||||||
|
@ -28,10 +30,17 @@ namespace EonaCat.DnsTester
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunTest_Click(object sender, EventArgs e)
|
private async void RunTest_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
List<string> urls = new List<string>();
|
List<string> urls = new List<string>();
|
||||||
SetupUrls(urls);
|
SetupView();
|
||||||
|
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
UrlHelper.GetRandomUrls(ref urls, (int)numericUpDown1.Value);
|
||||||
|
});
|
||||||
|
AddUrlToView(urls);
|
||||||
|
|
||||||
|
|
||||||
if (IsRunning)
|
if (IsRunning)
|
||||||
{
|
{
|
||||||
|
@ -39,11 +48,11 @@ namespace EonaCat.DnsTester
|
||||||
}
|
}
|
||||||
|
|
||||||
IsRunning = true;
|
IsRunning = true;
|
||||||
Process(urls.ToArray(), _dnsServer1, _dnsServer2);
|
Process(_recordType, urls.ToArray(), _dnsServer1, _dnsServer2);
|
||||||
IsRunning = false;
|
IsRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupUrls(List<string> urls)
|
private void SetupView()
|
||||||
{
|
{
|
||||||
if (useCustomDnsServers)
|
if (useCustomDnsServers)
|
||||||
{
|
{
|
||||||
|
@ -81,9 +90,8 @@ namespace EonaCat.DnsTester
|
||||||
ResultView.Update();
|
ResultView.Update();
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
|
UrlHelper.Log -= UrlHelper_Log;
|
||||||
UrlHelper.Log += UrlHelper_Log;
|
UrlHelper.Log += UrlHelper_Log;
|
||||||
UrlHelper.GetRandomUrls(ref urls, (int)numericUpDown1.Value);
|
|
||||||
AddUrlToView(urls);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UrlHelper_Log(object sender, string e)
|
private void UrlHelper_Log(object sender, string e)
|
||||||
|
@ -178,89 +186,132 @@ namespace EonaCat.DnsTester
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void Process(string[] urls, string dnsAddress1, string dnsAddress2)
|
private async Task Process(DnsRecordType recordType, string[] urls, string dnsAddress1, string dnsAddress2)
|
||||||
{
|
{
|
||||||
int i;
|
if (recordType == 0)
|
||||||
|
{
|
||||||
|
recordType = DnsRecordType.A;
|
||||||
|
}
|
||||||
|
|
||||||
int urlsTotal = urls.Length;
|
int urlsTotal = urls.Length;
|
||||||
const int ipPort = 53;
|
const string dnsId1 = "Dns1";
|
||||||
const string transactionId1 = "Q1";
|
const string dnsId2 = "Dns2";
|
||||||
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 startOfUrl = string.Empty;
|
|
||||||
string domain = string.Empty;
|
|
||||||
byte[] bytesSend = new byte[256];
|
|
||||||
Socket dnsSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
|
||||||
dnsSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, dnsReceiveTimeout);
|
|
||||||
|
|
||||||
SetupDnsServers(dnsAddress1, dnsAddress2, ipPort, out var dnsEndpoint1, out var dnsEndpoint2);
|
DnsHelper.OnLog -= DnsHelper_OnLog;
|
||||||
|
DnsHelper.OnLog += DnsHelper_OnLog;
|
||||||
|
|
||||||
// Start the clock
|
for (int i = 0; i < urlsTotal; i++)
|
||||||
var startTime = DateTime.Now.Ticks;
|
|
||||||
|
|
||||||
for (i = 0; i < urlsTotal; i++)
|
|
||||||
{
|
{
|
||||||
var currentUrl = urls[i];
|
var currentUrl = urls[i];
|
||||||
startOfUrl = currentUrl.Substring(0, currentUrl.IndexOf("."));
|
|
||||||
domain = currentUrl.Substring(currentUrl.IndexOf(".") + 1,
|
|
||||||
currentUrl.Length - currentUrl.IndexOf(".") - 1);
|
|
||||||
var dnsQuery = typeString + (char)startOfUrl.Length + startOfUrl + (char)domain.Length + domain +
|
|
||||||
trailerString;
|
|
||||||
|
|
||||||
string queryString;
|
|
||||||
if (chkDns1.Checked)
|
|
||||||
{
|
|
||||||
queryString = transactionId1 + dnsQuery;
|
|
||||||
bytesSend = Encoding.ASCII.GetBytes(queryString);
|
|
||||||
if (dnsEndpoint1 != null)
|
|
||||||
dnsSocket.SendTo(bytesSend, bytesSend.Length, SocketFlags.None, dnsEndpoint1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
await ExecuteDns1(recordType, dnsAddress1, currentUrl, dnsId1, i);
|
||||||
if (!chkDns2.Checked) continue;
|
if (!chkDns2.Checked) continue;
|
||||||
|
await ExecuteDns2(recordType, dnsAddress2, currentUrl, dnsId2, i);
|
||||||
|
|
||||||
queryString = transactionId2 + dnsQuery;
|
await Task.Delay(100);
|
||||||
bytesSend = Encoding.ASCII.GetBytes(queryString);
|
}
|
||||||
if (dnsEndpoint2 != null) dnsSocket.SendTo(bytesSend, bytesSend.Length, SocketFlags.None, dnsEndpoint2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteDns2(DnsRecordType recordType, string dnsAddress2, string currentUrl, string dnsId2,
|
||||||
|
int i)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DnsHelper.Log += DnsHelper_Log;
|
DnsResponse response2 = null;
|
||||||
DnsHelper.ProcessDns(startOfUrl, domain, urlsTotal, dnsSocket, bytesSend, startTime, _dnsTotalChecked, ResultView);
|
byte[] queryBytes2 = DnsHelper.CreateDnsQueryPacket(currentUrl, recordType);
|
||||||
|
response2 = await DnsHelper.SendDnsQueryPacket(dnsId2, dnsAddress2, 53, queryBytes2);
|
||||||
|
ProcessResponse(response2);
|
||||||
}
|
}
|
||||||
catch (SocketException socketException)
|
catch (SocketException socketException)
|
||||||
{
|
{
|
||||||
SetStatus(
|
SetStatus(
|
||||||
Convert.ToString(socketException).IndexOf("time", StringComparison.Ordinal) > 0
|
Convert.ToString(socketException).IndexOf("time", StringComparison.Ordinal) > 0
|
||||||
? $"Timeout - No response received for {Convert.ToString(dnsReceiveTimeout / 1000)} seconds"
|
? $"DNS1 Timeout - No response received for {Convert.ToString(DnsHelper.DnsReceiveTimeout / 1000)} seconds"
|
||||||
: Convert.ToString(socketException));
|
: Convert.ToString(socketException));
|
||||||
}
|
}
|
||||||
finally
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
// close the socket
|
SetStatus(exception.Message);
|
||||||
dnsSocket.Close();
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DnsHelper_Log(object sender, string e)
|
private async Task ExecuteDns1(DnsRecordType recordType, string dnsAddress1, string currentUrl, string dnsId1,
|
||||||
|
int i)
|
||||||
|
{
|
||||||
|
if (chkDns1.Checked)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DnsResponse response1 = null;
|
||||||
|
byte[] queryBytes1 = DnsHelper.CreateDnsQueryPacket(currentUrl, recordType);
|
||||||
|
response1 = await DnsHelper.SendDnsQueryPacket(dnsId1, dnsAddress1, 53, queryBytes1);
|
||||||
|
ProcessResponse(response1);
|
||||||
|
}
|
||||||
|
catch (SocketException socketException)
|
||||||
|
{
|
||||||
|
SetStatus(
|
||||||
|
Convert.ToString(socketException).IndexOf("time", StringComparison.Ordinal) > 0
|
||||||
|
? $"DNS1 Timeout - No response received for {Convert.ToString(DnsHelper.DnsReceiveTimeout / 1000)} seconds"
|
||||||
|
: Convert.ToString(socketException));
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
SetStatus(exception.Message);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DnsHelper_OnLog(object sender, string e)
|
||||||
{
|
{
|
||||||
SetStatus(e);
|
SetStatus(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupDnsServers(string dnsAddress1, string dnsAddress2, int ipPort, out IPEndPoint dnsEndpoint1,
|
private void ProcessResponse(DnsResponse dnsResponse)
|
||||||
out IPEndPoint dnsEndpoint2)
|
|
||||||
{
|
{
|
||||||
dnsEndpoint1 = null;
|
if (dnsResponse == null || dnsResponse.Answers == null || !dnsResponse.Answers.Any())
|
||||||
if (chkDns1.Checked && !string.IsNullOrWhiteSpace(dnsAddress1))
|
|
||||||
{
|
{
|
||||||
dnsEndpoint1 = new IPEndPoint(IPAddress.Parse(dnsAddress1), ipPort);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dnsEndpoint2 = null;
|
// Retrieve stopTime
|
||||||
if (chkDns2.Checked && !string.IsNullOrWhiteSpace(dnsAddress2))
|
var stopTime = DateTime.Now.Ticks;
|
||||||
|
var deltaTime = Convert.ToString((double)(stopTime - dnsResponse.StartTime) / 10000000);
|
||||||
|
|
||||||
|
SetStatus($"ResourceRecord: Name: {dnsResponse.Answers.FirstOrDefault().Name} : Type : {dnsResponse.Answers.FirstOrDefault().Type} : Data : {dnsResponse.Answers.FirstOrDefault().Data}");
|
||||||
|
|
||||||
|
for (int i = 0; i < ResultView.Items.Count; i++)
|
||||||
{
|
{
|
||||||
dnsEndpoint2 = new IPEndPoint(IPAddress.Parse(dnsAddress2), ipPort);
|
if (ResultView.Items[i].Text != $"{dnsResponse.Answers.FirstOrDefault().Name.TrimEnd('.')}") continue;
|
||||||
|
|
||||||
|
string sDeltaTime;
|
||||||
|
switch (dnsResponse.DnsId)
|
||||||
|
{
|
||||||
|
case "Dns1":
|
||||||
|
ResultView.Items[i].SubItems[1].Text = Convert.ToString(dnsResponse.Answers.FirstOrDefault().Data);
|
||||||
|
sDeltaTime = Convert.ToString(deltaTime);
|
||||||
|
ResultView.Items[i].SubItems[2].Text =
|
||||||
|
sDeltaTime.Length > 5 ? sDeltaTime.Substring(0, 5) : 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 "Dns2":
|
||||||
|
ResultView.Items[i].SubItems[3].Text = Convert.ToString(dnsResponse.Answers.FirstOrDefault().Data);
|
||||||
|
sDeltaTime = Convert.ToString(deltaTime);
|
||||||
|
ResultView.Items[i].SubItems[4].Text =
|
||||||
|
sDeltaTime.Length > 5 ? sDeltaTime.Substring(0, 5) : 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +373,8 @@ namespace EonaCat.DnsTester
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetStatus(string text)
|
private void SetStatus(string text)
|
||||||
|
{
|
||||||
|
StatusBox.Invoke(() =>
|
||||||
{
|
{
|
||||||
StatusBox.Items.Add($"{DateTime.Now} {text}");
|
StatusBox.Items.Add($"{DateTime.Now} {text}");
|
||||||
StatusBox.TopIndex = StatusBox.Items.Count - 1;
|
StatusBox.TopIndex = StatusBox.Items.Count - 1;
|
||||||
|
@ -329,9 +382,19 @@ namespace EonaCat.DnsTester
|
||||||
{
|
{
|
||||||
StatusBox.Items.RemoveAt(0);
|
StatusBox.Items.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBox.Update();
|
StatusBox.Update();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const int STATUS_BAR_SIZE = 5000;
|
const int STATUS_BAR_SIZE = 5000;
|
||||||
|
|
||||||
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (Enum.TryParse(comboBox1.SelectedItem.ToString().ToUpper(), out DnsRecordType queryType))
|
||||||
|
{
|
||||||
|
_recordType = queryType;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<root>
|
||||||
<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.Runtime.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:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("EonaCat.EonaCat.DnsTester")]
|
[assembly: AssemblyProduct("EonaCat.EonaCat.DnsTester")]
|
||||||
[assembly: AssemblyCopyright("Copyright © EonaCat (Jeroen Saey) 2027")]
|
[assembly: AssemblyCopyright("Copyright © EonaCat (Jeroen Saey) 2023")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace EonaCat.EonaCat.DnsTester.Properties {
|
namespace EonaCat.DnsTester.Properties {
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
@ -22,5 +22,17 @@ namespace EonaCat.EonaCat.DnsTester.Properties {
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string EonaCat {
|
||||||
|
get {
|
||||||
|
return ((string)(this["EonaCat"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["EonaCat"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="EonaCat.DnsTester.Properties" GeneratedClassName="Settings">
|
||||||
<Profiles>
|
<Profiles />
|
||||||
<Profile Name="(Default)" />
|
<Settings>
|
||||||
</Profiles>
|
<Setting Name="EonaCat" Type="System.String" Scope="User">
|
||||||
<Settings />
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
|
@ -6,6 +6,14 @@
|
||||||
<server name="External Blocky" ip="192.168.1.10"></server>
|
<server name="External Blocky" ip="192.168.1.10"></server>
|
||||||
<!-- My Remote Blocky Dns -->
|
<!-- My Remote Blocky Dns -->
|
||||||
<server name="Remote Blocky" ip="192.168.1.254"></server>
|
<server name="Remote Blocky" ip="192.168.1.254"></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>
|
||||||
|
|
||||||
|
<!--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>
|
||||||
|
|
||||||
<!--Google Dns Servers-->
|
<!--Google Dns Servers-->
|
||||||
<server name="Google (8.8.8.8)" ip="8.8.8.8"></server>
|
<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>
|
<server name="Google (8.8.4.4)" ip="8.8.8.8"></server>
|
||||||
|
@ -13,13 +21,6 @@
|
||||||
<server name="CloudFlare Standard (1.1.1.1)" ip="1.1.1.1"></server>
|
<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>
|
<server name="CloudFlare Standard (1.0.0.1)" ip="1.0.0.1"></server>
|
||||||
<!--Quad9 DNS-->
|
<!--Quad9 DNS-->
|
||||||
<server name="Quad9 DNS 1 (9.9.9.9)" ip="9.9.9.9"></server>
|
<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>
|
<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>
|
</Servers>
|
||||||
|
|
Loading…
Reference in New Issue