1414using System . ComponentModel ;
1515using System . Diagnostics ;
1616using System . Windows . Threading ;
17+ using Heijden . DNS ;
18+ using System . Threading . Tasks ;
1719
1820namespace 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