Merge pull request #1031 from Frezzle/proxy-auth

CP-17231: Implement proxy authentication setting in XenCenter
This commit is contained in:
Konstantina Chremmou 2016-06-27 11:38:09 +01:00 committed by GitHub
commit 877081d3e8
22 changed files with 923 additions and 218 deletions

View File

@ -39,14 +39,19 @@ namespace XenAdmin.Dialogs.OptionsPages
this.TimeOutLabel = new System.Windows.Forms.Label();
this.ProxyGroupBox = new XenAdmin.Controls.DecentGroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.BypassForServersCheckbox = new System.Windows.Forms.CheckBox();
this.ProxyPasswordTextBox = new System.Windows.Forms.TextBox();
this.ProxyUsernameLabel = new System.Windows.Forms.Label();
this.ProxyUsernameTextBox = new System.Windows.Forms.TextBox();
this.ProxyPasswordLabel = new System.Windows.Forms.Label();
this.AuthenticationCheckBox = new System.Windows.Forms.CheckBox();
this.ProxyAddressLabel = new System.Windows.Forms.Label();
this.UseProxyRadioButton = new System.Windows.Forms.RadioButton();
this.DirectConnectionRadioButton = new System.Windows.Forms.RadioButton();
this.UseIERadioButton = new System.Windows.Forms.RadioButton();
this.BypassLocalCheckBox = new System.Windows.Forms.CheckBox();
this.ProxyAddressTextBox = new System.Windows.Forms.TextBox();
this.ProxyPortLabel = new System.Windows.Forms.Label();
this.ProxyPortTextBox = new System.Windows.Forms.TextBox();
this.ProxyPortLabel = new System.Windows.Forms.Label();
this.ConnectionTableLayoutPanel.SuspendLayout();
this.TimeoutGroupBox.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
@ -129,25 +134,71 @@ namespace XenAdmin.Dialogs.OptionsPages
// tableLayoutPanel1
//
resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
this.tableLayoutPanel1.Controls.Add(this.ProxyAddressLabel, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.BypassForServersCheckbox, 1, 4);
this.tableLayoutPanel1.Controls.Add(this.ProxyPasswordTextBox, 6, 6);
this.tableLayoutPanel1.Controls.Add(this.ProxyUsernameLabel, 2, 6);
this.tableLayoutPanel1.Controls.Add(this.ProxyUsernameTextBox, 4, 6);
this.tableLayoutPanel1.Controls.Add(this.ProxyPasswordLabel, 5, 6);
this.tableLayoutPanel1.Controls.Add(this.AuthenticationCheckBox, 1, 5);
this.tableLayoutPanel1.Controls.Add(this.ProxyAddressLabel, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.UseProxyRadioButton, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.DirectConnectionRadioButton, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.UseIERadioButton, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.BypassLocalCheckBox, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.ProxyAddressTextBox, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.ProxyPortLabel, 2, 3);
this.tableLayoutPanel1.Controls.Add(this.ProxyPortTextBox, 3, 3);
this.tableLayoutPanel1.Controls.Add(this.ProxyAddressTextBox, 3, 3);
this.tableLayoutPanel1.Controls.Add(this.ProxyPortTextBox, 5, 3);
this.tableLayoutPanel1.Controls.Add(this.ProxyPortLabel, 4, 3);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// BypassForServersCheckbox
//
resources.ApplyResources(this.BypassForServersCheckbox, "BypassForServersCheckbox");
this.tableLayoutPanel1.SetColumnSpan(this.BypassForServersCheckbox, 6);
this.BypassForServersCheckbox.Name = "BypassForServersCheckbox";
this.BypassForServersCheckbox.UseVisualStyleBackColor = true;
this.BypassForServersCheckbox.CheckedChanged += new System.EventHandler(this.BypassForServersCheckbox_CheckedChanged);
//
// ProxyPasswordTextBox
//
resources.ApplyResources(this.ProxyPasswordTextBox, "ProxyPasswordTextBox");
this.ProxyPasswordTextBox.Name = "ProxyPasswordTextBox";
this.ProxyPasswordTextBox.UseSystemPasswordChar = true;
this.ProxyPasswordTextBox.TextChanged += new System.EventHandler(this.ProxyPasswordTextBox_TextChanged);
//
// ProxyUsernameLabel
//
resources.ApplyResources(this.ProxyUsernameLabel, "ProxyUsernameLabel");
this.tableLayoutPanel1.SetColumnSpan(this.ProxyUsernameLabel, 2);
this.ProxyUsernameLabel.Name = "ProxyUsernameLabel";
//
// ProxyUsernameTextBox
//
resources.ApplyResources(this.ProxyUsernameTextBox, "ProxyUsernameTextBox");
this.ProxyUsernameTextBox.Name = "ProxyUsernameTextBox";
this.ProxyUsernameTextBox.TextChanged += new System.EventHandler(this.ProxyUsernameTextBox_TextChanged);
//
// ProxyPasswordLabel
//
resources.ApplyResources(this.ProxyPasswordLabel, "ProxyPasswordLabel");
this.ProxyPasswordLabel.Name = "ProxyPasswordLabel";
//
// AuthenticationCheckBox
//
resources.ApplyResources(this.AuthenticationCheckBox, "AuthenticationCheckBox");
this.tableLayoutPanel1.SetColumnSpan(this.AuthenticationCheckBox, 6);
this.AuthenticationCheckBox.Name = "AuthenticationCheckBox";
this.AuthenticationCheckBox.UseVisualStyleBackColor = true;
this.AuthenticationCheckBox.CheckedChanged += new System.EventHandler(this.AuthenticationCheckBox_CheckedChanged);
//
// ProxyAddressLabel
//
resources.ApplyResources(this.ProxyAddressLabel, "ProxyAddressLabel");
this.tableLayoutPanel1.SetColumnSpan(this.ProxyAddressLabel, 2);
this.ProxyAddressLabel.Name = "ProxyAddressLabel";
//
// UseProxyRadioButton
//
resources.ApplyResources(this.UseProxyRadioButton, "UseProxyRadioButton");
this.tableLayoutPanel1.SetColumnSpan(this.UseProxyRadioButton, 4);
this.tableLayoutPanel1.SetColumnSpan(this.UseProxyRadioButton, 6);
this.UseProxyRadioButton.Name = "UseProxyRadioButton";
this.UseProxyRadioButton.TabStop = true;
this.UseProxyRadioButton.UseVisualStyleBackColor = true;
@ -156,7 +207,7 @@ namespace XenAdmin.Dialogs.OptionsPages
// DirectConnectionRadioButton
//
resources.ApplyResources(this.DirectConnectionRadioButton, "DirectConnectionRadioButton");
this.tableLayoutPanel1.SetColumnSpan(this.DirectConnectionRadioButton, 4);
this.tableLayoutPanel1.SetColumnSpan(this.DirectConnectionRadioButton, 6);
this.DirectConnectionRadioButton.Name = "DirectConnectionRadioButton";
this.DirectConnectionRadioButton.TabStop = true;
this.DirectConnectionRadioButton.UseVisualStyleBackColor = true;
@ -164,35 +215,29 @@ namespace XenAdmin.Dialogs.OptionsPages
// UseIERadioButton
//
resources.ApplyResources(this.UseIERadioButton, "UseIERadioButton");
this.tableLayoutPanel1.SetColumnSpan(this.UseIERadioButton, 4);
this.tableLayoutPanel1.SetColumnSpan(this.UseIERadioButton, 6);
this.UseIERadioButton.Name = "UseIERadioButton";
this.UseIERadioButton.TabStop = true;
this.UseIERadioButton.UseVisualStyleBackColor = true;
//
// BypassLocalCheckBox
//
resources.ApplyResources(this.BypassLocalCheckBox, "BypassLocalCheckBox");
this.tableLayoutPanel1.SetColumnSpan(this.BypassLocalCheckBox, 4);
this.BypassLocalCheckBox.Name = "BypassLocalCheckBox";
this.BypassLocalCheckBox.UseVisualStyleBackColor = true;
//
// ProxyAddressTextBox
//
this.tableLayoutPanel1.SetColumnSpan(this.ProxyAddressTextBox, 2);
resources.ApplyResources(this.ProxyAddressTextBox, "ProxyAddressTextBox");
this.ProxyAddressTextBox.Name = "ProxyAddressTextBox";
this.ProxyAddressTextBox.TextChanged += new System.EventHandler(this.ProxyAddressTextBox_TextChanged);
//
// ProxyPortLabel
//
resources.ApplyResources(this.ProxyPortLabel, "ProxyPortLabel");
this.ProxyPortLabel.Name = "ProxyPortLabel";
//
// ProxyPortTextBox
//
resources.ApplyResources(this.ProxyPortTextBox, "ProxyPortTextBox");
this.ProxyPortTextBox.Name = "ProxyPortTextBox";
this.ProxyPortTextBox.TextChanged += new System.EventHandler(this.ProxyPortTextBox_TextChanged);
//
// ProxyPortLabel
//
resources.ApplyResources(this.ProxyPortLabel, "ProxyPortLabel");
this.ProxyPortLabel.Name = "ProxyPortLabel";
//
// ConnectionOptionsPage
//
resources.ApplyResources(this, "$this");
@ -224,7 +269,6 @@ namespace XenAdmin.Dialogs.OptionsPages
private System.Windows.Forms.Label ConnectionTimeoutLabel;
private System.Windows.Forms.Label SecondsLabel;
private XenAdmin.Controls.DecentGroupBox ProxyGroupBox;
private System.Windows.Forms.CheckBox BypassLocalCheckBox;
private System.Windows.Forms.RadioButton DirectConnectionRadioButton;
private System.Windows.Forms.TextBox ProxyAddressTextBox;
private System.Windows.Forms.RadioButton UseProxyRadioButton;
@ -235,5 +279,11 @@ namespace XenAdmin.Dialogs.OptionsPages
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox AuthenticationCheckBox;
private System.Windows.Forms.CheckBox BypassForServersCheckbox;
private System.Windows.Forms.TextBox ProxyPasswordTextBox;
private System.Windows.Forms.Label ProxyUsernameLabel;
private System.Windows.Forms.TextBox ProxyUsernameTextBox;
private System.Windows.Forms.Label ProxyPasswordLabel;
}
}

