}//end frmSettings() /// <summary> /// Load the saved values on open /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmSettings_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Program.settingsManager.getSetting("APIUrl").ToString())) { cloudflare_api_url_input.Text = "https://api.cloudflare.com/client/v4"; Program.settingsManager.setSetting("APIUrl", cloudflare_api_url_input.Text); } txtEmailAddress.Text = Program.settingsManager.getSetting("EmailAddress").ToString(); txtAPIKey.Text = Program.settingsManager.getSetting("APIKey").ToString(); txtFetchTime.Text = Program.settingsManager.getSetting("FetchTime").ToString(); cbEventLog.Checked = Program.settingsManager.getSetting("UseEventLog").ToBool(); IPV6UpdateURL.Text = Program.settingsManager.getSetting("IPV6UpdateURL").ToString(); IPV4UpdateURL.Text = Program.settingsManager.getSetting("IPV4UpdateURL").ToString(); StartMinimized.Checked = Program.settingsManager.getSetting("StartMinimized").ToBool(); cloudflare_api_url_input.Text = Program.settingsManager.getSetting("APIUrl").ToString(); UseInternalIP_input.Checked = Program.settingsManager.getSetting("UseInternalIP").ToBool(); HideSRV_input.Checked = Program.settingsManager.getSetting("HideSRV").ToBool(); show_local_ipv4.Text = NetworkInterfaceManager.GetDefaultIP(); show_local_ipv6.Text = NetworkInterfaceManager.GetDefaultIP(System.Net.Sockets.AddressFamily.InterNetworkV6); enable_network_interface_change.Checked = Program.settingsManager.getSetting("EnableNetworkInterfaceChange").ToBool(); network_interface_selector_reset_btn.Enabled = enable_network_interface_change.Checked; network_interface_selector.Enabled = enable_network_interface_change.Checked; load_network_interfaces(); }//end frmSettings_Load()
private void network_interface_selector_reset_btn_Click(object sender, EventArgs e) { var value = NetworkInterfaceManager.GetDeviceDefaultInterface().Name; network_interface_selector.SelectedItem = value; Console.WriteLine("New Interface selected: " + value); Program.settingsManager.setSetting("DefaultInterface", value); Program.settingsManager.saveSettings(); show_local_ipv4.Text = NetworkInterfaceManager.GetDefaultIP(); show_local_ipv6.Text = NetworkInterfaceManager.GetDefaultIP(System.Net.Sockets.AddressFamily.InterNetworkV6); }
private static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount) { if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork) { string currentIP = NetworkInterfaceManager.GetDefaultIP(); return new IPEndPoint(IPAddress.Parse(currentIP), 0); } // Just use the default endpoint. return null; }