Skip to content

Commit b150c68

Browse files
committed
Feature: Implement CAA resource records
1 parent 4387a4d commit b150c68

File tree

7 files changed

+74
-53
lines changed

7 files changed

+74
-53
lines changed

Source/NETworkManager.Models/Network/DNSLookup.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ private void ProcessDnsAnswers(IEnumerable<DnsResourceRecord> answers, NameServe
230230
record.DomainName, record.TimeToLive, $"{record.RecordClass}", $"{record.RecordType}",
231231
$"{record.Address}", $"{nameServer.Address}", nameServerHostname, nameServer.Port)));
232232

233+
// CAA
234+
foreach (var record in dnsResourceRecords.OfType<CaaRecord>())
235+
OnRecordReceived(new DNSLookupRecordReceivedArgs(
236+
new DNSLookupRecordInfo(record.DomainName, record.TimeToLive, $"{record.RecordClass}", $"{record.RecordType}",
237+
$"{record.Flags} {record.Tag} {record.Value}", $"{nameServer.Address}", nameServerHostname, nameServer.Port)));
238+
233239
// CNAME
234240
foreach (var record in dnsResourceRecords.OfType<CNameRecord>())
235241
OnRecordReceived(new DNSLookupRecordReceivedArgs(
@@ -286,6 +292,8 @@ private void ProcessDnsAnswers(IEnumerable<DnsResourceRecord> answers, NameServe
286292
record.DomainName, record.TimeToLive, $"{record.RecordClass}", $"{record.RecordType}",
287293
string.Join(", ", record.Text), $"{nameServer.Address}", nameServerHostname, nameServer.Port)));
288294

295+
296+
289297
// ToDo: implement more
290298
}
291299

Source/NETworkManager.Settings/GlobalStaticConfiguration.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public static class GlobalStaticConfiguration
2222

2323
// Application config
2424
public static int ApplicationUIRefreshInterval => 2500;
25-
25+
2626
// Type to search (average type speed --> 187 chars/min)
2727
public static TimeSpan SearchDispatcherTimerTimeSpan => new(0, 0, 0, 0, 750);
2828

2929
// Network config
3030
public static int NetworkChangeDetectionDelay => 5000;
31-
31+
3232
// Profile config
3333
public static bool Profile_ExpandProfileView => true;
3434
public static double Profile_WidthCollapsed => 40;
@@ -149,6 +149,7 @@ public static class GlobalStaticConfiguration
149149
QueryType.A,
150150
QueryType.AAAA,
151151
QueryType.ANY,
152+
QueryType.CAA,
152153
QueryType.CNAME,
153154
QueryType.DNSKEY,
154155
QueryType.MX,
@@ -237,7 +238,7 @@ public static class GlobalStaticConfiguration
237238
// Application: SNTP Lookup
238239
public static int SNTPLookup_Timeout => 4000;
239240
public static ExportFileType SNTPLookup_ExportFileType => ExportFileType.Csv;
240-
241+
241242
// Application: Hosts File Editor
242243
public static ExportFileType HostsFileEditor_ExportFileType => ExportFileType.Csv;
243244

Source/NETworkManager.Settings/SettingsInfo.cs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,7 @@ public QueryClass DNSLookup_QueryClass
17391739
}
17401740
}
17411741

1742+
/*
17421743
private bool _dnsLookup_ShowOnlyMostCommonQueryTypes = true;
17431744
17441745
public bool DNSLookup_ShowOnlyMostCommonQueryTypes
@@ -1753,6 +1754,7 @@ public bool DNSLookup_ShowOnlyMostCommonQueryTypes
17531754
OnPropertyChanged();
17541755
}
17551756
}
1757+
*/
17561758

17571759
private QueryType _dnsLookup_QueryType = GlobalStaticConfiguration.DNSLookup_QueryType;
17581760

@@ -3660,39 +3662,39 @@ public ExportFileType SNTPLookup_ExportFileType
36603662
}
36613663

