Skip to content

Commit

Permalink
Feature: Ping Monitor improvements (#2573)
Browse files Browse the repository at this point in the history
* Feature: Ping Monitor improvements

* Feature: DNS Lookup / Port Scanner improve group string

* Feature: Host range aded to Ping Monitor & new design

* Feature: Allow range in profile

* Feature: Ping Monitor

* Feature: Setting to expand host view

* Feature: Expand ping monitor host

* Docs: Ping Monitor

* Chore: Refactoring

* Feature: Ping Monitor

* Docs: Update img
  • Loading branch information
BornToBeRoot authored Dec 9, 2023
1 parent 24fa4f0 commit 01ae7e6
Show file tree
Hide file tree
Showing 49 changed files with 1,161 additions and 801 deletions.
2 changes: 1 addition & 1 deletion InnoSetup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "NETworkManager"
#define MyAppVersion "2023.11.28.0"
#define MyAppVersion "2023.12.9.0"
#define MyAppPublisher "BornToBeRoot"
#define MyAppURL "https://github.com/BornToBeRoot/NETworkManager/"
#define MyAppExeName "NETworkManager.exe"
Expand Down
4 changes: 2 additions & 2 deletions Source/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("2023.11.28.0")]
[assembly: AssemblyFileVersion("2023.11.28.0")]
[assembly: AssemblyVersion("2023.12.9.0")]
[assembly: AssemblyFileVersion("2023.12.9.0")]
21 changes: 0 additions & 21 deletions Source/NETworkManager.Converters/PercentConverter.cs

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<value>SERVER-01 or 10.0.0.10</value>
</data>
<data name="ExampleHostRange" xml:space="preserve">
<value>192.168.1.0/24; 192.168.178.1 - 192.168.178.128; 192.168.[178-179].[1,100,150-200]; borntoberoot.net/24</value>
<value>192.168.178.0/24; 10.0.0.0 - 10.0.0.9; 10.0.[0-9,20].[1-2]; server-01.borntoberoot.net/24</value>
</data>
<data name="ExampleIPv4Address" xml:space="preserve">
<value>10.0.0.10</value>
Expand Down
29 changes: 28 additions & 1 deletion Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Source/NETworkManager.Localization/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ First make a backup copy of your profile files before enabling encryption!</valu
<value>Hostname or IP address</value>
</data>
<data name="Hosts" xml:space="preserve">
<value>Host(s)</value>
<value>Hosts</value>
</data>
<data name="ID" xml:space="preserve">
<value>ID</value>
Expand Down Expand Up @@ -3748,4 +3748,13 @@ Try again in a few seconds.</value>
<data name="SNMPErrorCode_InconsistentName" xml:space="preserve">
<value>The object's state is inconsistent, preventing the set operation!</value>
</data>
<data name="CloseAll" xml:space="preserve">
<value>Close all</value>
</data>
<data name="ExpandHostView" xml:space="preserve">
<value>Expand host view</value>
</data>
<data name="CannotSetHostWhileRunningMessage" xml:space="preserve">
<value>Host cannot be set while other hosts are being added. Please wait until the process is complete and try again.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ private static void CreateCsv(IEnumerable<DNSLookupRecordInfo> collection, strin
var stringBuilder = new StringBuilder();

stringBuilder.AppendLine(
$"{nameof(DNSLookupRecordInfo.DomainName)},{nameof(DNSLookupRecordInfo.TTL)},{nameof(DNSLookupRecordInfo.RecordClass)},{nameof(DNSLookupRecordInfo.RecordType)},{nameof(DNSLookupRecordInfo.Result)},{nameof(DNSLookupRecordInfo.Server)},{nameof(DNSLookupRecordInfo.IPEndPoint)}");
$"{nameof(DNSLookupRecordInfo.DomainName)},{nameof(DNSLookupRecordInfo.TTL)},{nameof(DNSLookupRecordInfo.RecordClass)},{nameof(DNSLookupRecordInfo.RecordType)},{nameof(DNSLookupRecordInfo.Result)},{nameof(DNSLookupRecordInfo.NameServerIPAddress)},{nameof(DNSLookupRecordInfo.NameServerHostName)},{nameof(DNSLookupRecordInfo.NameServerPort)}");

