mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-12 08:33:43 +01:00
Rework DMApiParameters.AccessIdentifier to be properly non-nullble
This commit is contained in:
@@ -50,5 +50,14 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge
|
||||
/// The port that should be used to send world topics, if not the default.
|
||||
/// </summary>
|
||||
public ushort? TopicPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BridgeParameters"/> class.
|
||||
/// </summary>
|
||||
/// <param name="accessIdentifier">The access identifier for the <see cref="DMApiParameters"/>.</param>
|
||||
public BridgeParameters(string accessIdentifier)
|
||||
: base(accessIdentifier)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
{
|
||||
@@ -11,6 +12,24 @@ namespace Tgstation.Server.Host.Components.Interop
|
||||
/// Used to identify and authenticate the DreamDaemon instance.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string? AccessIdentifier { get; set; }
|
||||
public string AccessIdentifier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DMApiParameters"/> class.
|
||||
/// </summary>
|
||||
/// <param name="accessIdentifier">The value of <see cref="AccessIdentifier"/>.</param>
|
||||
public DMApiParameters(string accessIdentifier)
|
||||
{
|
||||
AccessIdentifier = accessIdentifier ?? throw new ArgumentNullException(nameof(accessIdentifier));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DMApiParameters"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>For use by EFCore only.</remarks>
|
||||
protected DMApiParameters()
|
||||
{
|
||||
AccessIdentifier = null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
/// </summary>
|
||||
/// <param name="commandType">The value of <see cref="CommandType"/>.</param>
|
||||
protected TopicParameters(TopicCommandType commandType)
|
||||
: base(String.Empty) // access identifier gets set before send
|
||||
{
|
||||
CommandType = commandType;
|
||||
}
|
||||
|
||||
@@ -74,13 +74,12 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
RuntimeInformation runtimeInformation,
|
||||
string accessIdentifier,
|
||||
ushort port)
|
||||
: base(accessIdentifier)
|
||||
{
|
||||
Dmb = dmb ?? throw new ArgumentNullException(nameof(dmb));
|
||||
ProcessId = process?.Id ?? throw new ArgumentNullException(nameof(process));
|
||||
RuntimeInformation = runtimeInformation ?? throw new ArgumentNullException(nameof(runtimeInformation));
|
||||
|
||||
AccessIdentifier = accessIdentifier ?? throw new ArgumentNullException(nameof(accessIdentifier));
|
||||
|
||||
LaunchSecurityLevel = runtimeInformation.SecurityLevel;
|
||||
LaunchVisibility = runtimeInformation.Visibility;
|
||||
Port = port;
|
||||
|
||||
@@ -75,9 +75,8 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
|
||||
await ClearImpl(db, false, cancellationToken);
|
||||
|
||||
var dbReattachInfo = new Models.ReattachInformation
|
||||
var dbReattachInfo = new Models.ReattachInformation(reattachInformation.AccessIdentifier)
|
||||
{
|
||||
AccessIdentifier = reattachInformation.AccessIdentifier,
|
||||
CompileJobId = reattachInformation.Dmb.CompileJob.Id.Value,
|
||||
InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Id.Value,
|
||||
Port = reattachInformation.Port,
|
||||
@@ -103,7 +102,7 @@ namespace Tgstation.Server.Host.Components.Session
|
||||
|
||||
logger.LogTrace("Updating reattach information: {info}...", reattachInformation);
|
||||
|
||||
var dbReattachInfo = new Models.ReattachInformation
|
||||
var dbReattachInfo = new Models.ReattachInformation(String.Empty)
|
||||
{
|
||||
Id = reattachInformation.Id.Value,
|
||||
};
|
||||
|
||||
@@ -97,10 +97,10 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|
||||
using (LogContext.PushProperty(SerilogContextHelper.BridgeRequestIterationContextProperty, Interlocked.Increment(ref requestsProcessed)))
|
||||
{
|
||||
var request = new BridgeParameters();
|
||||
BridgeParameters? request;
|
||||
try
|
||||
{
|
||||
JsonConvert.PopulateObject(data, request, DMApiConstants.SerializerSettings);
|
||||
request = JsonConvert.DeserializeObject<BridgeParameters>(data, DMApiConstants.SerializerSettings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
@@ -27,5 +28,22 @@ namespace Tgstation.Server.Host.Models
|
||||
/// The <see cref="Api.Models.EntityId.Id"/> of <see cref="InitialCompileJob"/>.
|
||||
/// </summary>
|
||||
public long? InitialCompileJobId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReattachInformation"/> class.
|
||||
/// </summary>
|
||||
[Obsolete("For use by EFCore only", true)]
|
||||
public ReattachInformation()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReattachInformation"/> class.
|
||||
/// </summary>
|
||||
/// <param name="accessIdentifier">The access identifier for the <see cref="ReattachInformationBase"/>.</param>
|
||||
public ReattachInformation(string accessIdentifier)
|
||||
: base(accessIdentifier)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,19 +49,30 @@ namespace Tgstation.Server.Host.Models
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReattachInformationBase"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>For use by EFCore only.</remarks>
|
||||
protected ReattachInformationBase()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReattachInformationBase"/> class.
|
||||
/// </summary>
|
||||
/// <param name="accessIdentifier">The access identifier for the <see cref="DMApiParameters"/>.</param>
|
||||
protected ReattachInformationBase(string accessIdentifier)
|
||||
: base(accessIdentifier)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReattachInformationBase"/> class.
|
||||
/// </summary>
|
||||
/// <param name="copy">The <see cref="ReattachInformationBase"/> to copy values from.</param>
|
||||
protected ReattachInformationBase(ReattachInformationBase copy)
|
||||
: base(copy == null
|
||||
? throw new ArgumentNullException(nameof(copy))
|
||||
: copy.AccessIdentifier)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(copy);
|
||||
Id = copy.Id;
|
||||
AccessIdentifier = copy.AccessIdentifier;
|
||||
Port = copy.Port;
|
||||
TopicPort = copy.TopicPort;
|
||||
ProcessId = copy.ProcessId;
|
||||
|
||||
@@ -15,17 +15,20 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
{
|
||||
sealed class TestBridgeHandler : Chunker, IBridgeHandler
|
||||
{
|
||||
class DMApiParametersImpl : DMApiParameters { }
|
||||
class DMApiParametersImpl : DMApiParameters
|
||||
{
|
||||
public DMApiParametersImpl(string accessIdentifier)
|
||||
: base(accessIdentifier)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class BridgeResponseHack : BridgeResponse
|
||||
{
|
||||
public string IntegrationHack { get; set; }
|
||||
}
|
||||
|
||||
public DMApiParameters DMApiParameters => new DMApiParametersImpl
|
||||
{
|
||||
AccessIdentifier = accessIdentifier
|
||||
};
|
||||
public DMApiParameters DMApiParameters => new DMApiParametersImpl(accessIdentifier);
|
||||
|
||||
long lastBridgeRequestSize = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user