public void Save()
        {
            // Proxy server settings
            HTTPHelper.ProxyStyle new_proxy_style =
                DirectConnectionRadioButton.Checked ? HTTPHelper.ProxyStyle.DirectConnection :
                UseIERadioButton.Checked ? HTTPHelper.ProxyStyle.SystemProxy :
                HTTPHelper.ProxyStyle.SpecifiedProxy;

            if (Properties.Settings.Default.ProxySetting != (int)new_proxy_style)
            {
                Properties.Settings.Default.ProxySetting = (int)new_proxy_style;
            }

            if (ProxyAddressTextBox.Text != Properties.Settings.Default.ProxyAddress && !string.IsNullOrEmpty(ProxyAddressTextBox.Text))
            {
                Properties.Settings.Default.ProxyAddress = ProxyAddressTextBox.Text;
            }

            Properties.Settings.Default.ProxyUsername = EncryptionUtils.Protect(ProxyUsernameTextBox.Text);
            Properties.Settings.Default.ProxyPassword = EncryptionUtils.Protect(ProxyPasswordTextBox.Text);
            Properties.Settings.Default.ProvideProxyAuthentication = AuthenticationCheckBox.Checked;

            HTTP.ProxyAuthenticationMethod new_auth_method = BasicRadioButton.Checked ?
                                                             HTTP.ProxyAuthenticationMethod.Basic : HTTP.ProxyAuthenticationMethod.Digest;
            if (Properties.Settings.Default.ProxyAuthenticationMethod != (int)new_auth_method)
            {
                Properties.Settings.Default.ProxyAuthenticationMethod = (int)new_auth_method;
            }

            try
            {
                int port = int.Parse(ProxyPortTextBox.Text);
                if (port != Properties.Settings.Default.ProxyPort)
                {
                    Properties.Settings.Default.ProxyPort = port;
                }
            }
            catch
            {
                Properties.Settings.Default.ProxyPort = 80;
            }

            if (BypassForServersCheckbox.Checked != Properties.Settings.Default.BypassProxyForServers)
            {
                Properties.Settings.Default.BypassProxyForServers = BypassForServersCheckbox.Checked;
            }

            // timeout settings
            int timeout = (int)ConnectionTimeoutNud.Value;

            if (timeout * 1000 != Properties.Settings.Default.ConnectionTimeout)
            {
                Properties.Settings.Default.ConnectionTimeout = timeout * 1000;
            }

            Program.ReconfigureConnectionSettings();

            Core.HealthCheck.SendProxySettingsToHealthCheck();
        }
Пример #2
0
 public TransferProxySettingsAction(HTTPHelper.ProxyStyle style, string address, int port, int timeout,
                                    bool suppressHistory, bool bypassForServer, bool provideCredentials, string username, string password, HTTP.ProxyAuthenticationMethod proxyAuthMethod)
     : base(null, Messages.ACTION_TRANSFER_HEALTHCHECK_SETTINGS, Messages.ACTION_TRANSFER_HEALTHCHECK_SETTINGS, suppressHistory)
 {
     proxyStyle                = style;
     proxyAddress              = address;
     proxyPort                 = port;
     timeOut                   = timeout;
     bypassProxyForServers     = bypassForServer;
     provideProxyCredentials   = provideCredentials;
     proxyUsername             = username;
     proxyPassword             = password;
     proxyAuthenticationMethod = proxyAuthMethod;
 }