Exemplo n.º 1
0
        private void resetBtn_Click(object sender, EventArgs e)
        {
            SentrySdk.AddBreadcrumb($"{nameof(resetBtn_Click)}", nameof(MainForm));

            try
            {
                var @interface = GetSelectedInterface();
                NetshHelper.ResetDnsEntries(@interface);
                NetshHelper.FlushDns();
            }
            catch (Exception ex)
            {
                SentrySdk.CaptureException(ex);
                Utilities.ShowExceptionMessage("Something went wrong during DNS configuration update.", ex);
            }

            InterfacesComboOnSelectedIndexChanged(interfacesCombo, null);

            Utilities.ButtonSuccessAnimation(sender);
        }
Exemplo n.º 2
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            SentrySdk.AddBreadcrumb($"{nameof(saveBtn_Click)}", nameof(MainForm));

            var dnsTextBoxes = new[]
            {
                v4primaryText,
                v4secondaryText,
                v6primaryText,
                v6secondaryText,
            };

            var dnsEntries = new List <DNSEntry>(dnsTextBoxes.Length);

            foreach (var dnsTextBox in dnsTextBoxes)
            {
                var dnsText = dnsTextBox.Text.Trim();

                if (GlobalVars.IpAddressRegex.IsMatch(dnsText))
                {
                    dnsEntries.Add(new DNSEntry(dnsText));
                }
            }

            try
            {
                var @interface = GetSelectedInterface();
                NetshHelper.UpdateDnsEntries(@interface, dnsEntries);
                NetshHelper.FlushDns();
            }
            catch (Exception ex)
            {
                SentrySdk.CaptureException(ex);
                Utilities.ShowExceptionMessage("Something went wrong during DNS configuration update.", ex);
            }

            Utilities.ButtonSuccessAnimation(sender);
        }