36623664
#endregion
3663-
3665+
36643666
#region Hosts File Editor
3665-
3666-
private string _hostsFileEditor_ExportFilePath;
3667-
3668-
public string HostsFileEditor_ExportFilePath
3669-
{
3670-
get => _hostsFileEditor_ExportFilePath;
3671-
set
3672-
{
3673-
if (value == _hostsFileEditor_ExportFilePath)
3674-
return;
3675-
3676-
_hostsFileEditor_ExportFilePath = value;
3677-
OnPropertyChanged();
3678-
}
3679-
}
3680-
3681-
private ExportFileType _hostsFileEditor_ExportFileType = GlobalStaticConfiguration.HostsFileEditor_ExportFileType;
3682-
3683-
public ExportFileType HostsFileEditor_ExportFileType
3684-
{
3685-
get => _hostsFileEditor_ExportFileType;
3686-
set
3687-
{
3688-
if (value == _hostsFileEditor_ExportFileType)
3689-
return;
3690-
3691-
_hostsFileEditor_ExportFileType = value;
3692-
OnPropertyChanged();
3693-
}
3694-
}
3695-
3667+
3668+
private string _hostsFileEditor_ExportFilePath;
3669+
3670+
public string HostsFileEditor_ExportFilePath
3671+
{
3672+
get => _hostsFileEditor_ExportFilePath;
3673+
set
3674+
{
3675+
if (value == _hostsFileEditor_ExportFilePath)
3676+
return;
3677+
3678+
_hostsFileEditor_ExportFilePath = value;
3679+
OnPropertyChanged();
3680+
}
3681+
}
3682+
3683+
private ExportFileType _hostsFileEditor_ExportFileType = GlobalStaticConfiguration.HostsFileEditor_ExportFileType;
3684+
3685+
public ExportFileType HostsFileEditor_ExportFileType
3686+
{
3687+
get => _hostsFileEditor_ExportFileType;
3688+
set
3689+
{
3690+
if (value == _hostsFileEditor_ExportFileType)
3691+
return;
3692+
3693+
_hostsFileEditor_ExportFileType = value;
3694+
OnPropertyChanged();
3695+
}
3696+
}
3697+
36963698
#endregion
36973699

36983700
#region Discovery Protocol

Source/NETworkManager/ViewModels/DNSLookupSettingsViewModel.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using System.Windows.Data;
7-
using System.Windows.Input;
8-
using DnsClient;
1+
using DnsClient;
92
using MahApps.Metro.Controls.Dialogs;
103
using NETworkManager.Localization.Resources;
114
using NETworkManager.Models.Network;
125
using NETworkManager.Settings;
136
using NETworkManager.Utilities;
147
using NETworkManager.Views;
8+
using System;
9+
using System.Collections.Generic;
10+
using System.ComponentModel;
11+
using System.Linq;
12+
using System.Threading.Tasks;
13+
using System.Windows.Data;
14+
using System.Windows.Input;
1515

1616
namespace NETworkManager.ViewModels;
1717

@@ -41,8 +41,8 @@ public DNSServerConnectionInfoProfile SelectedDNSServer
4141
}
4242
}
4343

44-
private List<string> ServerInfoProfileNames => SettingsManager.Current.DNSLookup_DNSServers
45-
.Where(x => !x.UseWindowsDNSServer).Select(x => x.Name).ToList();
44+
private List<string> ServerInfoProfileNames => [.. SettingsManager.Current.DNSLookup_DNSServers
45+
.Where(x => !x.UseWindowsDNSServer).Select(x => x.Name)];
4646

4747
private bool _addDNSSuffix;
4848

@@ -154,6 +154,10 @@ public QueryClass QueryClass
154154
}
155155
}
156156

157+
/*
158+
* Disabled until more query types are implemented.
159+
*
160+
157161
private bool _showOnlyMostCommonQueryTypes;
158162
159163
public bool ShowOnlyMostCommonQueryTypes
@@ -171,6 +175,7 @@ public bool ShowOnlyMostCommonQueryTypes
171175
OnPropertyChanged();
172176
}
173177
}
178+
*/
174179

175180
private bool _useTCPOnly;
176181

