Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

36 changes: 18 additions & 18 deletions Source/NETworkManager.Models/Network/DNSServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,34 @@ public static class DNSServer
/// <returns>List of common dns servers.</returns>
public static List<DNSServerConnectionInfoProfile> GetDefaultList()
{
return new List<DNSServerConnectionInfoProfile>
{
return
[
new(), // Windows DNS server
new("Cloudflare", new List<ServerConnectionInfo>
{
new("Cloudflare",
[
new("1.1.1.1", 53, TransportProtocol.Udp),
new("1.0.0.1", 53, TransportProtocol.Udp)
}),
new("DNS.Watch", new List<ServerConnectionInfo>
{
]),
new("DNS.Watch",
[
new("84.200.69.80", 53, TransportProtocol.Udp),
new("84.200.70.40", 53, TransportProtocol.Udp)
}),
new("Google Public DNS", new List<ServerConnectionInfo>
{
]),
new("Google Public DNS",
[
new("8.8.8.8", 53, TransportProtocol.Udp),
new("8.8.4.4", 53, TransportProtocol.Udp)
}),
new("Level3", new List<ServerConnectionInfo>
{
]),
new("Level3",
[
new("209.244.0.3", 53, TransportProtocol.Udp),
new("209.244.0.4", 53, TransportProtocol.Udp)
}),
new("Verisign", new List<ServerConnectionInfo>
{
]),
new("Verisign",
[
new("64.6.64.6", 53, TransportProtocol.Udp),
new("64.6.65.6", 53, TransportProtocol.Udp)
})
};
])
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class DNSServerConnectionInfoProfile : ServerConnectionInfoProfile
/// </summary>
public DNSServerConnectionInfoProfile()
{
Name = "[Windows DNS]";
UseWindowsDNSServer = true;
}

Expand All @@ -28,5 +29,5 @@ public DNSServerConnectionInfoProfile(string name, List<ServerConnectionInfo> se
/// <summary>
/// Use the DNS server from Windows.
/// </summary>
public bool UseWindowsDNSServer { get; set; }
public bool UseWindowsDNSServer { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ public ServerConnectionInfoProfile(string name, List<ServerConnectionInfo> serve
/// <summary>
/// List of servers as <see cref="ServerConnectionInfo" />.
/// </summary>
public List<ServerConnectionInfo> Servers { get; set; } = new();
public List<ServerConnectionInfo> Servers { get; set; } = [];

public override string ToString()
{
return Name;
}
}
2 changes: 1 addition & 1 deletion Source/NETworkManager.Settings/SettingsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ public ObservableCollection<DNSServerConnectionInfoProfile> DNSLookup_DNSServers
}
}

private DNSServerConnectionInfoProfile _dnsLookup_SelectedDNSServer = new();
private DNSServerConnectionInfoProfile _dnsLookup_SelectedDNSServer = null;

public DNSServerConnectionInfoProfile DNSLookup_SelectedDNSServer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DNSLookupSettingsViewModel : ViewModelBase

public ICollectionView DNSServers { get; }

private DNSServerConnectionInfoProfile _selectedDNSServer = new();
private DNSServerConnectionInfoProfile _selectedDNSServer = null;

public DNSServerConnectionInfoProfile SelectedDNSServer
{
Expand Down
64 changes: 57 additions & 7 deletions Source/NETworkManager/ViewModels/DNSLookupViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
Expand Down Expand Up @@ -57,24 +58,69 @@ public string Host
public ICollectionView DNSServers { get; }

private DNSServerConnectionInfoProfile _dnsServer = new();

public DNSServerConnectionInfoProfile DNSServer
{
get => _dnsServer;
set
private set
{
if (value == _dnsServer)
if (_dnsServer == value)
return;

_dnsServer = value ?? new DNSServerConnectionInfoProfile();

if (!_isLoading)
SettingsManager.Current.DNSLookup_SelectedDNSServer = value;
SettingsManager.Current.DNSLookup_SelectedDNSServer = _dnsServer;

OnPropertyChanged();
}
}

private DNSServerConnectionInfoProfile _selectedListProfile;
public DNSServerConnectionInfoProfile SelectedListProfile
{
get => _selectedListProfile;
set
{
if (_selectedListProfile == value)
return;

if (value != null)
{
DNSServer = value;
DNSServerQuickInput = value.ToString(); // uses your override
}

_dnsServer = value;
_selectedListProfile = value;
OnPropertyChanged();
}
}

private List<QueryType> _queryTypes = new();
// Text box content
private string _dnsServerQuickInput = string.Empty;
public string DNSServerQuickInput
{
get => _dnsServerQuickInput;
set
{
if (_dnsServerQuickInput == value)
return;

_dnsServerQuickInput = value?.Trim() ?? string.Empty;
OnPropertyChanged();

// As soon as user types → deselect any list item
SelectedListProfile = null;

// Create custom profile from raw IP
if (IPAddress.TryParse(_dnsServerQuickInput, out IPAddress x))
{
// Temporarily switch to this custom profile
DNSServer = new DNSServerConnectionInfoProfile("CUSTOM", [new ServerConnectionInfo(x.ToString(), 53)]);
}
}
}

private List<QueryType> _queryTypes = [];

public List<QueryType> QueryTypes
{
Expand Down Expand Up @@ -220,10 +266,14 @@ public DNSLookupViewModel(IDialogCoordinator instance, Guid tabId, string host)
ListSortDirection.Descending));
DNSServers.SortDescriptions.Add(new SortDescription(nameof(DNSServerConnectionInfoProfile.Name),
ListSortDirection.Ascending));
DNSServer = DNSServers.SourceCollection.Cast<DNSServerConnectionInfoProfile>()
var initialDNSServer = DNSServers.SourceCollection.Cast<DNSServerConnectionInfoProfile>()
.FirstOrDefault(x => x.Name == SettingsManager.Current.DNSLookup_SelectedDNSServer.Name) ??
DNSServers.SourceCollection.Cast<DNSServerConnectionInfoProfile>().First();

DNSServer = initialDNSServer;
SelectedListProfile = initialDNSServer;
DNSServerQuickInput = initialDNSServer.ToString();

ResultsView = CollectionViewSource.GetDefaultView(Results);
ResultsView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(DNSLookupRecordInfo.NameServerAsString)));
ResultsView.SortDescriptions.Add(new SortDescription(nameof(DNSLookupRecordInfo.NameServerIPAddress),
Expand Down
17 changes: 7 additions & 10 deletions Source/NETworkManager/Views/DNSLookupView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<UserControl.Resources>
<converters:BooleanReverseConverter x:Key="BooleanReverseConverter" />
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
<converters:DNSServerConnectionInfoProfileToString x:Key="DNSServerConnectionInfoProfileToString" />
</UserControl.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -71,15 +70,13 @@
</ComboBox>
<TextBlock Grid.Column="4" Grid.Row="0" Text="{x:Static localization:Strings.DNSServer}"
Style="{DynamicResource DefaultTextBlock}" VerticalAlignment="Center" />
<ComboBox x:Name="ComboBoxDNSServers" Grid.Column="6" Grid.Row="0" ItemsSource="{Binding DNSServers}"
SelectedItem="{Binding DNSServer}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Path=., Converter={StaticResource DNSServerConnectionInfoProfileToString}}"
d:DataContext="{d:DesignInstance network:DNSServerConnectionInfoProfile}" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox x:Name="ComboBoxDNSServers"
Grid.Column="6" Grid.Row="0"
ItemsSource="{Binding DNSServers}"
SelectedItem="{Binding SelectedListProfile}"
Text="{Binding DNSServerQuickInput, UpdateSourceTrigger=PropertyChanged}"
IsEditable="True"
IsTextSearchEnabled="False">
</ComboBox>
<TextBlock Grid.Column="8" Grid.Row="0" Text="{x:Static localization:Strings.Type}"
Style="{DynamicResource DefaultTextBlock}" VerticalAlignment="Center" />
Expand Down