fixed #2998: Added Quad9 DNS to preset list

This commit is contained in:
Jaex 2017-12-12 16:13:05 +03:00
parent fb0594db7f
commit 1a66200bdb
2 changed files with 25 additions and 10 deletions

View file

@ -85,11 +85,15 @@ public uint SetDNS(string primary, string secondary)
{
using (ManagementBaseObject parameters = adapter.GetMethodParameters("SetDNSServerSearchOrder"))
{
if (primary == null || secondary == null)
if (string.IsNullOrEmpty(primary))
{
// Obtain DNS server address automatically
parameters["DNSServerSearchOrder"] = null;
}
else if (string.IsNullOrEmpty(secondary))
{
parameters["DNSServerSearchOrder"] = new string[] { primary };
}
else
{
parameters["DNSServerSearchOrder"] = new string[] { primary, secondary };

View file

@ -38,12 +38,13 @@ public DNSChangerForm()
AddDNS(Resources.DNSChangerForm_DNSChangerForm_Manual);
AddDNS("Google Public DNS", "8.8.8.8", "8.8.4.4"); // https://developers.google.com/speed/public-dns/
AddDNS("OpenDNS", "208.67.222.222", "208.67.220.220"); // http://www.opendns.com/
AddDNS("Level 3 Communications", "4.2.2.1", "4.2.2.2"); // http://www.level3.com/
AddDNS("Norton ConnectSafe", "199.85.126.10", "199.85.127.10"); // https://dns.norton.com/
AddDNS("Comodo Secure DNS", "8.26.56.26", "8.20.247.20"); // http://www.comodo.com/secure-dns/
AddDNS("DNS Advantage", "156.154.70.1", "156.154.71.1"); // http://www.neustar.biz/services/dns-services/free-recursive-dns
AddDNS("Yandex DNS", "77.88.8.2", "77.88.8.88"); // http://dns.yandex.com/
AddDNS("OpenDNS", "208.67.222.222", "208.67.220.220"); // https://www.opendns.com
AddDNS("Level 3 Communications", "4.2.2.1", "4.2.2.2"); // http://www.level3.com
AddDNS("Norton ConnectSafe", "199.85.126.10", "199.85.127.10"); // https://dns.norton.com
AddDNS("Comodo Secure DNS", "8.26.56.26", "8.20.247.20"); // https://www.comodo.com/secure-dns/
AddDNS("DNS Advantage", "156.154.70.1", "156.154.71.1"); // https://www.security.neustar/dns-services/free-recursive-dns-service
AddDNS("Yandex DNS", "77.88.8.2", "77.88.8.88"); // https://dns.yandex.com
AddDNS("Quad9", "9.9.9.9"); // https://quad9.net
foreach (AdapterInfo adapter in AdapterInfo.GetEnabledAdapters())
{
@ -69,15 +70,25 @@ private void cbAdapters_SelectedIndexChanged(object sender, EventArgs e)
{
string[] dns = adapter.GetDNS();
if (dns != null && dns.Length == 2)
if (dns != null && dns.Length > 0)
{
cbAutomatic.Checked = false;
txtPreferredDNS.Text = dns[0];
txtAlternateDNS.Text = dns[1];
if (dns.Length > 1)
{
txtAlternateDNS.Text = dns[1];
}
else
{
txtAlternateDNS.Text = "";
}
}
else
{
cbAutomatic.Checked = true;
txtPreferredDNS.Text = "";
txtAlternateDNS.Text = "";
}
cbDNSType.SelectedIndex = 0;
@ -161,7 +172,7 @@ private void btnSave_Click(object sender, EventArgs e)
string primaryDNS = txtPreferredDNS.Text.Trim();
string secondaryDNS = txtAlternateDNS.Text.Trim();
if (Helpers.IsValidIPAddress(primaryDNS) && Helpers.IsValidIPAddress(secondaryDNS))
if (Helpers.IsValidIPAddress(primaryDNS) && (string.IsNullOrEmpty(secondaryDNS) || Helpers.IsValidIPAddress(secondaryDNS)))
{
result = adapter.SetDNS(primaryDNS, secondaryDNS);
}