foreach (var info in collection)
stringBuilder.AppendLine(
$"{info.DomainName},{info.TTL},{info.RecordClass},{info.RecordType},{info.Result},{info.Server},{info.IPEndPoint}");
$"{info.DomainName},{info.TTL},{info.RecordClass},{info.RecordType},{info.Result},{info.NameServerIPAddress},{info.NameServerHostName},{info.NameServerPort}");

System.IO.File.WriteAllText(filePath, stringBuilder.ToString());
}
Expand All @@ -73,8 +73,9 @@ from info in collection
new XElement(nameof(DNSLookupRecordInfo.RecordClass), info.RecordClass),
new XElement(nameof(DNSLookupRecordInfo.RecordType), info.RecordType),
new XElement(nameof(DNSLookupRecordInfo.Result), info.Result),
new XElement(nameof(DNSLookupRecordInfo.Server), info.Server),
new XElement(nameof(DNSLookupRecordInfo.IPEndPoint), info.IPEndPoint)))));
new XElement(nameof(DNSLookupRecordInfo.NameServerIPAddress), info.NameServerIPAddress),
new XElement(nameof(DNSLookupRecordInfo.NameServerHostName), info.NameServerHostName),
new XElement(nameof(DNSLookupRecordInfo.NameServerPort), info.NameServerPort)))));

document.Save(filePath);
}
Expand All @@ -97,8 +98,9 @@ private static void CreateJson(IReadOnlyList<DNSLookupRecordInfo> collection, st
collection[i].RecordClass,
collection[i].RecordType,
collection[i].Result,
collection[i].Server,
collection[i].IPEndPoint
collection[i].NameServerIPAddress,
collection[i].NameServerHostName,
collection[i].NameServerPort
};
}

Expand Down
33 changes: 20 additions & 13 deletions Source/NETworkManager.Models/Network/DNSLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using DnsClient.Protocol;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using NETworkManager.Utilities;

namespace NETworkManager.Models.Network;

