Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions package/WindowsManaged/Actions/CustomActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ public static ActionResult ConfigureNgrokListeners(Session session)
return ExecuteCommand(session, command);
}

[CustomAction]
public static ActionResult ConfigureAgentTunnel(Session session)
{
string command;

try
{
command = $"$AgentTunnel = New-DGatewayAgentTunnelConfig -Enabled -ListenPort {session.Get(GatewayProperties.agentTunnelPort)}; Set-DGatewayConfig -AgentTunnel $AgentTunnel";
command = FormatPowerShellCommand(session, command);
}
catch (Exception e)
{
session.Log($"command {nameof(ConfigureAgentTunnel)} execution failure: {e}");
return ActionResult.Failure;
}

return ExecuteCommand(session, command);
}

[CustomAction]
public static ActionResult ConfigurePublicKey(Session session)
{
Expand Down
19 changes: 17 additions & 2 deletions package/WindowsManaged/Actions/GatewayActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,27 @@ internal static class GatewayActions
},
new[] { GatewayProperties.configureNgrok.Equal(true) });

private static readonly ElevatedManagedAction configureAgentTunnel = BuildConfigureAction(
$"CA.{nameof(configureAgentTunnel)}",
CustomActions.ConfigureAgentTunnel,
When.After, new Step(configureNgrokListeners.Id),
new IWixProperty[]
{
GatewayProperties.agentTunnelPort,
},
new[]
{
GatewayProperties.firstInstall.Equal(true),
GatewayProperties.enableAgentTunnel.Equal(true)
});

