Skip to content

Commit f4de4d8

Browse files
committed
Settings added + tests...
1 parent 5a3b6b2 commit f4de4d8

2 files changed

Lines changed: 68 additions & 4 deletions

File tree

Source/NETworkManager/Models/Settings/SettingsInfo.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,23 @@ public int WakeOnLAN_DefaultPort
764764
}
765765
}
766766
#endregion
767+
768+
#region DNS Lookup
769+
private List<string> _dnsLookup_HostnameOrIPAddressHistory = new List<string>();
770+
public List<string> DNSLookup_HostnameOrIPAddressHistory
771+
{
772+
get { return _dnsLookup_HostnameOrIPAddressHistory; }
773+
set
774+
{
775+
if (value == _dnsLookup_HostnameOrIPAddressHistory)
776+
return;
777+
778+
SettingsChanged = true;
779+
780+
_dnsLookup_HostnameOrIPAddressHistory = value;
781+
}
782+
}
783+
#endregion
767784
#endregion
768785

769786
#region Constructor

Source/NETworkManager/ViewModels/Applications/DNSLookupViewModel.cs

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using System.ComponentModel;
1515
using System.Diagnostics;
1616
using System.Windows.Threading;
17+
using Heijden.DNS;
18+
using System.Threading.Tasks;
1719

1820
namespace NETworkManager.ViewModels.Applications
1921
{
@@ -25,6 +27,8 @@ public class DNSLookupViewModel : ViewModelBase
2527

2628
CancellationTokenSource cancellationTokenSource;
2729

30+
Resolver dnsResolver = new Resolver();
31+
2832
private bool _isLoading = true;
2933

3034
private string _hostnameOrIPAddress;
@@ -51,7 +55,7 @@ public List<string> HostnameOrIPAddressHistory
5155
return;
5256

5357
if (!_isLoading)
54-
SettingsManager.Current.Ping_HostnameOrIPAddressHistory = value;
58+
SettingsManager.Current.DNSLookup_HostnameOrIPAddressHistory = value;
5559

5660
_hostnameOrIPAddressHistory = value;
5761
OnPropertyChanged();
@@ -119,8 +123,8 @@ public DNSLookupViewModel(IDialogCoordinator instance)
119123
#region Load settings
120124
private void LoadSettings()
121125
{
122-
//if (SettingsManager.Current.Ping_HostnameOrIPAddressHistory != null)
123-
// HostnameOrIPAddressHistory = new List<string>(SettingsManager.Current.Ping_HostnameOrIPAddressHistory);
126+
if (SettingsManager.Current.DNSLookup_HostnameOrIPAddressHistory != null)
127+
HostnameOrIPAddressHistory = new List<string>(SettingsManager.Current.DNSLookup_HostnameOrIPAddressHistory);
124128
}
125129
#endregion
126130

@@ -140,12 +144,55 @@ private void LookupAction()
140144
#endregion
141145

142146
#region Methods
143-
private async void StartLookup()
147+
private void StartLookup()
144148
{
145149
IsLookupRunning = true;
146150

147151
// Reset the latest results
148152
LookupResult.Clear();
153+
154+
dnsResolver.DnsServer = "8.8.8.8";
155+
dnsResolver.TransportType = Heijden.DNS.TransportType.Udp;
156+
dnsResolver.Recursion = true;
157+
Response dnsResponse = dnsResolver.Query(HostnameOrIPAddress, QType.ANY, QClass.IN);
158+
159+
if (!string.IsNullOrEmpty(dnsResponse.Error))
160+
MessageBox.Show(dnsResponse.Error);
161+
162+
foreach (RecordA r in dnsResponse.RecordsA)
163+
{
164+
MessageBox.Show(r.Address.ToString());
165+
}
166+
167+
foreach (RecordAAAA r in dnsResponse.RecordsAAAA)
168+
{
169+
MessageBox.Show(r.Address.ToString());
170+
}
171+
172+
foreach (RecordCNAME r in dnsResponse.RecordsCNAME)
173+
{
174+
MessageBox.Show(r.CNAME);
175+
}
176+
177+
foreach (RecordPTR r in dnsResponse.RecordsPTR)
178+
{
179+
MessageBox.Show(r.PTRDNAME);
180+
}
181+
182+
foreach (RecordMX r in dnsResponse.RecordsMX)
183+
{
184+
MessageBox.Show(r.EXCHANGE);
185+
}
186+
187+
foreach(RecordNS r in dnsResponse.RecordsNS)
188+
{
189+
MessageBox.Show(r.NSDNAME);
190+
191+
}
192+
193+
HostnameOrIPAddressHistory = new List<string>(HistoryListHelper.Modify(HostnameOrIPAddressHistory, HostnameOrIPAddress, SettingsManager.Current.Application_HistoryListEntries));
194+
195+
IsLookupRunning = false;
149196
}
150197

151198
private void StopLookup()

0 commit comments

Comments
 (0)