View File

@ -40,6 +40,7 @@ using XenAdmin.Properties;
using XenAdmin.Actions;
using XenAPI;
using System.Text.RegularExpressions;
using XenAdmin.Core;
namespace XenAdmin.Dialogs.OptionsPages
@ -50,6 +51,9 @@ namespace XenAdmin.Dialogs.OptionsPages
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private OptionsDialog optionsDialog;
// used for preventing the event handlers (mainly the SelectUseThisProxyServer function) from being called when loading the settings into the text/check boxes
private bool built = false;
public ConnectionOptionsPage()
{
InitializeComponent();
@ -81,38 +85,81 @@ namespace XenAdmin.Dialogs.OptionsPages
break;
}
ProxyAddressTextBox.Text = Properties.Settings.Default.ProxyAddress;
ProxyPortTextBox.Text = Properties.Settings.Default.ProxyPort.ToString();
BypassLocalCheckBox.Checked = Properties.Settings.Default.BypassProxyForLocal;
ProxyAddressLabel.Enabled = UseProxyRadioButton.Checked;
ProxyAddressTextBox.Enabled = UseProxyRadioButton.Checked;
ProxyPortLabel.Enabled = UseProxyRadioButton.Checked;
ProxyPortTextBox.Enabled = UseProxyRadioButton.Checked;
BypassLocalCheckBox.Enabled = UseProxyRadioButton.Checked;
ProxyAddressTextBox.Text = Properties.Settings.Default.ProxyAddress;
ProxyPortTextBox.Text = Properties.Settings.Default.ProxyPort.ToString();
BypassForServersCheckbox.Checked = Properties.Settings.Default.BypassProxyForServers;
AuthenticationCheckBox.Checked = Properties.Settings.Default.ProvideProxyAuthentication;
ConnectionTimeoutNud.Value = Properties.Settings.Default.ConnectionTimeout / 1000;
// checks for empty default username/password which starts out unencrypted
string protectedUsername = Properties.Settings.Default.ProxyUsername;
ProxyUsernameTextBox.Text = string.IsNullOrEmpty(protectedUsername) ? "" : EncryptionUtils.Unprotect(Properties.Settings.Default.ProxyUsername);
string protectedPassword = Properties.Settings.Default.ProxyPassword;
ProxyPasswordTextBox.Text = string.IsNullOrEmpty(protectedPassword) ? "" : EncryptionUtils.Unprotect(Properties.Settings.Default.ProxyPassword);
ConnectionTimeoutNud.Value = Properties.Settings.Default.ConnectionTimeout / 1000;
built = true;
}
private void UseProxyRadioButton_CheckedChanged(object sender, EventArgs e)
{
ProxyAddressLabel.Enabled = UseProxyRadioButton.Checked;
ProxyAddressTextBox.Enabled = UseProxyRadioButton.Checked;
ProxyPortLabel.Enabled = UseProxyRadioButton.Checked;
ProxyPortTextBox.Enabled = UseProxyRadioButton.Checked;
BypassLocalCheckBox.Enabled = UseProxyRadioButton.Checked;
enableOK();
}
private void AuthenticationCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!AuthenticationCheckBox.Checked)
{
ProxyUsernameTextBox.Clear();
ProxyPasswordTextBox.Clear();
AuthenticationCheckBox.Checked = false; // have to redo this as the 2 Clears above cause the checkbox to recheck
}
SelectUseThisProxyServer();
enableOK();
}
private void ProxyAddressTextBox_TextChanged(object sender, EventArgs e)
{
SelectUseThisProxyServer();
enableOK();
}
private void ProxyPortTextBox_TextChanged(object sender, EventArgs e)
{
SelectUseThisProxyServer();
enableOK();
}
private void ProxyUsernameTextBox_TextChanged(object sender, EventArgs e)
{
SelectUseThisProxyServer();
if (!AuthenticationCheckBox.Checked)
AuthenticationCheckBox.Checked = true;
enableOK();
}
private void ProxyPasswordTextBox_TextChanged(object sender, EventArgs e)
{
SelectUseThisProxyServer();
if (!AuthenticationCheckBox.Checked)
AuthenticationCheckBox.Checked = true;
enableOK();
}
private void BypassForServersCheckbox_CheckedChanged(object sender, EventArgs e)
{
SelectUseThisProxyServer();
enableOK();
}
private void SelectUseThisProxyServer()
{
if (!UseProxyRadioButton.Checked && built)
UseProxyRadioButton.Checked = true;
}
private void enableOK()
{
if (optionsDialog == null)
@ -123,6 +170,11 @@ namespace XenAdmin.Dialogs.OptionsPages
optionsDialog.okButton.Enabled = true;
return;
}
else if (AuthenticationCheckBox.Checked && string.IsNullOrEmpty(ProxyUsernameTextBox.Text))
{
optionsDialog.okButton.Enabled = false;
return;
}
try
{
@ -150,7 +202,8 @@ namespace XenAdmin.Dialogs.OptionsPages
log.Info("=== ProxySetting: " + Properties.Settings.Default.ProxySetting.ToString());
log.Info("=== ProxyAddress: " + Properties.Settings.Default.ProxyAddress.ToString());
log.Info("=== ProxyPort: " + Properties.Settings.Default.ProxyPort.ToString());
log.Info("=== BypassProxyForLocal: " + Properties.Settings.Default.BypassProxyForLocal.ToString());
log.Info("=== ByPassProxyForServers: " + Properties.Settings.Default.BypassProxyForServers.ToString());
log.Info("=== ProvideProxyAuthentication: " + Properties.Settings.Default.ProvideProxyAuthentication.ToString());
log.Info("=== ConnectionTimeout: " + Properties.Settings.Default.ConnectionTimeout.ToString());
}
@ -158,7 +211,7 @@ namespace XenAdmin.Dialogs.OptionsPages
public void Save()
{
// Proxy server
// Proxy server settings
HTTPHelper.ProxyStyle new_proxy_style =
DirectConnectionRadioButton.Checked ? HTTPHelper.ProxyStyle.DirectConnection :
UseIERadioButton.Checked ? HTTPHelper.ProxyStyle.SystemProxy :
@ -167,14 +220,30 @@ namespace XenAdmin.Dialogs.OptionsPages
if (Properties.Settings.Default.ProxySetting != (int)new_proxy_style)
Properties.Settings.Default.ProxySetting = (int)new_proxy_style;
if (ProxyAddressTextBox.Text != Properties.Settings.Default.ProxyAddress && ProxyAddressTextBox.Text != "")
if (ProxyAddressTextBox.Text != Properties.Settings.Default.ProxyAddress && !string.IsNullOrEmpty(ProxyAddressTextBox.Text))
Properties.Settings.Default.ProxyAddress = ProxyAddressTextBox.Text;
if (new_proxy_style == HTTPHelper.ProxyStyle.SpecifiedProxy)
Properties.Settings.Default.ProxyUsername = EncryptionUtils.Protect(ProxyUsernameTextBox.Text);
Properties.Settings.Default.ProxyPassword = EncryptionUtils.Protect(ProxyPasswordTextBox.Text);
try
{
SetSpecifiedProxySettings();
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;
if (AuthenticationCheckBox.Checked != Properties.Settings.Default.ProvideProxyAuthentication)
Properties.Settings.Default.ProvideProxyAuthentication = AuthenticationCheckBox.Checked;
// timeout settings
int timeout = (int)ConnectionTimeoutNud.Value;
if (timeout * 1000 != Properties.Settings.Default.ConnectionTimeout)
{
@ -186,26 +255,11 @@ namespace XenAdmin.Dialogs.OptionsPages
Properties.Settings.Default.ProxyAddress,
Properties.Settings.Default.ProxyPort,
Properties.Settings.Default.ConnectionTimeout,
Properties.Settings.Default.BypassProxyForLocal,
true).RunAsync();
}
private void SetSpecifiedProxySettings()
{
if (int.Parse(ProxyPortTextBox.Text) != Properties.Settings.Default.ProxyPort)
{
try
{
Properties.Settings.Default.ProxyPort = int.Parse(ProxyPortTextBox.Text);
}
catch
{
Properties.Settings.Default.ProxyPort = 80;
}
}
if (BypassLocalCheckBox.Checked != Properties.Settings.Default.BypassProxyForLocal)
Properties.Settings.Default.BypassProxyForLocal = BypassLocalCheckBox.Checked;
false,
Properties.Settings.Default.BypassProxyForServers,
Properties.Settings.Default.ProvideProxyAuthentication,
Properties.Settings.Default.ProxyUsername,
Properties.Settings.Default.ProxyPassword).RunAsync();
}
#endregion