Expand Down Expand Up @@ -116,8 +116,15 @@ public void ResolveAsync(IEnumerable<string> hosts)
var queries = _addSuffix && _settings.QueryType != QueryType.PTR ? GetHostWithSuffix(hosts) : hosts;
// Foreach dns server
Parallel.ForEach(_servers, dnsServer =>
Parallel.ForEach(_servers, async dnsServer =>
{
// Get the dns server hostname for some additional information
var dnsServerHostName = string.Empty;
var dnsResult = await DNSClient.GetInstance().ResolvePtrAsync(dnsServer.Address);
if (!dnsResult.HasError)
dnsServerHostName = dnsResult.Value;
// Init each dns server once
LookupClientOptions lookupClientOptions = new(dnsServer)
{
Expand All @@ -129,7 +136,7 @@ public void ResolveAsync(IEnumerable<string> hosts)
};
LookupClient lookupClient = new(lookupClientOptions);
// Foreach host
Parallel.ForEach(queries, query =>
{
Expand All @@ -153,7 +160,7 @@ public void ResolveAsync(IEnumerable<string> hosts)
}
// Process the results...
ProcessDnsAnswers(dnsResponse.Answers, dnsResponse.NameServer);
ProcessDnsAnswers(dnsResponse.Answers, dnsResponse.NameServer, dnsServerHostName);
}
catch (Exception ex)
{
Expand All @@ -171,7 +178,7 @@ public void ResolveAsync(IEnumerable<string> hosts)
/// </summary>
/// <param name="answers">List of DNS resource records.</param>
/// <param name="nameServer">DNS name server that answered the query.</param>
private void ProcessDnsAnswers(IEnumerable<DnsResourceRecord> answers, NameServer nameServer)
private void ProcessDnsAnswers(IEnumerable<DnsResourceRecord> answers, NameServer nameServer, string nameServerHostname = null)
{
if(answers is not DnsResourceRecord[] dnsResourceRecords)
return;
Expand All @@ -180,49 +187,49 @@ private void ProcessDnsAnswers(IEnumerable<DnsResourceRecord> answers, NameServe
foreach (var record in dnsResourceRecords.ARecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}" , $"{record.Address}", $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}" , $"{record.Address}", $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// AAAA
foreach (var record in dnsResourceRecords.AaaaRecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", $"{record.Address}", $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", $"{record.Address}", $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// CNAME
foreach (var record in dnsResourceRecords.CnameRecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.CanonicalName, $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.CanonicalName, $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// MX
foreach (var record in dnsResourceRecords.MxRecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.Exchange, $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.Exchange, $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// NS
foreach (var record in dnsResourceRecords.NsRecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.NSDName, $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.NSDName, $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// PTR
foreach (var record in dnsResourceRecords.PtrRecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.PtrDomainName, $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.PtrDomainName, $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// SOA
foreach (var record in dnsResourceRecords.SoaRecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.MName + ", " + record.RName, $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", record.MName + ", " + record.RName, $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// TXT
foreach (var record in dnsResourceRecords.TxtRecords())
OnRecordReceived(new DNSLookupRecordReceivedArgs(
new DNSLookupRecordInfo(
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", string.Join(", ", record.Text), $"{nameServer.Address}", $"{nameServer.Address}:{nameServer.Port}")));
record.DomainName, record.TimeToLive, $"{record.RecordClass}",$"{record.RecordType}", string.Join(", ", record.Text), $"{nameServer.Address}", nameServerHostname, nameServer.Port)));

// ToDo: implement more
}
Expand Down
39 changes: 27 additions & 12 deletions Source/NETworkManager.Models/Network/DNSLookupRecordInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public class DNSLookupRecordInfo
/// Domain name of the record.
/// </summary>
public string DomainName { get; set; }

/// <summary>
/// Time to live (TTL) of the record.
/// </summary>
public int TTL { get; set; }

/// <summary>
/// Class of the record.
/// </summary>
Expand All @@ -31,14 +31,26 @@ public class DNSLookupRecordInfo
public string Result { get; set; }

/// <summary>
/// Name server that provided the result.
/// IP address of the name server that provided the result.
/// </summary>
public string NameServerIPAddress { get; set; }

/// <summary>
/// Port of the name server that provided the result.
/// </summary>
public int NameServerPort { get; set; }

/// <summary>
/// Hostname of the name server that provided the result.
/// </summary>
public string Server { get; set; }
public string NameServerHostName { get; set; }

/// <summary>
/// IP endpoint (IP address:port) of the name server that provided the result.
/// Hostname (if available) or/and IP address with port of the name server that provided the result.
/// </summary>
public string IPEndPoint { get; set; }
public string NameServerAsString => string.IsNullOrEmpty(NameServerHostName)
? $"{NameServerIPAddress}:{NameServerPort}"
: $"{NameServerHostName.TrimEnd('.')} # {NameServerIPAddress}:{NameServerPort}";

/// <summary>
/// Creates a new instance of <see cref="DNSLookupRecordInfo"/> with the specified parameters.
Expand All @@ -48,16 +60,19 @@ public class DNSLookupRecordInfo
/// <param name="recordClass">Class of the record.</param>
/// <param name="recordType">Type of the record.</param>
/// <param name="result">Result of the record. (IP address, hostname, text, etc.)</param>
/// <param name="server">Name server that provided the result.</param>
/// <param name="ipEndPoint">IP endpoint (IP address:port) of the name server that provided the result.</param>
public DNSLookupRecordInfo(string domainName, int ttl, string recordClass, string recordType, string result, string server, string ipEndPoint)
/// <param name="nameServerIPAddress">IP address of the name server that provided the result.</param>
/// <param name="nameServerHostName">Hostname of the name server that provided the result.</param>
/// <param name="nameServerPort">Port of the name server that provided the result.</param>
public DNSLookupRecordInfo(string domainName, int ttl, string recordClass, string recordType, string result,
string nameServerIPAddress, string nameServerHostName, int nameServerPort)
{
DomainName = domainName;
TTL = ttl;
RecordClass = recordClass;
RecordType = recordType;
Result = result;
Server = server;
IPEndPoint = ipEndPoint;
NameServerIPAddress = nameServerIPAddress;
NameServerPort = nameServerPort;
NameServerHostName = nameServerHostName;
}
}
}
21 changes: 0 additions & 21 deletions Source/NETworkManager.Models/Network/HostNotFoundException.cs

This file was deleted.

Loading

0 comments on commit 01ae7e6

Please sign in to comment.