Пример #1
0
        private void FillInterfacesCombo()
        {
            SentrySdk.AddBreadcrumb($"{nameof(FillInterfacesCombo)}", nameof(MainForm));

            interfacesCombo.Items.Clear();

            var selectedItem = (object)null;

            foreach (var @interface in NetshHelper.GetInterfaces())
            {
                var item = new ComboBoxItem(@interface.ToString(), @interface);
                interfacesCombo.Items.Add(item);

                if (@interface.ToString() == Settings.Default.SelectedInterface)
                {
                    selectedItem = item;
                }
            }

            // some users do not have any interfaces available
            if (interfacesCombo.Items.Count == 0)
            {
                throw new Exception("Failed to fetch network interface list (empty response).");
            }

            if (selectedItem != null)
            {
                interfacesCombo.SelectedItem = selectedItem;
            }
            else
            {
                interfacesCombo.SelectedIndex = 0;
            }
        }
Пример #2
0
        private void InterfacesComboOnSelectedIndexChanged(object sender, EventArgs e)
        {
            SentrySdk.AddBreadcrumb($"{nameof(InterfacesComboOnSelectedIndexChanged)}", nameof(MainForm));

            var @interface = GetSelectedInterface();

            Settings.Default.SelectedInterface = @interface.ToString();

            var dnsEntries = NetshHelper.GetDnsEntries(@interface).ToArray();

            DisplayDnsEntries(dnsEntries);
            MatchInputToDnsServer();
        }
Пример #3
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);
        }
Пример #4
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);
        }