View File

@ -319,7 +319,7 @@
<value>Tahoma, 8pt</value>
</data>
<data name="TimeoutGroupBox.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 196</value>
<value>3, 241</value>
</data>
<data name="TimeoutGroupBox.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 0</value>
@ -358,14 +358,233 @@
<value>GrowAndShrink</value>
</data>
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="BypassForServersCheckbox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="BypassForServersCheckbox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="BypassForServersCheckbox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="BypassForServersCheckbox.Location" type="System.Drawing.Point, System.Drawing">
<value>20, 97</value>
</data>
<data name="BypassForServersCheckbox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 5, 3, 0</value>
</data>
<data name="BypassForServersCheckbox.Size" type="System.Drawing.Size, System.Drawing">
<value>276, 17</value>
</data>
<data name="BypassForServersCheckbox.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="BypassForServersCheckbox.Text" xml:space="preserve">
<value>&amp;Bypass proxy server for all [XenServer] connections</value>
</data>
<data name="&gt;&gt;BypassForServersCheckbox.Name" xml:space="preserve">
<value>BypassForServersCheckbox</value>
</data>
<data name="&gt;&gt;BypassForServersCheckbox.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BypassForServersCheckbox.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;BypassForServersCheckbox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="ProxyPasswordTextBox.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="ProxyPasswordTextBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="ProxyPasswordTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>355, 139</value>
</data>
<data name="ProxyPasswordTextBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 3, 3, 0</value>
</data>
<data name="ProxyPasswordTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>140, 20</value>
</data>
<data name="ProxyPasswordTextBox.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="&gt;&gt;ProxyPasswordTextBox.Name" xml:space="preserve">
<value>ProxyPasswordTextBox</value>
</data>
<data name="&gt;&gt;ProxyPasswordTextBox.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ProxyPasswordTextBox.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyPasswordTextBox.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="ProxyUsernameLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="ProxyUsernameLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="ProxyUsernameLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="ProxyUsernameLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>40, 136</value>
</data>
<data name="ProxyUsernameLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="ProxyUsernameLabel.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 5, 0, 0</value>
</data>
<data name="ProxyUsernameLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 18</value>
</data>
<data name="ProxyUsernameLabel.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="ProxyUsernameLabel.Text" xml:space="preserve">
<value>&amp;Username:</value>
</data>
<data name="ProxyUsernameLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="&gt;&gt;ProxyUsernameLabel.Name" xml:space="preserve">
<value>ProxyUsernameLabel</value>
</data>
<data name="&gt;&gt;ProxyUsernameLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ProxyUsernameLabel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyUsernameLabel.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="ProxyUsernameTextBox.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="ProxyUsernameTextBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="ProxyUsernameTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>99, 139</value>
</data>
<data name="ProxyUsernameTextBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 3, 3, 0</value>
</data>
<data name="ProxyUsernameTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>193, 20</value>
</data>
<data name="ProxyUsernameTextBox.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="&gt;&gt;ProxyUsernameTextBox.Name" xml:space="preserve">
<value>ProxyUsernameTextBox</value>
</data>
<data name="&gt;&gt;ProxyUsernameTextBox.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ProxyUsernameTextBox.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyUsernameTextBox.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="ProxyPasswordLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="ProxyPasswordLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="ProxyPasswordLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="ProxyPasswordLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="ProxyPasswordLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>298, 136</value>
</data>
<data name="ProxyPasswordLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 0, 0</value>
</data>
<data name="ProxyPasswordLabel.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 5, 0, 0</value>
</data>
<data name="ProxyPasswordLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>57, 18</value>
</data>
<data name="ProxyPasswordLabel.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="ProxyPasswordLabel.Text" xml:space="preserve">
<value>Pass&amp;word:</value>
</data>
<data name="ProxyPasswordLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="&gt;&gt;ProxyPasswordLabel.Name" xml:space="preserve">
<value>ProxyPasswordLabel</value>
</data>
<data name="&gt;&gt;ProxyPasswordLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ProxyPasswordLabel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyPasswordLabel.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="AuthenticationCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="AuthenticationCheckBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="AuthenticationCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="AuthenticationCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>20, 119</value>
</data>
<data name="AuthenticationCheckBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 5, 3, 0</value>
</data>
<data name="AuthenticationCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>121, 17</value>
</data>
<data name="AuthenticationCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="AuthenticationCheckBox.Text" xml:space="preserve">
<value>Provide &amp;credentials:</value>
</data>
<data name="&gt;&gt;AuthenticationCheckBox.Name" xml:space="preserve">
<value>AuthenticationCheckBox</value>
</data>
<data name="&gt;&gt;AuthenticationCheckBox.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;AuthenticationCheckBox.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;AuthenticationCheckBox.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="ProxyAddressLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="ProxyAddressLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="ProxyAddressLabel.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="ProxyAddressLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
@ -376,7 +595,7 @@
<value>20, 69</value>
</data>
<data name="ProxyAddressLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>20, 0, 0, 0</value>
<value>0, 0, 0, 0</value>
</data>
<data name="ProxyAddressLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>50, 23</value>
@ -400,7 +619,7 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyAddressLabel.ZOrder" xml:space="preserve">
<value>0</value>
<value>6</value>
</data>
<data name="UseProxyRadioButton.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -433,7 +652,7 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;UseProxyRadioButton.ZOrder" xml:space="preserve">
<value>1</value>
<value>7</value>
</data>
<data name="DirectConnectionRadioButton.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -466,7 +685,7 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;DirectConnectionRadioButton.ZOrder" xml:space="preserve">
<value>2</value>
<value>8</value>
</data>
<data name="UseIERadioButton.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -499,43 +718,10 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;UseIERadioButton.ZOrder" xml:space="preserve">
<value>3</value>
<value>9</value>
</data>
<data name="BypassLocalCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="BypassLocalCheckBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="BypassLocalCheckBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="BypassLocalCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>20, 97</value>
</data>
<data name="BypassLocalCheckBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>20, 5, 3, 0</value>
</data>
<data name="BypassLocalCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>218, 17</value>
</data>
<data name="BypassLocalCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="BypassLocalCheckBox.Text" xml:space="preserve">
<value>&amp;Bypass proxy server for local addresses</value>
</data>
<data name="&gt;&gt;BypassLocalCheckBox.Name" xml:space="preserve">
<value>BypassLocalCheckBox</value>
</data>
<data name="&gt;&gt;BypassLocalCheckBox.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;BypassLocalCheckBox.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;BypassLocalCheckBox.ZOrder" xml:space="preserve">
<value>4</value>
<data name="ProxyAddressTextBox.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="ProxyAddressTextBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
@ -547,7 +733,7 @@
<value>0, 3, 3, 0</value>
</data>
<data name="ProxyAddressTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>193, 20</value>
<value>222, 20</value>
</data>
<data name="ProxyAddressTextBox.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -562,14 +748,47 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyAddressTextBox.ZOrder" xml:space="preserve">
<value>10</value>
</data>
<data name="ProxyPortTextBox.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="ProxyPortTextBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="ProxyPortTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>355, 72</value>
</data>
<data name="ProxyPortTextBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 3, 3, 0</value>
</data>
<data name="ProxyPortTextBox.MaxLength" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="ProxyPortTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>140, 20</value>
</data>
<data name="ProxyPortTextBox.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.Name" xml:space="preserve">
<value>ProxyPortTextBox</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.ZOrder" xml:space="preserve">
<value>11</value>
</data>
<data name="ProxyPortLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Right</value>
</data>
<data name="ProxyPortLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="ProxyPortLabel.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="ProxyPortLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
@ -577,13 +796,13 @@
<value>NoControl</value>
</data>
<data name="ProxyPortLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>269, 69</value>
<value>324, 74</value>
</data>
<data name="ProxyPortLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 0, 0</value>
</data>
<data name="ProxyPortLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>31, 23</value>
<value>31, 13</value>
</data>
<data name="ProxyPortLabel.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -604,46 +823,16 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyPortLabel.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="ProxyPortTextBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
</data>
<data name="ProxyPortTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>300, 72</value>
</data>
<data name="ProxyPortTextBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 3, 3, 0</value>
</data>
<data name="ProxyPortTextBox.MaxLength" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="ProxyPortTextBox.Size" type="System.Drawing.Size, System.Drawing">
<value>99, 20</value>
</data>
<data name="ProxyPortTextBox.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.Name" xml:space="preserve">
<value>ProxyPortTextBox</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;ProxyPortTextBox.ZOrder" xml:space="preserve">
<value>7</value>
<value>12</value>
</data>
<data name="tableLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 19</value>
</data>
<data name="tableLayoutPanel1.RowCount" type="System.Int32, mscorlib">
<value>5</value>
<value>7</value>
</data>
<data name="tableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>402, 114</value>
<value>498, 159</value>
</data>
<data name="tableLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -661,7 +850,7 @@
<value>0</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="ProxyAddressLabel" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="UseProxyRadioButton" Row="2" RowSpan="1" Column="0" ColumnSpan="4" /&gt;&lt;Control Name="DirectConnectionRadioButton" Row="0" RowSpan="1" Column="0" ColumnSpan="4" /&gt;&lt;Control Name="UseIERadioButton" Row="1" RowSpan="1" Column="0" ColumnSpan="4" /&gt;&lt;Control Name="BypassLocalCheckBox" Row="4" RowSpan="1" Column="0" ColumnSpan="4" /&gt;&lt;Control Name="ProxyAddressTextBox" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="ProxyPortLabel" Row="3" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="ProxyPortTextBox" Row="3" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="BypassForServersCheckbox" Row="4" RowSpan="1" Column="1" ColumnSpan="6" /&gt;&lt;Control Name="ProxyPasswordTextBox" Row="6" RowSpan="1" Column="6" ColumnSpan="1" /&gt;&lt;Control Name="ProxyUsernameLabel" Row="6" RowSpan="1" Column="2" ColumnSpan="2" /&gt;&lt;Control Name="ProxyUsernameTextBox" Row="6" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;Control Name="ProxyPasswordLabel" Row="6" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="AuthenticationCheckBox" Row="5" RowSpan="1" Column="1" ColumnSpan="6" /&gt;&lt;Control Name="ProxyAddressLabel" Row="3" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="UseProxyRadioButton" Row="2" RowSpan="1" Column="0" ColumnSpan="6" /&gt;&lt;Control Name="DirectConnectionRadioButton" Row="0" RowSpan="1" Column="0" ColumnSpan="6" /&gt;&lt;Control Name="UseIERadioButton" Row="1" RowSpan="1" Column="0" ColumnSpan="6" /&gt;&lt;Control Name="ProxyAddressTextBox" Row="3" RowSpan="1" Column="3" ColumnSpan="2" /&gt;&lt;Control Name="ProxyPortTextBox" Row="3" RowSpan="1" Column="5" ColumnSpan="1" /&gt;&lt;Control Name="ProxyPortLabel" Row="3" RowSpan="1" Column="4" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,20,Absolute,20,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="ProxyGroupBox.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
@ -676,7 +865,7 @@
<value>3, 3, 3, 0</value>
</data>
<data name="ProxyGroupBox.Size" type="System.Drawing.Size, System.Drawing">
<value>584, 149</value>
<value>584, 194</value>
</data>
<data name="ProxyGroupBox.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -718,7 +907,7 @@
<value>2</value>
</data>
<data name="label1.Text" xml:space="preserve">
<value>These settings allow you to configure a proxy server or to customize your [XenServer] connections for high latency environments.</value>
<value>These settings allow you to configure a proxy server or to customize your [XenServer] connections for high latency environments.</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
@ -783,4 +972,4 @@
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
</root>

