From e9008e74a1e655718b3f03c9d955c2085779bb5f Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 28 Sep 2022 06:08:28 -0400 Subject: [PATCH 1/7] Add a way to skip the BYOND firewall exemption step with config --- build/Version.props | 4 +-- .../Components/Byond/WindowsByondInstaller.cs | 28 +++++++++++++++---- .../Configuration/GeneralConfiguration.cs | 7 ++++- src/Tgstation.Server.Host/appsettings.yml | 1 + .../Instance/ByondTest.cs | 6 ++++ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/build/Version.props b/build/Version.props index a53842da56..d41f9edf3b 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,8 +3,8 @@ - 5.0.4 - 4.2.0 + 5.0.5 + 4.3.0 9.6.0 9.6.1 10.7.1 diff --git a/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs b/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs index 2368aa2af6..678e12347f 100644 --- a/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs @@ -1,11 +1,14 @@ using System; +using System.Collections.Generic; using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Tgstation.Server.Api.Models; +using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Core; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; @@ -55,6 +58,11 @@ namespace Tgstation.Server.Host.Components.Byond /// readonly IProcessExecutor processExecutor; + /// + /// The for the . + /// + readonly GeneralConfiguration generalConfiguration; + /// /// The for the . /// @@ -69,12 +77,14 @@ namespace Tgstation.Server.Host.Components.Byond /// Initializes a new instance of the class. /// /// The value of . + /// The containing the value of . /// The for the . /// The for the . - public WindowsByondInstaller(IProcessExecutor processExecutor, IIOManager ioManager, ILogger logger) + public WindowsByondInstaller(IProcessExecutor processExecutor, IIOManager ioManager, IOptions generalConfigurationOptions, ILogger logger) : base(ioManager, logger) { this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor)); + generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); PathToUserByondFolder = IOManager.ResolvePath(IOManager.ConcatPath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "BYOND")); @@ -87,10 +97,18 @@ namespace Tgstation.Server.Host.Components.Byond /// public override Task InstallByond(string path, Version version, CancellationToken cancellationToken) - => Task.WhenAll( + { + var tasks = new List + { SetNoPromptTrusted(path, cancellationToken), InstallDirectX(path, cancellationToken), - AddDreamDaemonToFirewall(path, cancellationToken)); + }; + + if (!generalConfiguration.SkipAddingByondFirewallException) + tasks.Add(AddDreamDaemonToFirewall(path, cancellationToken)); + + return Task.WhenAll(tasks); + } /// /// Creates the BYOND cfg file that prevents the trusted mode dialog from appearing when launching DreamDaemon. @@ -104,7 +122,7 @@ namespace Tgstation.Server.Host.Components.Byond await IOManager.CreateDirectory(configPath, cancellationToken); var configFilePath = IOManager.ConcatPath(configPath, ByondDreamDaemonConfigFilename); - Logger.LogTrace("Disabling trusted prompts in {0}...", configFilePath); + Logger.LogTrace("Disabling trusted prompts in {configFilePath}...", configFilePath); await IOManager.WriteAllBytes( configFilePath, Encoding.UTF8.GetBytes(ByondNoPromptTrustedMode), @@ -186,7 +204,7 @@ namespace Tgstation.Server.Host.Components.Byond cancellationToken.ThrowIfCancellationRequested(); Logger.LogDebug( - "netsh.exe output:{0}{1}", + "netsh.exe output:{newLine}{output}", Environment.NewLine, await netshProcess.GetCombinedOutput(cancellationToken)); diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs index d7a1a91f06..7be48930ed 100644 --- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs @@ -111,6 +111,11 @@ namespace Tgstation.Server.Host.Configuration /// public bool HostApiDocumentation { get; set; } + /// + /// If the netsh.exe execution to exempt DreamDaemon from Windows firewall should be skipped. + /// + public bool SkipAddingByondFirewallException { get; set; } + /// /// Initializes a new instance of the class. /// @@ -133,7 +138,7 @@ namespace Tgstation.Server.Host.Configuration if (ConfigVersion == null) logger.LogCritical( - "No `ConfigVersion` specified, your configuration may be out of date! The current version is \"{0}\"", + "No `ConfigVersion` specified, your configuration may be out of date! The current version is \"{currentVersion}\"", CurrentConfigVersion); else if (ConfigVersion != CurrentConfigVersion) if (ConfigVersion.Major != CurrentConfigVersion.Major) diff --git a/src/Tgstation.Server.Host/appsettings.yml b/src/Tgstation.Server.Host/appsettings.yml index ebab1c2470..3fb8ebb675 100644 --- a/src/Tgstation.Server.Host/appsettings.yml +++ b/src/Tgstation.Server.Host/appsettings.yml @@ -11,6 +11,7 @@ General: InstanceLimit: 10 ValidInstancePaths: HostApiDocumentation: false + SkipAddingByondFirewallException: false Session: HighPriorityLiveDreamDaemon: false LowPriorityDeploymentProcesses: true diff --git a/tests/Tgstation.Server.Tests/Instance/ByondTest.cs b/tests/Tgstation.Server.Tests/Instance/ByondTest.cs index a1dc699d70..db83ca4ad3 100644 --- a/tests/Tgstation.Server.Tests/Instance/ByondTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/ByondTest.cs @@ -1,5 +1,6 @@ using Castle.Core.Logging; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using System; @@ -13,6 +14,7 @@ using Tgstation.Server.Api.Models.Request; using Tgstation.Server.Client; using Tgstation.Server.Client.Components; using Tgstation.Server.Host.Components.Byond; +using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; @@ -87,10 +89,14 @@ namespace Tgstation.Server.Tests.Instance async Task TestCustomInstalls(CancellationToken cancellationToken) { + var generalConfigOptionsMock = new Mock>(); + generalConfigOptionsMock.SetupGet(x => x.Value).Returns(new GeneralConfiguration()); + var byondInstaller = new PlatformIdentifier().IsWindows ? (IByondInstaller)new WindowsByondInstaller( Mock.Of(), new DefaultIOManager(new AssemblyInformationProvider()), + generalConfigOptionsMock.Object, Mock.Of>()) : new PosixByondInstaller( Mock.Of(), From cf83e8e25029653a1425beeecdfd092d67afa0b5 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 28 Sep 2022 06:15:40 -0400 Subject: [PATCH 2/7] We're on 5.0.4 --- build/Version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Version.props b/build/Version.props index d41f9edf3b..121bb486aa 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 5.0.5 + 5.0.4 4.3.0 9.6.0 9.6.1 From 596caba3019bf4a56dcf730ba61f831e029b7b37 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 28 Sep 2022 06:23:22 -0400 Subject: [PATCH 3/7] Possible fix for test merge deployments --- src/Tgstation.Server.Host/Components/Repository/Repository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index 4d20f4be52..f2d808bfc0 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -196,7 +196,7 @@ namespace Tgstation.Server.Host.Components.Repository var commitMessage = String.Format( CultureInfo.InvariantCulture, - "TGS Test merge #{0}{1}{2}", + "TGS Test Merge (#{0}){1}{2}", testMergeParameters.Number, testMergeParameters.Comment != null ? Environment.NewLine From f186d6a62642547d1b1bcb928101d57c6c66849c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 28 Sep 2022 13:44:45 -0400 Subject: [PATCH 4/7] Fix !tgs not working on Discord --- .../Components/Chat/Providers/DiscordProvider.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 57125c0e1d..5067aac312 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -529,7 +529,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers lock (mappedChannels) shouldNotAnswer = !mappedChannels.Contains(messageCreateEvent.ChannelID.Value); - var content = NormalizeMentions(messageCreateEvent.Content); + var refreshedMessage = !String.IsNullOrWhiteSpace(messageCreateEvent.Content) + ? messageCreateEvent + : (await channelsClient.GetChannelMessageAsync(messageCreateEvent.ChannelID, messageCreateEvent.ID, cancellationToken)).Entity; + var content = NormalizeMentions(refreshedMessage.Content); var mentionedUs = messageCreateEvent.Mentions.Any(x => x.ID == currentUserId) || (!shouldNotAnswer && content.Split(' ').First().Equals(ChatManager.CommonMention, StringComparison.OrdinalIgnoreCase)); From 0f7aced259918c65f848cc7eae28c1b53a4094a1 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 28 Sep 2022 13:45:27 -0400 Subject: [PATCH 5/7] Fix channel 0 not mapping for commands on Discord --- .../Components/Chat/Providers/DiscordProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 5067aac312..f89d57e9f1 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -527,7 +527,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var shouldNotAnswer = !pm; if (shouldNotAnswer) lock (mappedChannels) - shouldNotAnswer = !mappedChannels.Contains(messageCreateEvent.ChannelID.Value); + shouldNotAnswer = !mappedChannels.Contains(messageCreateEvent.ChannelID.Value) && !mappedChannels.Contains(0); var refreshedMessage = !String.IsNullOrWhiteSpace(messageCreateEvent.Content) ? messageCreateEvent