@@ -261,7 +266,7 @@ private void LoadSettings()
261266
UseCache = SettingsManager.Current.DNSLookup_UseCache;
262267
QueryClasses = Enum.GetValues(typeof(QueryClass)).Cast<QueryClass>().OrderBy(x => x.ToString()).ToList();
263268
QueryClass = QueryClasses.First(x => x == SettingsManager.Current.DNSLookup_QueryClass);
264-
ShowOnlyMostCommonQueryTypes = SettingsManager.Current.DNSLookup_ShowOnlyMostCommonQueryTypes;
269+
//ShowOnlyMostCommonQueryTypes = SettingsManager.Current.DNSLookup_ShowOnlyMostCommonQueryTypes;
265270
UseTCPOnly = SettingsManager.Current.DNSLookup_UseTCPOnly;
266271
Retries = SettingsManager.Current.DNSLookup_Retries;
267272
Timeout = SettingsManager.Current.DNSLookup_Timeout;

Source/NETworkManager/ViewModels/DNSLookupViewModel.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,12 @@ private void LoadTypes()
256256
{
257257
var queryTypes = (QueryType[])Enum.GetValues(typeof(QueryType));
258258

259-
if (SettingsManager.Current.DNSLookup_ShowOnlyMostCommonQueryTypes)
260-
QueryTypes = [.. queryTypes.Where(GlobalStaticConfiguration.DNSLookup_CustomQueryTypes.Contains).OrderBy(x => x.ToString())];
261-
else
262-
QueryTypes = [.. queryTypes.OrderBy(x => x.ToString())];
259+
//if (SettingsManager.Current.DNSLookup_ShowOnlyMostCommonQueryTypes)
260+
// QueryTypes = [.. queryTypes.Where(GlobalStaticConfiguration.DNSLookup_CustomQueryTypes.Contains).OrderBy(x => x.ToString())];
261+
//else
262+
// QueryTypes = [.. queryTypes.OrderBy(x => x.ToString())];
263263

264+
QueryTypes = [.. queryTypes.Where(GlobalStaticConfiguration.DNSLookup_CustomQueryTypes.Contains).OrderBy(x => x.ToString())];
264265
QueryType = QueryTypes.FirstOrDefault(x => x == SettingsManager.Current.DNSLookup_QueryType);
265266

266267
// Fallback
@@ -457,9 +458,9 @@ private void SettingsManager_PropertyChanged(object sender, PropertyChangedEvent
457458
{
458459
switch (e.PropertyName)
459460
{
460-
case nameof(SettingsInfo.DNSLookup_ShowOnlyMostCommonQueryTypes):
461-
LoadTypes();
462-
break;
461+
//case nameof(SettingsInfo.DNSLookup_ShowOnlyMostCommonQueryTypes):
462+
// LoadTypes();
463+
// break;
463464
}
464465
}
465466

Source/NETworkManager/Views/DNSLookupSettingsView.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,10 @@
198198
Margin="0,0,0,10" />
199199
<ComboBox ItemsSource="{Binding QueryClasses}" SelectedItem="{Binding QueryClass}" Width="250"
200200
HorizontalAlignment="Left" Margin="0,0,0,10" />
201+
<!--
201202
<mah:ToggleSwitch Header="{x:Static localization:Strings.ShowOnlyMostCommonQueryTypes}"
202203
IsOn="{Binding ShowOnlyMostCommonQueryTypes}" Margin="0,0,0,10" />
204+
-->
203205
<mah:ToggleSwitch Header="{x:Static localization:Strings.UseOnlyTCP}" IsOn="{Binding UseTCPOnly}"
204206
Margin="0,0,0,10" />
205207
<TextBlock Text="{x:Static localization:Strings.Retries}" Style="{DynamicResource DefaultTextBlock}"

Website/docs/changelog/next-release.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Release date: **xx.xx.2025**
2727

2828
- `DNSKEY` records are now supported. [#3060](https://github.com/BornToBeRoot/NETworkManager/pull/3060)
2929
- `SRV` records are now supported. [#3060](https://github.com/BornToBeRoot/NETworkManager/pull/3060)
30+
- `CAA` records are now supported. [#3012](https://github.com/BornToBeRoot/NETworkManager/pull/3012)
31+
- Record types that are not implemented are now hidden in the user interface. [#3012](https://github.com/BornToBeRoot/NETworkManager/pull/3012)
3032

3133
## Improvements
3234

0 commit comments

Comments
 (0)