View File

@ -507,8 +507,11 @@ namespace XenAdmin
Properties.Settings.Default.ProxyAddress,
Properties.Settings.Default.ProxyPort,
Properties.Settings.Default.ConnectionTimeout,
Properties.Settings.Default.BypassProxyForLocal,
true).RunAsync();
true,
Properties.Settings.Default.BypassProxyForServers,
Properties.Settings.Default.ProvideProxyAuthentication,
Properties.Settings.Default.ProxyUsername,
Properties.Settings.Default.ProxyPassword).RunAsync();
}
catch (ConfigurationErrorsException ex)
{

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -268,19 +268,6 @@ namespace XenAdmin.Properties {
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public bool BypassProxyForLocal {
get {
return ((bool)(this["BypassProxyForLocal"]));
}
set {
this["BypassProxyForLocal"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("80")]
@ -708,5 +695,53 @@ namespace XenAdmin.Properties {
this["ShowAboutDialog"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool ProvideProxyAuthentication {
get {
return ((bool)(this["ProvideProxyAuthentication"]));
}
set {
this["ProvideProxyAuthentication"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ProxyUsername {
get {
return ((string)(this["ProxyUsername"]));
}
set {
this["ProxyUsername"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ProxyPassword {
get {
return ((string)(this["ProxyPassword"]));
}
set {
this["ProxyPassword"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool BypassProxyForServers {
get {
return ((bool)(this["BypassProxyForServers"]));
}
set {
this["BypassProxyForServers"] = value;
}
}
}
}

View File

@ -60,9 +60,6 @@
<Setting Name="ProxyAddress" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="BypassProxyForLocal" Roaming="true" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ProxyPort" Roaming="true" Type="System.Int32" Scope="User">
<Value Profile="(Default)">80</Value>
</Setting>
@ -164,5 +161,17 @@
<Setting Name="ShowAboutDialog" Roaming="true" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ProvideProxyAuthentication" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ProxyUsername" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ProxyPassword" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="BypassProxyForServers" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -85,6 +85,11 @@ namespace XenAdmin
}
public IWebProxy GetProxyFromSettings(IXenConnection connection)
{
return GetProxyFromSettings(connection, true);
}
public IWebProxy GetProxyFromSettings(IXenConnection connection, bool isForXenServer)
{
try
{
@ -94,10 +99,24 @@ namespace XenAdmin
switch ((HTTPHelper.ProxyStyle)XenAdmin.Properties.Settings.Default.ProxySetting)
{
case HTTPHelper.ProxyStyle.SpecifiedProxy:
return new WebProxy(string.Format("http://{0}:{1}",
if (isForXenServer && Properties.Settings.Default.BypassProxyForServers)
return null;
string address = string.Format("http://{0}:{1}",
XenAdmin.Properties.Settings.Default.ProxyAddress,
XenAdmin.Properties.Settings.Default.ProxyPort),
XenAdmin.Properties.Settings.Default.BypassProxyForLocal);
XenAdmin.Properties.Settings.Default.ProxyPort);
if (XenAdmin.Properties.Settings.Default.ProvideProxyAuthentication)
{
string protectedUsername = XenAdmin.Properties.Settings.Default.ProxyUsername;
string protectedPassword = XenAdmin.Properties.Settings.Default.ProxyPassword;
return new WebProxy(address, false, null, new NetworkCredential(
// checks for empty default username/password which starts out unencrypted
string.IsNullOrEmpty(protectedUsername) ? "" : EncryptionUtils.Unprotect(protectedUsername),
string.IsNullOrEmpty(protectedPassword) ? "" : EncryptionUtils.Unprotect(protectedPassword)));
}
else
return new WebProxy(address, false);
case HTTPHelper.ProxyStyle.SystemProxy:
return WebRequest.GetSystemWebProxy();

View File

@ -60,9 +60,6 @@
<setting name="ProxyAddress" serializeAs="String">
<value />
</setting>
<setting name="BypassProxyForLocal" serializeAs="String">
<value>False</value>
</setting>
<setting name="ProxyPort" serializeAs="String">
<value>80</value>
</setting>
@ -159,6 +156,18 @@
<setting name="ShowAboutDialog" serializeAs="String">
<value>True</value>
</setting>
<setting name="ProvideProxyAuthentication" serializeAs="String">
<value>False</value>
</setting>
<setting name="ProxyUsername" serializeAs="String">
<value />
</setting>
<setting name="ProxyPassword" serializeAs="String">
<value />
</setting>
<setting name="BypassProxyForServers" serializeAs="String">
<value>False</value>
</setting>
</XenAdmin.Properties.Settings>
</userSettings>

View File

@ -79,6 +79,11 @@ namespace XenAdminTests.XenModelTests
return new XenAdminSimulatorWebProxy(DbProxy.proxys[connection]);
}
public IWebProxy GetProxyFromSettings(IXenConnection connection, bool isForXenServer)
{
return new XenAdminSimulatorWebProxy(DbProxy.proxys[connection]);
}
public int GetProxyTimeout(bool timeout)
{
return 0;

View File

@ -38,7 +38,7 @@ namespace XenAdmin.Core
{
/// <summary>
/// Used to centralise the encryption routines used for master password
/// & session lists
/// and session lists
/// </summary>
public class EncryptionUtils
{

View File

@ -44,16 +44,23 @@ namespace XenAdmin.Actions
private string proxyAddress;
private int proxyPort;
private int timeOut;
private bool bypassForLocal;
private bool bypassProxyForServers;
private bool provideProxyCredentials;
private string proxyUsername;
private string proxyPassword;
public TransferProxySettingsAction(HTTPHelper.ProxyStyle style, string address, int port, int timeout, bool bypassLocal, bool suppressHistory)
public TransferProxySettingsAction(HTTPHelper.ProxyStyle style, string address, int port, int timeout,
bool suppressHistory, bool bypassForServer, bool provideCredentials, string username, string password)
: base(null, Messages.ACTION_TRANSFER_HEALTHCHECK_SETTINGS, Messages.ACTION_TRANSFER_HEALTHCHECK_SETTINGS, suppressHistory)
{
proxyStyle = style;
proxyAddress = address;
proxyPort = port;
timeOut = timeout;
bypassForLocal = bypassLocal;
bypassProxyForServers = bypassForServer;
provideProxyCredentials = provideCredentials;
proxyUsername = username;
proxyPassword = password;
}
private const string HEALTHCHECKSERVICENAME = "XenServerHealthCheck";
@ -71,7 +78,10 @@ namespace XenAdmin.Actions
proxyAddress,
proxyPort.ToString(),
timeOut.ToString(),
bypassForLocal.ToString()});
bypassProxyForServers.ToString(),
provideProxyCredentials.ToString(),
proxyUsername.ToString(),
proxyPassword.ToString()});
return proxySettings;
case HTTPHelper.ProxyStyle.SystemProxy:

View File

@ -62,7 +62,7 @@ namespace XenServerHealthCheck
{
UPLOAD_URL = uploadUrl;
}
proxy = XenAdminConfigManager.Provider.GetProxyFromSettings(connection);
proxy = XenAdminConfigManager.Provider.GetProxyFromSettings(connection, false);
}
// Request an upload and fetch the uploading id from CIS.

View File

@ -265,7 +265,7 @@ namespace XenAdmin.Actions
protected virtual XmlDocument FetchCheckForUpdatesXml(string location)
{
XmlDocument xdoc;
using (Stream xmlstream = HTTPHelper.GET(new Uri(location), Connection, false, true))
using (Stream xmlstream = HTTPHelper.GET(new Uri(location), Connection, false, true, false))
{
xdoc = Helpers.LoadXmlDocument(xmlstream);
}

View File

@ -323,11 +323,11 @@ namespace XenAPI
return HTTP.PUT(uri, XenAdminConfigManager.Provider.GetProxyFromSettings(null), ContentLength, XenAdminConfigManager.Provider.GetProxyTimeout(timeout));
}
public static Stream GET(Uri uri, IXenConnection connection, bool timeout, bool do_log)
public static Stream GET(Uri uri, IXenConnection connection, bool timeout, bool do_log, bool isForXenServer = true)
{
if (do_log)
log.DebugFormat("HTTP GETTING file from {0}", uri);
return HTTP.GET(uri, XenAdminConfigManager.Provider.GetProxyFromSettings(connection), XenAdminConfigManager.Provider.GetProxyTimeout(timeout));
return HTTP.GET(uri, XenAdminConfigManager.Provider.GetProxyFromSettings(connection, isForXenServer), XenAdminConfigManager.Provider.GetProxyTimeout(timeout));
}
}
}

View File

@ -36,6 +36,7 @@ using System.Net.Sockets;
using System.Text;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Runtime.Serialization;
@ -106,6 +107,18 @@ namespace XenAPI
protected CancelledException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
[Serializable]
public class ProxyServerAuthenticationException : Exception
{
public ProxyServerAuthenticationException() : base() { }
public ProxyServerAuthenticationException(string message) : base(message) { }
public ProxyServerAuthenticationException(string message, Exception exception) : base(message, exception) { }
protected ProxyServerAuthenticationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
public delegate bool FuncBool();
public delegate void UpdateProgressDelegate(int percent);
public delegate void DataCopiedDelegate(long bytes);
@ -130,6 +143,10 @@ namespace XenAPI
WriteLine("", stream);
}
// Stream.ReadByte() is used because using StreamReader in its place causes the reading to become stuck,
// as it seems the Stream object has trouble recognizing the end of the stream. This seems to be a common
// problem, of which a common solution is to read each byte until an EndOfStreamException is thrown, as is
// done here.
private static string ReadLine(Stream stream)
{
System.Text.StringBuilder result = new StringBuilder();
@ -150,25 +167,81 @@ namespace XenAPI
/// </summary>
/// <param name="stream"></param>
/// <returns>True if a redirect has occurred - headers will need to be resent.</returns>
private static bool ReadHttpHeaders(ref Stream stream, IWebProxy proxy, bool nodelay, int timeout_ms)
private static bool ReadHttpHeaders(ref Stream stream, IWebProxy proxy, bool nodelay, int timeout_ms, List<string> headers = null)
{
string response = ReadLine(stream);
int code = getResultCode(response);
// read headers/fields
string line = ReadLine(stream), initialLine = line, transferEncodingField = null;
if (string.IsNullOrEmpty(initialLine)) // sanity check
return false;
while (!string.IsNullOrWhiteSpace(line)) // IsNullOrWhiteSpace also checks for empty string
{
if (headers != null)
{
line = line.TrimEnd('\r', '\n');
headers.Add(line);
if (line == "Transfer-Encoding: Chunked")
transferEncodingField = line;
}
line = ReadLine(stream);
}
// read chunks
string entityBody = "";
if (!string.IsNullOrEmpty(transferEncodingField))
{
int lastChunkSize = -1;
do
{
string chunkSizeStr = ReadLine(stream);
chunkSizeStr = chunkSizeStr.TrimEnd('\r', '\n');
int chunkSize = int.Parse(chunkSizeStr, System.Globalization.NumberStyles.HexNumber);
byte[] bytes = new byte[chunkSize];
stream.Read(bytes, 0, chunkSize);
if (headers != null)
{
string str = System.Text.Encoding.ASCII.GetString(bytes);
string[] split = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
headers.AddRange(split);
entityBody += str;
}
line = ReadLine(stream); // empty line in the end of chunk
lastChunkSize = chunkSize;
}
while (lastChunkSize != 0);
if (headers != null)
{
entityBody = entityBody.TrimEnd('\r', '\n');
headers.Add(entityBody); // keep entityBody if it's needed for Digest authentication (when qop="auth-int")
}
}
else
{
// todo: handle other transfer types, in case "Transfer-Encoding: Chunked" isn't used
}
// handle server response
int code = getResultCode(initialLine);
switch (code)
{
case 407: // authentication error; caller must handle this case
case 200:
break;
case 302:
string url = "";
while (true)
foreach (string header in headers)
{
response = ReadLine(stream);
if (response.StartsWith("Location: "))
url = response.Substring(10);
if (response.Equals("\r\n") || response.Equals("\n") || response.Equals(""))
if (header.StartsWith("Location: "))
{
url = header.Substring(10);
break;
}
}
Uri redirect = new Uri(url.Trim());
stream.Close();
@ -176,19 +249,8 @@ namespace XenAPI
return true; // headers need to be sent again
default:
if (response.EndsWith("\r\n"))
response = response.Substring(0, response.Length - 2);
else if (response.EndsWith("\n"))
response = response.Substring(0, response.Length - 1);
stream.Close();
throw new BadServerResponseException(string.Format("Received error code {0} from the server", response));
}
while (true)
{
string line = ReadLine(stream);
if (System.Text.RegularExpressions.Regex.Match(line, "^\\s*$").Success)
break;
throw new BadServerResponseException(string.Format("Received error code {0} from the server", initialLine));
}
return false;
@ -214,6 +276,20 @@ namespace XenAPI
return true;
}
/// <summary>
/// Returns a secure MD5 hash of the given input string.
/// </summary>
/// <param name="str">The string to hash.</param>
/// <returns>The secure hash as a hex string.</returns>
public static string MD5Hash(string str)
{
MD5 hasher = MD5.Create();
ASCIIEncoding enc = new ASCIIEncoding();
byte[] bytes = enc.GetBytes(str);
byte[] hash = hasher.ComputeHash(bytes);
return BitConverter.ToString(hash).Replace("-", "").ToLower();
}
public static long CopyStream(Stream inStream, Stream outStream,
DataCopiedDelegate progressDelegate, FuncBool cancellingDelegate)
{
@ -299,6 +375,12 @@ namespace XenAPI
return uri.Uri;
}
private static string GetPartOrNull(string str, int partIndex)
{
string[] parts = str.Split(new char[] { ' ' }, partIndex + 2, StringSplitOptions.RemoveEmptyEntries);
return partIndex < parts.Length - 1 ? parts[partIndex] : null;
}
#endregion
private static NetworkStream ConnectSocket(Uri uri, bool nodelay, int timeout_ms)
@ -348,11 +430,13 @@ namespace XenAPI
if (useProxy)
{
string line = String.Format("CONNECT {0}:{1} HTTP/1.0", uri.Host, uri.Port);
WriteLine(line, stream);
WriteLine(stream);
ReadHttpHeaders(ref stream, proxy, nodelay, timeout_ms);
List<string> initialResponse = new List<string>();
ReadHttpHeaders(ref stream, proxy, nodelay, timeout_ms, initialResponse);
AuthenticateProxy(ref stream, uri, proxy, nodelay, timeout_ms, initialResponse, line);
}
if (UseSSL(uri))
@ -373,6 +457,157 @@ namespace XenAPI
}
}
private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy proxy, bool nodelay, int timeout_ms, List<string> initialResponse, string header)
{
// perform authentication only if proxy requires it
List<string> fields = initialResponse.FindAll(str => str.StartsWith("Proxy-Authenticate:"));
if (fields.Count > 0)
{
// clean up (if initial server response specifies "Proxy-Connection: Close" then stream cannot be re-used)
string field = initialResponse.Find(str => str.StartsWith("Proxy-Connection: Close"));
if (!string.IsNullOrEmpty(field))
{
stream.Close();
Uri proxyURI = proxy.GetProxy(uri);
stream = ConnectSocket(proxyURI, nodelay, timeout_ms);
}
if (proxy.Credentials == null)
throw new BadServerResponseException(string.Format("Received error code {0} from the server", initialResponse[0]));
NetworkCredential credentials = proxy.Credentials.GetCredential(uri, null);
string basicField = fields.Find(str => str.StartsWith("Proxy-Authenticate: Basic"));
string digestField = fields.Find(str => str.StartsWith("Proxy-Authenticate: Digest"));
if (!string.IsNullOrEmpty(basicField))
{
string authenticationFieldReply = String.Format("Proxy-Authorization: Basic {0}",
Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials.UserName + ":" + credentials.Password)));
WriteLine(header, stream);
WriteLine(authenticationFieldReply, stream);
WriteLine(stream);
}
else if (!string.IsNullOrEmpty(digestField))
{
string authenticationFieldReply = string.Format(
"Proxy-Authorization: Digest username=\"{0}\", uri=\"{1}:{2}\"",
credentials.UserName, uri.Host, uri.Port);
string directiveString = digestField.Substring(27, digestField.Length - 27);
string[] directives = directiveString.Split(new string[] { ", ", "\"" }, StringSplitOptions.RemoveEmptyEntries);
string algorithm = null; // optional
string opaque = null; // optional
string qop = null; // optional
string realm = null;
string nonce = null;
for (int i = 0; i < directives.Length; ++i)
{
switch (directives[i])
{
case "stale=":
if (directives[++i].ToLower() == "true")
throw new ProxyServerAuthenticationException("Stale nonce in Digest authentication attempt.");
break;
case "realm=":
authenticationFieldReply += string.Format(", {0}\"{1}\"", directives[i], directives[++i]);
realm = directives[i];
break;
case "nonce=":
authenticationFieldReply += string.Format(", {0}\"{1}\"", directives[i], directives[++i]);
nonce = directives[i];
break;
case "opaque=":
authenticationFieldReply += string.Format(", {0}\"{1}\"", directives[i], directives[++i]);
opaque = directives[i];
break;
case "algorithm=":
authenticationFieldReply += string.Format(", {0}\"{1}\"", directives[i], directives[++i]);
algorithm = directives[i];
break;
case "qop=":
List<string> qops = new List<string>(directives[++i].Split(new char[] { ',' }));
if (qops.Count > 0)
{
if (qops.Contains("auth"))
qop = "auth";
else if (qops.Contains("auth-int"))
qop = "auth-int";
else
throw new ProxyServerAuthenticationException(
"Digest authentication's quality-of-protection directive of is not supported.");
authenticationFieldReply += string.Format(", qop=\"{0}\"", qop);
}
break;
default:
break;
}
}
string clientNonce = "X3nC3nt3r"; // todo: generate random string
if (qop != null)
authenticationFieldReply += string.Format(", cnonce=\"{0}\"", clientNonce);
string nonceCount = "00000001"; // todo: track nonces and their corresponding nonce counts
if (qop != null)
authenticationFieldReply += string.Format(", nc={0}", nonceCount);
string HA1 = "";
string scratch = string.Format("{0}:{1}:{2}", credentials.UserName, realm, credentials.Password);
if (algorithm == null || algorithm == "MD5")
HA1 = MD5Hash(scratch);
else
HA1 = MD5Hash(string.Format("{0}:{1}:{2}", MD5Hash(scratch), nonce, clientNonce));
string HA2 = "";
scratch = GetPartOrNull(header, 0);
scratch = string.Format("{0}:{1}:{2}", scratch ?? "CONNECT", uri.Host, uri.Port);
if (qop == null || qop == "auth")
HA2 = MD5Hash(scratch);
else
{
string entityBody = initialResponse[initialResponse.Count - 1]; // entity body should have been stored as last element of initialResponse
string str = string.Format("{0}:{1}", scratch, MD5Hash(entityBody));
HA2 = MD5Hash(str);
}
string response = "";
if (qop == null)
response = MD5Hash(string.Format("{0}:{1}:{2}", HA1, nonce, HA2));
else
response = MD5Hash(string.Format("{0}:{1}:{2}:{3}:{4}:{5}", HA1, nonce, nonceCount, clientNonce, qop, HA2));
authenticationFieldReply += string.Format(", response=\"{0}\"", response);
WriteLine(header, stream);
WriteLine(authenticationFieldReply, stream);
WriteLine(stream);
}
else
{
string authType = GetPartOrNull(fields[0], 1);
throw new ProxyServerAuthenticationException(
string.Format("Proxy server's {0} authentication method is not supported.", authType ?? "chosen"));
}
// handle authentication attempt response
List<string> authenticatedResponse = new List<string>();
ReadHttpHeaders(ref stream, proxy, nodelay, timeout_ms, authenticatedResponse);
if (authenticatedResponse.Count == 0)
throw new BadServerResponseException("No response from the proxy server after authentication attempt.");
switch (getResultCode(authenticatedResponse[0]))
{
case 200:
break;
case 407:
throw new ProxyServerAuthenticationException("Proxy server denied access due to wrong credentials.");
default:
throw new BadServerResponseException(string.Format(
"Received error code {0} from the server", authenticatedResponse[0]));
}
}
}
private static Stream DO_HTTP(Uri uri, IWebProxy proxy, bool nodelay, int timeout_ms, params string[] headers)
{
Stream stream = ConnectStream(uri, proxy, nodelay, timeout_ms);

View File

@ -53,6 +53,7 @@ namespace XenAdmin
string XenCenterUUID { get; }
bool DontSudo { get; }
IWebProxy GetProxyFromSettings(IXenConnection connection);
IWebProxy GetProxyFromSettings(IXenConnection connection, bool isForXenServer);
int GetProxyTimeout(bool timeout);
void ShowObject(string newVMRef);
void HideObject(string newVMRef);

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -93,12 +93,12 @@ namespace XenServerHealthCheck.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public bool BypassProxyForLocal {
public bool BypassProxyForServers {
get {
return ((bool)(this["BypassProxyForLocal"]));
return ((bool)(this["BypassProxyForServers"]));
}
set {
this["BypassProxyForLocal"] = value;
this["BypassProxyForServers"] = value;
}
}
@ -127,5 +127,41 @@ namespace XenServerHealthCheck.Properties {
this["ConnectionTimeout"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool ProvideProxyAuthentication {
get {
return ((bool)(this["ProvideProxyAuthentication"]));
}
set {
this["ProvideProxyAuthentication"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ProxyUsername {
get {
return ((string)(this["ProxyUsername"]));
}
set {
this["ProxyUsername"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ProxyPassword {
get {
return ((string)(this["ProxyPassword"]));
}
set {
this["ProxyPassword"] = value;
}
}
}
}

View File

@ -18,7 +18,7 @@
<Setting Name="ProxyAddress" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="BypassProxyForLocal" Roaming="true" Type="System.Boolean" Scope="User">
<Setting Name="BypassProxyForServers" Roaming="true" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ProxyPort" Roaming="true" Type="System.Int32" Scope="User">
@ -27,5 +27,14 @@
<Setting Name="ConnectionTimeout" Roaming="true" Type="System.Int32" Scope="User">
<Value Profile="(Default)">20000</Value>
</Setting>
<Setting Name="ProvideProxyAuthentication" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ProxyUsername" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ProxyPassword" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@ -228,18 +228,23 @@ namespace XenServerHealthCheck
Properties.Settings.Default.ProxyAddress = proxySettings[2];
Properties.Settings.Default.ProxyPort = Int32.Parse(proxySettings[3]);
Properties.Settings.Default.ConnectionTimeout = Int32.Parse(proxySettings[4]);
Properties.Settings.Default.BypassProxyForLocal = bool.Parse(proxySettings[5]);
return;
Properties.Settings.Default.BypassProxyForServers = bool.Parse(proxySettings[5]);
Properties.Settings.Default.ProvideProxyAuthentication = bool.Parse(proxySettings[6]);
Properties.Settings.Default.ProxyUsername = proxySettings[7];
Properties.Settings.Default.ProxyPassword = proxySettings[8];
break;
case HTTPHelper.ProxyStyle.SystemProxy:
Properties.Settings.Default.ProxySetting = (Int32)proxyStyle;
return;
break;
default:
Properties.Settings.Default.ProxySetting = (Int32)proxyStyle;
return;
break;
}
Properties.Settings.Default.Save();
XenServerHealthCheckService.ReconfigureConnectionSettings();
}
catch (Exception e)
{

View File

@ -36,6 +36,7 @@ using System.IO;
using System.Net;
using XenAdmin;
using XenAdmin.Actions;
using XenAdmin.Core;
using XenAdmin.Network;
using XenAdmin.ServerDBs;
using XenAPI;
@ -89,6 +90,11 @@ namespace XenServerHealthCheck
}
public IWebProxy GetProxyFromSettings(IXenConnection connection)
{
return GetProxyFromSettings(connection, true);
}
public IWebProxy GetProxyFromSettings(IXenConnection connection, bool isForXenServer)
{
try
{
@ -98,10 +104,24 @@ namespace XenServerHealthCheck
switch ((HTTPHelper.ProxyStyle)Properties.Settings.Default.ProxySetting)
{
case HTTPHelper.ProxyStyle.SpecifiedProxy:
return new WebProxy(string.Format("http://{0}:{1}",
if (isForXenServer && Properties.Settings.Default.BypassProxyForServers)
return null;
string address = string.Format("http://{0}:{1}",
Properties.Settings.Default.ProxyAddress,
Properties.Settings.Default.ProxyPort),
Properties.Settings.Default.BypassProxyForLocal);
Properties.Settings.Default.ProxyPort);
if (Properties.Settings.Default.ProvideProxyAuthentication)
{
string protectedUsername = Properties.Settings.Default.ProxyUsername;
string protectedPassword = Properties.Settings.Default.ProxyPassword;
return new WebProxy(address, false, null, new NetworkCredential(
// checks for empty default username/password which starts out unencrypted
string.IsNullOrEmpty(protectedUsername) ? "" : EncryptionUtils.Unprotect(protectedUsername),
string.IsNullOrEmpty(protectedPassword) ? "" : EncryptionUtils.Unprotect(protectedPassword)));
}
else
return new WebProxy(address, false);
case HTTPHelper.ProxyStyle.SystemProxy:
return WebRequest.GetSystemWebProxy();

View File

@ -68,9 +68,16 @@ namespace XenServerHealthCheck
Properties.Settings.Default.Save();
}
ReconfigureConnectionSettings();
log.InfoFormat("XenServer Health Check Service {0} starting...", Properties.Settings.Default.UUID);
}
public static void ReconfigureConnectionSettings()
{
XenAPI.Session.Proxy = XenAdminConfigManager.Provider.GetProxyFromSettings(null);
}
protected override void OnStart(string[] args)
{
// Set up a timer to trigger the uploading service.

View File

@ -63,7 +63,7 @@
<setting name="ProxyAddress" serializeAs="String">
<value />
</setting>
<setting name="BypassProxyForLocal" serializeAs="String">
<setting name="BypassProxyForServers" serializeAs="String">
<value>False</value>
</setting>
<setting name="ProxyPort" serializeAs="String">
@ -72,6 +72,15 @@
<setting name="ConnectionTimeout" serializeAs="String">
<value>20000</value>
</setting>
<setting name="ProvideProxyAuthentication" serializeAs="String">
<value>False</value>
</setting>
<setting name="ProxyUsername" serializeAs="String">
<value />
</setting>
<setting name="ProxyPassword" serializeAs="String">
<value />
</setting>
</XenServerHealthCheck.Properties.Settings>
</userSettings>
</configuration>