Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds OpenDream topic port as a DreamDaemon option #1828

Merged
merged 2 commits into from
Jul 21, 2024
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
8 changes: 4 additions & 4 deletions build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<!-- Integration tests will ensure they match across the board -->
<Import Project="WebpanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>6.6.1</TgsCoreVersion>
<TgsCoreVersion>6.7.0</TgsCoreVersion>
<TgsConfigVersion>5.1.0</TgsConfigVersion>
<TgsApiVersion>10.4.0</TgsApiVersion>
<TgsApiVersion>10.5.0</TgsApiVersion>
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
<TgsApiLibraryVersion>13.4.0</TgsApiLibraryVersion>
<TgsClientVersion>15.4.0</TgsClientVersion>
<TgsApiLibraryVersion>13.5.0</TgsApiLibraryVersion>
<TgsClientVersion>15.5.0</TgsClientVersion>
<TgsDmapiVersion>7.1.2</TgsDmapiVersion>
<TgsInteropVersion>5.9.0</TgsInteropVersion>
<TgsHostWatchdogVersion>1.4.1</TgsHostWatchdogVersion>
Expand Down
2 changes: 1 addition & 1 deletion build/package/winget/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"wix": {
"version": "4.0.4",
"version": "5.0.1",
"commands": [
"wix"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="WixToolset.Sdk/4.0.4" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Project Sdk="WixToolset.Sdk/5.0.1" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Import Project="../../../Common.props" />
<PropertyGroup>
<DefineConstants>ProductVersion=$(TgsCoreVersion);NetMajorVersion=$(TgsNetMajorVersion);DotnetRedistUrl=$(TgsDotnetRedistUrl);MariaDBRedistUrl=https://github.com/tgstation/tgstation-server/releases/download/tgstation-server-v$(TgsCoreVersion)/mariadb-$(TgsMariaDBRedistVersion)-winx64.msi</DefineConstants>
Expand All @@ -24,8 +24,8 @@
<Content Include="Theme.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.Bal.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.Netfx.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.Bal.wixext" Version="5.0.1" />
<PackageReference Include="WixToolset.Netfx.wixext" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tgstation.Server.Host.Service.Wix\Tgstation.Server.Host.Service.Wix.wixproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="WixToolset.Sdk/4.0.4">
<Project Sdk="WixToolset.Sdk/5.0.1">
<Import Project="../../../Common.props" />
<PropertyGroup>
<DefineConstants>ProductVersion=$(TgsCoreVersion)</DefineConstants>
Expand All @@ -25,8 +25,8 @@
</HarvestDirectory>
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.Heat" Version="4.0.4" />
<PackageReference Include="WixToolset.Util.wixext" Version="4.0.4" />
<PackageReference Include="WixToolset.Heat" Version="5.0.1" />
<PackageReference Include="WixToolset.Util.wixext" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tgstation.Server.Host.Service.Wix.Extensions\Tgstation.Server.Host.Service.Wix.Extensions.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public class DreamDaemonLaunchParameters
[Range(1, UInt16.MaxValue)]
public ushort? Port { get; set; }

/// <summary>
/// The port used by <see cref="EngineType.OpenDream"/> for its topic port.
/// </summary>
[Required]
[ResponseOptions]
public ushort? OpenDreamTopicPort { get; set; }

/// <summary>
/// The DreamDaemon startup timeout in seconds.
/// </summary>
Expand Down Expand Up @@ -109,8 +116,9 @@ public class DreamDaemonLaunchParameters
/// Check if we match a given set of <paramref name="otherParameters"/>. <see cref="StartupTimeout"/> is excluded.
/// </summary>
/// <param name="otherParameters">The <see cref="DreamDaemonLaunchParameters"/> to compare against.</param>
/// <param name="engineType">The <see cref="EngineType"/> currently running.</param>
/// <returns><see langword="true"/> if they match, <see langword="false"/> otherwise.</returns>
public bool CanApplyWithoutReboot(DreamDaemonLaunchParameters otherParameters)
public bool CanApplyWithoutReboot(DreamDaemonLaunchParameters otherParameters, EngineType engineType)
{
if (otherParameters == null)
throw new ArgumentNullException(nameof(otherParameters));
Expand All @@ -119,6 +127,7 @@ public bool CanApplyWithoutReboot(DreamDaemonLaunchParameters otherParameters)
&& SecurityLevel == otherParameters.SecurityLevel
&& Visibility == otherParameters.Visibility
&& Port == otherParameters.Port
&& (OpenDreamTopicPort == otherParameters.OpenDreamTopicPort || engineType != EngineType.OpenDream)
&& TopicRequestTimeout == otherParameters.TopicRequestTimeout
&& AdditionalParameters == otherParameters.AdditionalParameters
&& StartProfiler == otherParameters.StartProfiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public sealed class DreamDaemonResponse : DreamDaemonApiBase
[ResponseOptions]
public ushort? CurrentPort { get; set; }

/// <summary>
/// The <see cref="EngineType.OpenDream"/> topic port the running <see cref="DreamDaemonResponse"/> instance is set to.
/// </summary>
[ResponseOptions]
public ushort? CurrentTopicPort { get; set; }

/// <summary>
/// The webclient status the running <see cref="DreamDaemonResponse"/> instance is set to.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ async ValueTask VerifyApi(
{
AllowWebClient = false,
Port = portToUse,
OpenDreamTopicPort = 0,
SecurityLevel = securityLevel,
Visibility = DreamDaemonVisibility.Invisible,
StartupTimeout = timeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override string FormatServerArguments(

var parametersString = EncodeParameters(parameters, launchParameters);

var arguments = $"--cvar {(logFilePath != null ? $"log.path=\"{InstallationIOManager.GetDirectoryName(logFilePath)}\" --cvar log.format=\"{InstallationIOManager.GetFileName(logFilePath)}\"" : "log.enabled=false")} --cvar watchdog.token={accessIdentifier} --cvar log.runtimelog=false --cvar net.port={launchParameters.Port!.Value} --cvar opendream.topic_port=0 --cvar opendream.world_params=\"{parametersString}\" --cvar opendream.json_path=\"./{dmbProvider.DmbName}\"";
var arguments = $"--cvar {(logFilePath != null ? $"log.path=\"{InstallationIOManager.GetDirectoryName(logFilePath)}\" --cvar log.format=\"{InstallationIOManager.GetFileName(logFilePath)}\"" : "log.enabled=false")} --cvar watchdog.token={accessIdentifier} --cvar log.runtimelog=false --cvar net.port={launchParameters.Port!.Value} --cvar opendream.topic_port={launchParameters.OpenDreamTopicPort!.Value} --cvar opendream.world_params=\"{parametersString}\" --cvar opendream.json_path=\"./{dmbProvider.DmbName}\"";
return arguments;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,13 @@ public async ValueTask<bool> ChangeSettings(DreamDaemonLaunchParameters launchPa
{
using (await SemaphoreSlimContext.Lock(synchronizationSemaphore, cancellationToken))
{
bool match = launchParameters.CanApplyWithoutReboot(ActiveLaunchParameters);
var currentLaunchParameters = ActiveLaunchParameters;
ActiveLaunchParameters = launchParameters;
var currentEngine = GetActiveController()?.EngineVersion.Engine;
if (!currentEngine.HasValue)
return false;

bool match = launchParameters.CanApplyWithoutReboot(currentLaunchParameters, currentEngine.Value);
if (match || Status == WatchdogStatus.Offline || Status == WatchdogStatus.DelayedRestart)
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ bool CheckModified<T>(Expression<Func<Api.Models.Internal.DreamDaemonSettings, T
if (CheckModified(x => x.AllowWebClient, DreamDaemonRights.SetWebClient)
|| CheckModified(x => x.AutoStart, DreamDaemonRights.SetAutoStart)
|| CheckModified(x => x.Port, DreamDaemonRights.SetPort)
|| CheckModified(x => x.OpenDreamTopicPort, DreamDaemonRights.SetPort)
|| CheckModified(x => x.SecurityLevel, DreamDaemonRights.SetSecurity)
|| CheckModified(x => x.Visibility, DreamDaemonRights.SetVisibility)
|| (model.SoftRestart.HasValue && !ddRights.HasFlag(DreamDaemonRights.SoftRestart))
Expand Down Expand Up @@ -344,10 +345,12 @@ ValueTask<IActionResult> ReadImpl(DreamDaemonSettings? settings, bool knownForce
var rstate = dd.RebootState;
result.AutoStart = settings.AutoStart!.Value;
result.CurrentPort = llp?.Port!.Value;
result.CurrentTopicPort = llp?.OpenDreamTopicPort;
result.CurrentSecurity = llp?.SecurityLevel!.Value;
result.CurrentVisibility = llp?.Visibility!.Value;
result.CurrentAllowWebclient = llp?.AllowWebClient!.Value;
result.Port = settings.Port!.Value;
result.OpenDreamTopicPort = settings.OpenDreamTopicPort;
result.AllowWebClient = settings.AllowWebClient!.Value;

var firstIteration = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ public async ValueTask<IActionResult> GrantPermissions(long id, CancellationToke
AllowWebClient = false,
AutoStart = false,
Port = ddPort,
OpenDreamTopicPort = 0,
SecurityLevel = DreamDaemonSecurity.Safe,
Visibility = DreamDaemonVisibility.Public,
StartupTimeout = 60,
Expand Down
18 changes: 14 additions & 4 deletions src/Tgstation.Server.Host/Database/DatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,22 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
/// <summary>
/// Used by unit tests to remind us to setup the correct MSSQL migration downgrades.
/// </summary>
internal static readonly Type MSLatestMigration = typeof(MSAddCronAutoUpdates);
internal static readonly Type MSLatestMigration = typeof(MSAddOpenDreamTopicPort);

/// <summary>
/// Used by unit tests to remind us to setup the correct MYSQL migration downgrades.
/// </summary>
internal static readonly Type MYLatestMigration = typeof(MYAddCronAutoUpdates);
internal static readonly Type MYLatestMigration = typeof(MYAddOpenDreamTopicPort);

/// <summary>
/// Used by unit tests to remind us to setup the correct PostgresSQL migration downgrades.
/// </summary>
internal static readonly Type PGLatestMigration = typeof(PGAddCronAutoUpdates);
internal static readonly Type PGLatestMigration = typeof(PGAddOpenDreamTopicPort);

/// <summary>
/// Used by unit tests to remind us to setup the correct SQLite migration downgrades.
/// </summary>
internal static readonly Type SLLatestMigration = typeof(SLAddCronAutoUpdates);
internal static readonly Type SLLatestMigration = typeof(SLAddOpenDreamTopicPort);

/// <inheritdoc />
#pragma warning disable CA1502 // Cyclomatic complexity
Expand Down Expand Up @@ -419,6 +419,16 @@ public async ValueTask SchemaDowngradeForServerVersion(

string BadDatabaseType() => throw new ArgumentException($"Invalid DatabaseType: {currentDatabaseType}", nameof(currentDatabaseType));

if (targetVersion < new Version(6, 7, 0))
targetMigration = currentDatabaseType switch
{
DatabaseType.MySql => nameof(MSAddCronAutoUpdates),
DatabaseType.PostgresSql => nameof(PGAddCronAutoUpdates),
DatabaseType.SqlServer => nameof(MSAddCronAutoUpdates),
DatabaseType.Sqlite => nameof(SLAddCronAutoUpdates),
_ => BadDatabaseType(),
};

if (targetVersion < new Version(6, 6, 0))
targetMigration = currentDatabaseType switch
{
Expand Down
Loading
Loading