Skip to content

Commit

Permalink
Fix RuntimeInformation after reattach having null SecurityLevel and V…
Browse files Browse the repository at this point in the history
…isibility
  • Loading branch information
Cyberboss committed Oct 21, 2023
1 parent 2f5e62c commit a6cb819
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<TgsApiLibraryVersion>11.1.2</TgsApiLibraryVersion>
<TgsClientVersion>12.1.2</TgsClientVersion>
<TgsDmapiVersion>6.5.4</TgsDmapiVersion>
<TgsInteropVersion>5.6.1</TgsInteropVersion>
<TgsInteropVersion>5.6.2</TgsInteropVersion>
<TgsHostWatchdogVersion>1.4.0</TgsHostWatchdogVersion>
<TgsContainerScriptVersion>1.2.1</TgsContainerScriptVersion>
<TgsMigratorVersion>1.0.2</TgsMigratorVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/DMAPI/tgs/v5/__interop_version.dm
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"5.6.1"
"5.6.2"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;

using Newtonsoft.Json;

using Tgstation.Server.Api.Models;
using Tgstation.Server.Host.Components.Chat;
using Tgstation.Server.Host.Components.Deployment;
Expand Down Expand Up @@ -42,12 +44,14 @@ public sealed class RuntimeInformation : ChatUpdate
/// <summary>
/// The <see cref="DreamDaemonSecurity"/> level of the launch.
/// </summary>
public DreamDaemonSecurity? SecurityLevel { get; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
public DreamDaemonSecurity SecurityLevel { get; }

/// <summary>
/// The <see cref="DreamDaemonSecurity"/> level of the launch.
/// </summary>
public DreamDaemonVisibility? Visibility { get; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
public DreamDaemonVisibility Visibility { get; }

/// <summary>
/// The <see cref="TestMergeInformation"/>s in the launch.
Expand All @@ -70,8 +74,8 @@ public RuntimeInformation(
IDmbProvider dmbProvider,
Version serverVersion,
string instanceName,
DreamDaemonSecurity? securityLevel,
DreamDaemonVisibility? visibility,
DreamDaemonSecurity securityLevel,
DreamDaemonVisibility visibility,
ushort serverPort,
bool apiValidateOnly)
: base(chatTrackingContext?.Channels ?? throw new ArgumentNullException(nameof(chatTrackingContext)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@ internal ReattachInformation(
Dmb = dmb ?? throw new ArgumentNullException(nameof(dmb));
ProcessId = process?.Id ?? throw new ArgumentNullException(nameof(process));
RuntimeInformation = runtimeInformation ?? throw new ArgumentNullException(nameof(runtimeInformation));
if (!runtimeInformation.SecurityLevel.HasValue)
throw new ArgumentException("runtimeInformation must have a valid SecurityLevel!", nameof(runtimeInformation));

AccessIdentifier = accessIdentifier ?? throw new ArgumentNullException(nameof(accessIdentifier));

LaunchSecurityLevel = runtimeInformation.SecurityLevel.Value;
LaunchVisibility = runtimeInformation.Visibility.Value;
LaunchSecurityLevel = runtimeInformation.SecurityLevel;
LaunchVisibility = runtimeInformation.Visibility;
Port = port;

runtimeInformationLock = new object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ public async Task<ISessionController> LaunchNew(
var runtimeInformation = CreateRuntimeInformation(
dmbProvider,
chatTrackingContext,
launchParameters,
launchParameters.SecurityLevel.Value,
launchParameters.Visibility.Value,
apiValidate);

var reattachInformation = new ReattachInformation(
Expand Down Expand Up @@ -430,7 +431,8 @@ public async Task<ISessionController> Reattach(
var runtimeInformation = CreateRuntimeInformation(
reattachInformation.Dmb,
chatTrackingContext,
null,
reattachInformation.LaunchSecurityLevel,
reattachInformation.LaunchVisibility,
false);
reattachInformation.SetRuntimeInformation(runtimeInformation);

Expand Down Expand Up @@ -632,15 +634,16 @@ async Task LogDDOutput(IProcess process, string outputFilePath, bool cliSupporte
RuntimeInformation CreateRuntimeInformation(
IDmbProvider dmbProvider,
IChatTrackingContext chatTrackingContext,
DreamDaemonLaunchParameters launchParameters,
DreamDaemonSecurity securityLevel,
DreamDaemonVisibility visibility,
bool apiValidateOnly)
=> new (
chatTrackingContext,
dmbProvider,
assemblyInformationProvider.Version,
instance.Name,
launchParameters?.SecurityLevel,
launchParameters?.Visibility,
securityLevel,
visibility,
serverPortProvider.HttpApiPort,
apiValidateOnly);

Expand Down
4 changes: 2 additions & 2 deletions src/Tgstation.Server.Host/Models/ReattachInformationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public abstract class ReattachInformationBase : DMApiParameters
/// The <see cref="DreamDaemonSecurity"/> level DreamDaemon was launched with.
/// </summary>
[Required]
public DreamDaemonSecurity? LaunchSecurityLevel { get; set; }
public DreamDaemonSecurity LaunchSecurityLevel { get; set; }

/// <summary>
/// The <see cref="DreamDaemonVisibility"/> DreamDaemon was launched with.
/// </summary>
[Required]
public DreamDaemonVisibility? LaunchVisibility { get; set; }
public DreamDaemonVisibility LaunchVisibility { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="ReattachInformationBase"/> class.
Expand Down

0 comments on commit a6cb819

Please sign in to comment.