/// <summary>
/// Configure the certificate using PowerShell
/// </summary>
private static readonly ElevatedManagedAction configureCertificate = BuildConfigureAction(
$"CA.{nameof(configureCertificate)}",
CustomActions.ConfigureCertificate,
When.After, new Step(configureNgrokListeners.Id),
When.After, new Step(configureAgentTunnel.Id),
new IWixProperty[]
{
GatewayProperties.certificateMode,
Expand Down Expand Up @@ -534,9 +548,10 @@ private static ElevatedManagedAction BuildConfigureAction(
configureInit,
configureAccessUri,
configureListeners,
configureNgrokListeners,
configureAgentTunnel,
configureCertificate,
setCertificatePrivateKeyPermissions,
configureNgrokListeners,
configurePublicKey,
configureWebApp,
configureWebAppUser,
Expand Down
81 changes: 71 additions & 10 deletions package/WindowsManaged/Dialogs/CustomizeDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions package/WindowsManaged/Dialogs/CustomizeDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public override void FromProperties()
{
GatewayProperties properties = new(this.Runtime.Session);
this.cmbConfigure.SelectedIndex = properties.ConfigureGateway ? 0 : 1;
this.chkEnableAgentTunnel.Checked = properties.EnableAgentTunnel;
this.txtAgentTunnelPort.Text = properties.AgentTunnelPort.ToString();
this.chkConfigureNgrok.Checked = properties.ConfigureNgrok;
this.chkWebApp.Checked = properties.ConfigureWebApp;
this.chkGenerateCertificate.Checked = properties.GenerateCertificate;
Expand All @@ -33,12 +35,28 @@ public override void FromProperties()
this.SetControlStates();
}

public override bool DoValidate()
{
if (this.ConfigureNow && this.chkEnableAgentTunnel.Checked &&
(string.IsNullOrWhiteSpace(this.txtAgentTunnelPort.Text) || !Validation.IsValidPort(this.txtAgentTunnelPort.Text, out _)))
{
ShowValidationError(I18n(Strings.YouMustEnterAValidPort));
return false;
}

return true;
}

public override bool ToProperties()
{
new GatewayProperties(this.Runtime.Session)
{
ConfigureGateway = this.ConfigureNow,
ConfigureNgrok = this.ConfigureNow && this.chkConfigureNgrok.Checked,
EnableAgentTunnel = this.ConfigureNow && this.chkEnableAgentTunnel.Checked,
AgentTunnelPort = Validation.IsValidPort(this.txtAgentTunnelPort.Text, out uint agentTunnelPort)
? agentTunnelPort
: GatewayProperties.agentTunnelPort.Default,
ConfigureWebApp = this.ConfigureNow && this.chkWebApp.Checked,
GenerateCertificate = this.ConfigureNow && this.chkGenerateCertificate.Checked && !this.chkConfigureNgrok.Checked,
GenerateKeyPair = this.ConfigureNow && this.chkGenerateKeyPair.Checked,
Expand Down Expand Up @@ -73,6 +91,8 @@ public override void OnLoad(object sender, EventArgs e)
private void SetControlStates()
{
this.chkConfigureNgrok.Enabled = this.ConfigureNow;
this.chkEnableAgentTunnel.Enabled = this.ConfigureNow;
this.txtAgentTunnelPort.Enabled = this.chkEnableAgentTunnel.Checked && this.chkEnableAgentTunnel.Enabled;
this.chkWebApp.Enabled = this.ConfigureNow;

this.chkGenerateCertificate.Enabled = this.chkWebApp.Checked && this.chkWebApp.Enabled && !this.chkConfigureNgrok.Checked;
Expand Down Expand Up @@ -117,6 +137,11 @@ private void chkConfigureNgrok_CheckedChanged(object sender, EventArgs e)
}
}

private void chkEnableAgentTunnel_CheckedChanged(object sender, EventArgs e)
{
this.SetControlStates();
}

private void cmbConfigure_SelectedIndexChanged(object sender, EventArgs e)
{
this.SetControlStates();
Expand Down
11 changes: 11 additions & 0 deletions package/WindowsManaged/Dialogs/SummaryDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ private void Init() => this.Groups = new[]
}
},

new PropertyGroup()
{
Name = Strings.Group_AgentTunnel,
If = p => p.EnableAgentTunnel,
Properties = new IProperty[]
{
new InstallerProperty(this.MsiRuntime, GatewayProperties.enableAgentTunnel),
new InstallerProperty(this.MsiRuntime, GatewayProperties.agentTunnelPort)
}
},

new PropertyGroup()
{
Name = Strings.Group_EncryptionKeys,
Expand Down
63 changes: 63 additions & 0 deletions package/WindowsManaged/Properties/GatewayProperties.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,63 @@ public Boolean ConfigureGateway
}


internal static readonly WixProperty<Boolean> enableAgentTunnel = new()
{
Id = "P.ENABLEAGENTTUNNEL",
Default = false,
Name = "EnableAgentTunnel",
Secure = true,
Hidden = false,
Public = true,
Encode = false,
};

/// <summary>`true` to enable Agent Tunnel</summary>
public Boolean EnableAgentTunnel
{
get
{
string stringValue = this.FnGetPropValue(enableAgentTunnel.Id);
return WixProperties.GetPropertyValue<Boolean>(stringValue);
}
set
{
if (this.runtimeSession is not null)
{
this.runtimeSession.Set(enableAgentTunnel, value);
}
}
}


internal static readonly WixProperty<UInt32> agentTunnelPort = new()
{
Id = "P.AGENTTUNNELPORT",
Default = 4433,
Name = "AgentTunnelPort",
Secure = true,
Hidden = false,
Public = true,
Encode = false,
};

public UInt32 AgentTunnelPort
{
get
{
string stringValue = this.FnGetPropValue(agentTunnelPort.Id);
return WixProperties.GetPropertyValue<UInt32>(stringValue);
}
set
{
if (this.runtimeSession is not null)
{
this.runtimeSession.Set(agentTunnelPort, value);
}
}
}


internal static readonly WixProperty<Boolean> hasPowerShell = new()
{
Id = "P.HasPowerShell",
Expand Down Expand Up @@ -1522,6 +1579,12 @@ public Boolean Maintenance
configureGateway,


enableAgentTunnel,


agentTunnelPort,


hasPowerShell,


Expand Down
2 changes: 2 additions & 0 deletions package/WindowsManaged/Properties/GatewayProperties.g.tt
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ namespace DevolutionsGateway.Properties
new PropertyDefinition<string>("DevolutionsServerCertificateExceptions", "", isPublic: true, hidden: false, secure: true, encode: true),

new PropertyDefinition<bool>("ConfigureGateway", false, secure: false, comment: "`true` to configure the Gateway interactively"),
new PropertyDefinition<bool>("EnableAgentTunnel", false, comment: "`true` to enable Agent Tunnel"),
new PropertyDefinition<uint>("AgentTunnelPort", 4433),
new PropertyDefinition<bool>("HasPowerShell", false, isPublic: false, secure: false),

new PropertyDefinition<string>("HttpListenerHost", "0.0.0.0"),
Expand Down
Loading
Loading