Skip to content

Commit 7ee4902

Browse files
committed
Settings for DNSLookup added
1 parent f4b3310 commit 7ee4902

20 files changed

Lines changed: 578 additions & 308 deletions

Source/NETworkManager/Helpers/RegexHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ public static class RegexHelper
55
// Match IPv4-Address like 192.168.178.1
66
public const string IPv4AddressRegex = @"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
77

8+
// Match IPv6-Address
9+
public const string IPv6AddressRegex = @"(?:^|(?<=\s))(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(?=\s|$)";
10+
811
// Match IPv4-Address Range like 192.168.178.1-192.168.178.127
912
public const string IPv4AddressRangeRegex = @"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)-(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
1013

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ private void OnPropertyChanged(string propertyName)
4646

4747
// Indicates a restart message, when settings changed
4848
private string _cultureCode;
49-
private bool? _developerMode;
5049

5150
private bool _applicationView_Expand;
5251
public bool ApplicationView_Expand
@@ -264,13 +263,10 @@ public MainWindow()
264263

265264
private void LoadApplicationList()
266265
{
267-
_applicationViewCollectionSource = new CollectionViewSource();
268-
269-
// Developer features
270-
if (SettingsManager.Current.DeveloperMode)
271-
_applicationViewCollectionSource.Source = ApplicationViewManager.List;
272-
else
273-
_applicationViewCollectionSource.Source = ApplicationViewManager.List.Where(x => x.IsDev == false);
266+
_applicationViewCollectionSource = new CollectionViewSource()
267+
{
268+
Source = ApplicationViewManager.List
269+
};
274270

275271
_applicationViewCollectionSource.Filter += ApplicationView_Search;
276272
_applicationViewCollectionSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
@@ -612,9 +608,6 @@ private async void OpenSettingsAction()
612608
if (string.IsNullOrEmpty(_cultureCode))
613609
_cultureCode = SettingsManager.Current.Localization_CultureCode;
614610

615-
if (_developerMode == null)
616-
_developerMode = SettingsManager.Current.DeveloperMode;
617-
618611
SettingsWindow settingsWindow = _isInTray ? new SettingsWindow() : new SettingsWindow(SelectedApplicationViewInfo.Name);
619612

620613
if (_isInTray)
@@ -648,7 +641,7 @@ private async void OpenSettingsAction()
648641
}
649642

650643
// Ask the user to restart (if he has changed the language or enables the developer mode)
651-
if ((_cultureCode != SettingsManager.Current.Localization_CultureCode) || (_developerMode != SettingsManager.Current.DeveloperMode) || (AllowsTransparency != SettingsManager.Current.Appearance_EnableTransparency))
644+
if ((_cultureCode != SettingsManager.Current.Localization_CultureCode) || (AllowsTransparency != SettingsManager.Current.Appearance_EnableTransparency))
652645
{
653646
ShowWindowAction();
654647

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using Heijden.DNS;
2+
using NETworkManager.Helpers;
3+
using System;
4+
using System.Linq;
5+
using System.Net;
6+
using System.Net.NetworkInformation;
7+
using System.Net.Sockets;
8+
using System.Threading;
9+
using System.Threading.Tasks;
10+
using System.Windows;
11+
12+
namespace NETworkManager.Models.Network
13+
{
14+
public class DNSLookup
15+
{
16+
#region Variables
17+
Resolver dnsResolver = new Resolver();
18+
#endregion
19+
20+
#region Events
21+
/* public event EventHandler<IPScannerHostFoundArgs> RecordReceived;
22+
23+
protected virtual void OnRecordReceived(IPScannerHostFoundArgs e)
24+
{
25+
RecordReceived?.Invoke(this, e);
26+
} */
27+
28+
public event EventHandler LookupComplete;
29+
30+
protected virtual void OnLookupComplete()
31+
{
32+
LookupComplete?.Invoke(this, EventArgs.Empty);
33+
}
34+
#endregion
35+
36+
#region Methods
37+
public void LookupAsync(string hostnameOrIPAddress)
38+
{
39+
Task.Run(() =>
40+
{
41+
dnsResolver.DnsServer = "2001:4860:4860::8888";
42+
dnsResolver.TransportType = Heijden.DNS.TransportType.Udp;
43+
dnsResolver.Recursion = true;
44+
dnsResolver.TransportType = Heijden.DNS.TransportType.Tcp;
45+
Response dnsResponse = dnsResolver.Query(hostnameOrIPAddress, QType.ANY, QClass.IN);
46+
47+
if (!string.IsNullOrEmpty(dnsResponse.Error))
48+
MessageBox.Show(dnsResponse.Error);
49+
50+
foreach (RecordA r in dnsResponse.RecordsA)
51+
{
52+
MessageBox.Show(r.Address.ToString());
53+
}
54+
55+
foreach (RecordAAAA r in dnsResponse.RecordsAAAA)
56+
{
57+
MessageBox.Show(r.Address.ToString());
58+
}
59+
60+
foreach (RecordCNAME r in dnsResponse.RecordsCNAME)
61+
{
62+
MessageBox.Show(r.CNAME);
63+
}
64+
65+
foreach (RecordPTR r in dnsResponse.RecordsPTR)
66+
{
67+
MessageBox.Show(r.PTRDNAME);
68+
}
69+
70+
foreach (RecordMX r in dnsResponse.RecordsMX)
71+
{
72+
MessageBox.Show(r.EXCHANGE);
73+
}
74+
75+
foreach (RecordNS r in dnsResponse.RecordsNS)
76+
{
77+
MessageBox.Show(r.NSDNAME);
78+
79+
}
80+
81+
OnLookupComplete();
82+
});
83+
}
84+
#endregion
85+
}
86+
}

0 commit comments

Comments
 (0)