diff --git a/.dockerignore b/.dockerignore index 0a5c0e76af..018b718239 100644 --- a/.dockerignore +++ b/.dockerignore @@ -12,18 +12,12 @@ appveyor.yml omnisharp.json README.md - -build/** -!build/analyzers.ruleset -!build/tgs.docker.sh -!build/tgs.ico -!build/tgs.png -!build/stylecop.json -!build/Version.props -!build/ControlPanelVersion.props -!build/Common.props -!build/NugetCommon.props -!build/uac_elevation_manifest.xml +build/package/** +build/coverlet.runsettings +build/Dockerfile +build/GenerateMigrations.sh +build/OpenApiValidationSettings.json +build/tgstation-server.service docs src/DMAPI src/Tgstation.Server.Host/ClientApp diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6f4a8cdab8..d8b62ead67 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -74,8 +74,9 @@ If you don't plan on deploying TGS, the following secrets can be omitted: - Secret `DOCKER_USERNAME`: Login username for Docker image push. - Secret `DOCKER_PASSWORD`: Login password for Docker image push. - Secret `NUGET_API_KEY`: Nuget.org API Key for client libraries push. -- Secret `CODE_SIGNING_BASE64`: Base64 string of a .pfx file containing a Windows code-signing certificate. +- Secret `CODE_SIGNING_BASE64`: Base64 string of a .pfx file containing an X.509 code-signing certificate. - Secret `CODE_SIGNING_PASSWORD`: Password for importing the above .pfx. +- Variable `CODE_SIGNING_THUMBPRINT`: Thumbprint for the above .pfx ### Know your Code diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 273317b8ea..0da4e45b60 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -1140,10 +1140,10 @@ jobs: run: dotnet restore - name: Build ReleaseNotes - run: dotnet build -c Release tools/ReleaseNotes/ReleaseNotes.csproj + run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj - name: Run ReleaseNotes Check - run: dotnet run -c Release --no-build --project tools/ReleaseNotes --winget-template-check ${{ steps.get-sha.outputs.pr_template_sha }} + run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --winget-template-check ${{ steps.get-sha.outputs.pr_template_sha }} ci-completion-gate: # This job exists so there isn't a moving target for branch protections name: CI Completion Gate @@ -1304,10 +1304,10 @@ jobs: run: dotnet restore - name: Build ReleaseNotes - run: dotnet build -c Release tools/ReleaseNotes/ReleaseNotes.csproj + run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj - name: Run ReleaseNotes with --ensure-release - run: dotnet run -c Release --no-build --project tools/ReleaseNotes --ensure-release + run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --ensure-release deploy-tgs: name: Deploy TGS @@ -1332,7 +1332,7 @@ jobs: dotnet tool restore - name: Build ReleaseNotes - run: dotnet build -c Release tools/ReleaseNotes/ReleaseNotes.csproj + run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj # We need to rebuild the installer.exe so it can be properly signed - name: Restore @@ -1422,7 +1422,7 @@ jobs: &"C:/Program Files/7-Zip/7z.exe" a ServerUpdatePackage.zip ./ServerUpdatePackage/* -tzip - name: Generate Release Notes - run: dotnet run -c Release --no-build --project tools/ReleaseNotes ${{ env.TGS_VERSION }} + run: dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes ${{ env.TGS_VERSION }} - name: Create GitHub Release uses: actions/create-release@v1 @@ -1571,7 +1571,7 @@ jobs: uses: actions/checkout@v3 - name: Build ReleaseNotes - run: dotnet build -c Release tools/ReleaseNotes + run: dotnet build -c Release tools/Tgstation.Server.ReleaseNotes - name: Execute Push Script shell: powershell @@ -1581,4 +1581,4 @@ jobs: shell: powershell run: | Sleep 15 - dotnet run -c Release --no-build --project tools/ReleaseNotes --link-winget ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + dotnet run -c Release --no-build --project tools/Tgstation.Server.ReleaseNotes --link-winget ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/.gitignore b/.gitignore index a53f0d523d..d7756e60cd 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,8 @@ artifacts/ /src/Tgstation.Server.Host/wwwroot /src/Tgstation.Server.Host/--applicationName /src/Tgstation.Server.Host/ClientApp -/tools/ReleaseNotes/release_notes.md -/tools/ReleaseNotes/Properties/launchSettings.json +/tools/Tgstation.Server.ReleaseNotes/release_notes.md +launchSettings.json release_notes.md *nupkg *.sqlite3 diff --git a/README.md b/README.md index 1ad767815e..bb49a83e4c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Follow the instructions for your OS below. ###### Note about Digital Signatures -Note that the Windows Service and installer executables requires administrative privileges. These are digitally signed against the Root CA managed by [Jordan Dominion](https://github.com/Cyberboss). Consider installing the certificate into your `Trusted Root Authorities` store for cleaner UAC prompts. The certificate can be downloaded [here](https://file.house/zpFb.cer), please validate the thumbprint is `70176acf7ffa2898fa5b5cd6e38b43b38ea5d07f` before installing. +Note that the Windows Service and installer executables require administrative privileges. These are digitally signed against the Root CA managed by [Jordan Dominion](https://github.com/Cyberboss). Consider installing the certificate into your `Trusted Root Authorities` store for cleaner UAC prompts. The certificate can be downloaded [here](https://file.house/zpFb.cer), please validate the thumbprint is `70176acf7ffa2898fa5b5cd6e38b43b38ea5d07f` before installing. The OCSP server for this is `http://ocsp.dextraspace.net`. ##### winget (Windows 10 or later) @@ -252,17 +252,19 @@ Create an `appsettings.Production.yml` file next to `appsettings.yml`. This will Password: yourpasshere ``` -- `Swarm`: This section should be left `null` unless using the server swarm system. If this is to happen, ensure all swarm servers are set to connect to the same database. +- `Swarm`: This section should be left empty unless using the server swarm system. If this is to happen, ensure all swarm servers are set to connect to the same database. -- `Swarm:PrivateKey`: Should be a secure string set identically on all swarmed servers. +- `Swarm:PrivateKey`: Must be a secure string set identically on all swarmed servers. -- `Swarm:ControllerAddress`: Should be set on all swarmed servers that are **not** the controller server and should be an address the controller server may be reached at. +- `Swarm:ControllerAddress`: Must be set on all swarmed servers that are **not** the controller server and should be an address the controller server may be reached at. -- `Swarm:Address`: Should be set on all swarmed servers. Should be an address the server can be reached at by other servers in the swarm. +- `Swarm:Address`: Must be set on all swarmed servers. Should be an address the server can be reached at by other servers in the swarm. -- `Swarm:Identifier` should be set uniquely on all swarmed servers. Used to identify the current server. This is also used to select which instances exist on the current machine and should not be changed post-setup. +- `Swarm:PublicAddress`: Should be set on all swarmed servers. Should be an address the server can be reached at by other servers in the swarm. -- `Swarm:UpdateRequiredNodeCount` should be set to the total number of servers in your swarm, minus the controller. Prevents updates from occurring unless the non-controller server count in the swarm is greater than or equal to this value. +- `Swarm:Identifier`: Must be set uniquely on all swarmed servers. Used to identify the current server. This is also used to select which instances exist on the current machine and should not be changed post-setup. + +- `Swarm:UpdateRequiredNodeCount`: Should be set to the total number of servers in your swarm minus 1. Prevents updates from occurring unless the non-controller server count in the swarm is greater than or equal to this value. - `Security:OAuth:`: Sets the OAuth client ID and secret for a given ``. The currently supported providers are `Keycloak`, `GitHub`, `Discord`, `InvisionCommunity` and `TGForums`. Setting these fields to `null` disables logins with the provider, but does not stop users from associating their accounts using the API. Sample Entry: ```yml diff --git a/build/Common.props b/build/Common.props index 89b88f109b..c081f2e0d7 100644 --- a/build/Common.props +++ b/build/Common.props @@ -3,7 +3,6 @@ net$(TgsNetMajorVersion).0 - netstandard2.0 latest Full diff --git a/build/Dockerfile b/build/Dockerfile index 06b9ea71ae..39e392ca57 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -29,6 +29,7 @@ COPY build/Common.props Common.props COPY build/NugetCommon.props NugetCommon.props COPY build/Version.props Version.props COPY build/ControlPanelVersion.props ControlPanelVersion.props +COPY build/SrcCommon.props SrcCommon.props WORKDIR /repo/src/Tgstation.Server.Host diff --git a/build/NugetCommon.props b/build/NugetCommon.props index 886f98c028..6f2600ccd3 100644 --- a/build/NugetCommon.props +++ b/build/NugetCommon.props @@ -1,9 +1,9 @@ - + true - Cyberboss/Dominion + Jordan Dominion /tg/station 13 https://tgstation.github.io/tgstation-server LICENSE diff --git a/build/SrcCommon.props b/build/SrcCommon.props new file mode 100644 index 0000000000..fb1f8c29d5 --- /dev/null +++ b/build/SrcCommon.props @@ -0,0 +1,30 @@ + + + + + true + false + true + ../../build/analyzers.ruleset + true + bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml + + + + true + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/build/TestCommon.props b/build/TestCommon.props new file mode 100644 index 0000000000..50ad972952 --- /dev/null +++ b/build/TestCommon.props @@ -0,0 +1,19 @@ + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/build/Version.props b/build/Version.props index 84803c354f..d58023e462 100644 --- a/build/Version.props +++ b/build/Version.props @@ -15,6 +15,7 @@ 1.2.1 1.0.2 6 + netstandard2.0 https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/6.0.19/dotnet-hosting-6.0.19-win.exe diff --git a/build/analyzers.ruleset b/build/analyzers.ruleset index 2699bd4001..365db1e57f 100644 --- a/build/analyzers.ruleset +++ b/build/analyzers.ruleset @@ -1,5 +1,5 @@  - + @@ -1026,8 +1026,8 @@ - - + + diff --git a/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs b/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs index 02a90bdc43..74c84ca711 100644 --- a/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs +++ b/build/package/winget/Tgstation.Server.Host.Service.Wix.Extensions/InstallationExtensions.cs @@ -1,4 +1,4 @@ -namespace Tgstation.Server.Host.Service.Wix.SafeShutdown +namespace Tgstation.Server.Host.Service.Wix.Extensions { using System; using System.ServiceProcess; @@ -28,21 +28,21 @@ session.Log("Begin DetachStopTgsServiceIfRunning"); ServiceController serviceController = null; - session.Log($"Searching for {Constants.CanonicalPackageName} service..."); - foreach (var controller in ServiceController.GetServices()) - if (controller.ServiceName == Constants.CanonicalPackageName) - { - serviceController = controller; - break; - } - else - controller.Dispose(); - - using (serviceController) + // As much as I'd like to use Tgstation.Server.Common.Constants.CanonicalPackageName here, attempting to reference it make Tgstation.Server.Migrator.Comms fail due to referencing the net2.0 version of that library. EVEN THOUGH IT'S A TRANSITIVE DEPENDENCY OF Tgstation.Server.Client!!!!! + // If that dead-ass tool has been removed, feel free to do this + const string CanonicalPackageName = "tgstation-server"; + session.Log($"Searching for {CanonicalPackageName} service..."); + try { + foreach (var controller in ServiceController.GetServices()) + if (controller.ServiceName == CanonicalPackageName) + serviceController = controller; + else + controller.Dispose(); + if (serviceController == null || serviceController.Status != ServiceControllerStatus.Running) { - session.Log($"{Constants.CanonicalPackageName} service not found. Continuing."); + session.Log($"{CanonicalPackageName} service not found. Continuing."); return ActionResult.Success; } @@ -50,21 +50,25 @@ PipeCommands.CommandDetachingShutdown) .Value; - session.Log($"{Constants.CanonicalPackageName} service found. Sending command \"{PipeCommands.CommandDetachingShutdown}\" ({commandId})..."); + session.Log($"{CanonicalPackageName} service found. Sending command \"{PipeCommands.CommandDetachingShutdown}\" ({commandId})..."); serviceController.ExecuteCommand(commandId); - session.Log($"Command sent. Waiting for {Constants.CanonicalPackageName} service to stop..."); + session.Log($"Command sent. Waiting for {CanonicalPackageName} service to stop..."); serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMinutes(1)); var stopped = serviceController.Status == ServiceControllerStatus.Stopped; - session.Log($"{Constants.CanonicalPackageName} stopped {(stopped ? String.Empty : "un")}successfully."); + session.Log($"{CanonicalPackageName} stopped {(stopped ? String.Empty : "un")}successfully."); return stopped ? ActionResult.Success : ActionResult.NotExecuted; } + finally + { + serviceController?.Dispose(); + } } catch (Exception ex) { diff --git a/build/package/winget/Tgstation.Server.Host.Service.Wix/Package.en-us.wxl b/build/package/winget/Tgstation.Server.Host.Service.Wix/Package.en-us.wxl index b1675c9c30..1113dfdeee 100644 --- a/build/package/winget/Tgstation.Server.Host.Service.Wix/Package.en-us.wxl +++ b/build/package/winget/Tgstation.Server.Host.Service.Wix/Package.en-us.wxl @@ -3,7 +3,7 @@ This file contains the declaration of all the localizable strings. --> - + diff --git a/build/stylecop.json b/build/stylecop.json index bc19a81992..d18cd8693c 100644 --- a/build/stylecop.json +++ b/build/stylecop.json @@ -1,4 +1,5 @@ { + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "settings": { "documentationRules": { "documentPrivateElements": true, @@ -33,6 +34,13 @@ "accessibility" ], "usingDirectivesPlacement": "outsideNamespace" + }, + "namingRules": { + "allowCommonHungarianPrefixes": false, + "includeInferredTupleElementNames": true + }, + "readabilityRules": { + "allowBuiltInTypeAliases": true } } } diff --git a/src/Tgstation.Server.Api/ApiHeaders.cs b/src/Tgstation.Server.Api/ApiHeaders.cs index c8a3093c78..7dc1d79e7e 100644 --- a/src/Tgstation.Server.Api/ApiHeaders.cs +++ b/src/Tgstation.Server.Api/ApiHeaders.cs @@ -124,7 +124,8 @@ namespace Tgstation.Server.Api /// The value of . /// The value of . /// The value of . - public ApiHeaders(ProductHeaderValue userAgent, string token, OAuthProvider? oauthProvider = null) : this(userAgent, token, null, null) + public ApiHeaders(ProductHeaderValue userAgent, string token, OAuthProvider? oauthProvider = null) + : this(userAgent, token, null, null) { if (userAgent == null) throw new ArgumentNullException(nameof(userAgent)); @@ -140,7 +141,8 @@ namespace Tgstation.Server.Api /// The value of . /// The value of . /// The value of . - public ApiHeaders(ProductHeaderValue userAgent, string username, string password) : this(userAgent, null, username, password) + public ApiHeaders(ProductHeaderValue userAgent, string username, string password) + : this(userAgent, null, username, password) { if (userAgent == null) throw new ArgumentNullException(nameof(userAgent)); diff --git a/src/Tgstation.Server.Api/HeadersException.cs b/src/Tgstation.Server.Api/HeadersException.cs index 62bce1433b..6287ee1c88 100644 --- a/src/Tgstation.Server.Api/HeadersException.cs +++ b/src/Tgstation.Server.Api/HeadersException.cs @@ -17,7 +17,8 @@ namespace Tgstation.Server.Api /// /// The value of . /// The error message. - public HeadersException(HeaderTypes missingOrMalformedHeaders, string message) : base(message) + public HeadersException(HeaderTypes missingOrMalformedHeaders, string message) + : base(message) { MissingOrMalformedHeaders = missingOrMalformedHeaders; } @@ -33,7 +34,8 @@ namespace Tgstation.Server.Api /// Initializes a new instance of the class. /// /// The error message. - public HeadersException(string message) : base(message) + public HeadersException(string message) + : base(message) { } @@ -42,7 +44,8 @@ namespace Tgstation.Server.Api /// /// The error message. /// The inner for the base . - public HeadersException(string message, Exception innerException) : base(message, innerException) + public HeadersException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Api/Models/ErrorCode.cs b/src/Tgstation.Server.Api/Models/ErrorCode.cs index 23f8be21af..1ca26752ee 100644 --- a/src/Tgstation.Server.Api/Models/ErrorCode.cs +++ b/src/Tgstation.Server.Api/Models/ErrorCode.cs @@ -1,6 +1,8 @@ using System; using System.ComponentModel; +using Tgstation.Server.Common; + namespace Tgstation.Server.Api.Models { /// @@ -60,7 +62,7 @@ namespace Tgstation.Server.Api.Models /// /// Attempted to change to a major version less than 4. /// - [Description("Cannot downgrade to tgstation-server major version <4!")] + [Description($"Cannot downgrade to {Constants.CanonicalPackageName} major version <4!")] CannotChangeServerSuite, /// diff --git a/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs b/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs index 8ce9873fce..4dfb80287b 100644 --- a/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs +++ b/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs @@ -14,6 +14,11 @@ namespace Tgstation.Server.Api.Models.Internal [Required] public virtual Uri? Address { get; set; } + /// + /// The address the swarm server can be publically accessed. + /// + public virtual Uri? PublicAddress { get; set; } + /// /// The server's identifier. /// diff --git a/src/Tgstation.Server.Api/Models/UserName.cs b/src/Tgstation.Server.Api/Models/UserName.cs index c5d5f30604..779f951916 100644 --- a/src/Tgstation.Server.Api/Models/UserName.cs +++ b/src/Tgstation.Server.Api/Models/UserName.cs @@ -24,7 +24,8 @@ /// /// The child of to create. /// A new copied from . - protected virtual TResultType CreateUserName() where TResultType : UserName, new() => new TResultType + protected virtual TResultType CreateUserName() + where TResultType : UserName, new() => new TResultType { Id = Id, Name = Name, diff --git a/src/Tgstation.Server.Api/Rights/RightsHelper.cs b/src/Tgstation.Server.Api/Rights/RightsHelper.cs index 8860391110..eb33954a48 100644 --- a/src/Tgstation.Server.Api/Rights/RightsHelper.cs +++ b/src/Tgstation.Server.Api/Rights/RightsHelper.cs @@ -38,7 +38,8 @@ namespace Tgstation.Server.Api.Rights /// The . /// The . /// A representing the claim role name. - public static string RoleNames(TRight right) where TRight : Enum + public static string RoleNames(TRight right) + where TRight : Enum { IEnumerable GetRoleNames() { @@ -75,7 +76,8 @@ namespace Tgstation.Server.Api.Rights /// /// The . /// All rights for the given . - public static TRight AllRights() where TRight : Enum + public static TRight AllRights() + where TRight : Enum { ulong rights = 0; foreach (Enum right in Enum.GetValues(typeof(TRight))) @@ -91,7 +93,8 @@ namespace Tgstation.Server.Api.Rights /// The . /// The s to clamp. /// The clamped . - public static TRight Clamp(TRight rights) where TRight : Enum + public static TRight Clamp(TRight rights) + where TRight : Enum { var allRights = AllRights(); diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj index 2018f93dfe..913f4db126 100644 --- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj +++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj @@ -2,22 +2,14 @@ - $(TgsNugetNetVersion) + $(TgsNugetNetFramework) $(TgsApiLibraryVersion) API definitions for tgstation-server. json web api tgstation-server tgstation ss13 byond http Added support for -map-threads DreamDaemon parameter and UploadZip Administration update option. - true - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml CA1028 - - true - - - @@ -36,11 +28,6 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/Tgstation.Server.Client/ApiClient.cs b/src/Tgstation.Server.Client/ApiClient.cs index ae10ac62af..939fdb2dc8 100644 --- a/src/Tgstation.Server.Client/ApiClient.cs +++ b/src/Tgstation.Server.Client/ApiClient.cs @@ -168,55 +168,78 @@ namespace Tgstation.Server.Client } /// - public Task Create(string route, CancellationToken cancellationToken) => RunRequest(route, new object(), HttpMethod.Put, null, false, cancellationToken); + public Task Create(string route, CancellationToken cancellationToken) + => RunRequest(route, new object(), HttpMethod.Put, null, false, cancellationToken); /// - public Task Read(string route, CancellationToken cancellationToken) => RunRequest(route, null, HttpMethod.Get, null, false, cancellationToken); + public Task Read(string route, CancellationToken cancellationToken) + => RunRequest(route, null, HttpMethod.Get, null, false, cancellationToken); /// - public Task Update(string route, CancellationToken cancellationToken) => RunRequest(route, new object(), HttpMethod.Post, null, false, cancellationToken); + public Task Update(string route, CancellationToken cancellationToken) + => RunRequest(route, new object(), HttpMethod.Post, null, false, cancellationToken); /// - public Task Update(string route, TBody body, CancellationToken cancellationToken) where TBody : class => RunRequest(route, body, HttpMethod.Post, null, false, cancellationToken); + public Task Update(string route, TBody body, CancellationToken cancellationToken) + where TBody : class + => RunRequest(route, body, HttpMethod.Post, null, false, cancellationToken); /// public Task Patch(string route, CancellationToken cancellationToken) => RunRequest(route, null, HttpPatch, null, false, cancellationToken); /// - public Task Update(string route, TBody body, CancellationToken cancellationToken) where TBody : class => RunRequest(route, body, HttpMethod.Post, null, false, cancellationToken); + public Task Update(string route, TBody body, CancellationToken cancellationToken) + where TBody : class + => RunRequest(route, body, HttpMethod.Post, null, false, cancellationToken); /// - public Task Create(string route, TBody body, CancellationToken cancellationToken) where TBody : class => RunRequest(route, body, HttpMethod.Put, null, false, cancellationToken); + public Task Create(string route, TBody body, CancellationToken cancellationToken) + where TBody : class + => RunRequest(route, body, HttpMethod.Put, null, false, cancellationToken); /// - public Task Delete(string route, CancellationToken cancellationToken) => RunRequest(route, null, HttpMethod.Delete, null, false, cancellationToken); + public Task Delete(string route, CancellationToken cancellationToken) + => RunRequest(route, null, HttpMethod.Delete, null, false, cancellationToken); /// - public Task Create(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest(route, body, HttpMethod.Put, instanceId, false, cancellationToken); + public Task Create(string route, TBody body, long instanceId, CancellationToken cancellationToken) + where TBody : class + => RunRequest(route, body, HttpMethod.Put, instanceId, false, cancellationToken); /// - public Task Read(string route, long instanceId, CancellationToken cancellationToken) => RunRequest(route, null, HttpMethod.Get, instanceId, false, cancellationToken); + public Task Read(string route, long instanceId, CancellationToken cancellationToken) + => RunRequest(route, null, HttpMethod.Get, instanceId, false, cancellationToken); /// - public Task Update(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest(route, body, HttpMethod.Post, instanceId, false, cancellationToken); + public Task Update(string route, TBody body, long instanceId, CancellationToken cancellationToken) + where TBody : class + => RunRequest(route, body, HttpMethod.Post, instanceId, false, cancellationToken); /// - public Task Delete(string route, long instanceId, CancellationToken cancellationToken) => RunRequest(route, null, HttpMethod.Delete, instanceId, false, cancellationToken); + public Task Delete(string route, long instanceId, CancellationToken cancellationToken) + => RunRequest(route, null, HttpMethod.Delete, instanceId, false, cancellationToken); /// - public Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest(route, body, HttpMethod.Delete, instanceId, false, cancellationToken); + public Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) + where TBody : class + => RunRequest(route, body, HttpMethod.Delete, instanceId, false, cancellationToken); /// - public Task Delete(string route, long instanceId, CancellationToken cancellationToken) => RunRequest(route, null, HttpMethod.Delete, instanceId, false, cancellationToken); + public Task Delete(string route, long instanceId, CancellationToken cancellationToken) + => RunRequest(route, null, HttpMethod.Delete, instanceId, false, cancellationToken); /// - public Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest(route, body, HttpMethod.Delete, instanceId, false, cancellationToken); + public Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) + where TBody : class + => RunRequest(route, body, HttpMethod.Delete, instanceId, false, cancellationToken); /// - public Task Create(string route, long instanceId, CancellationToken cancellationToken) => RunRequest(route, new object(), HttpMethod.Put, instanceId, false, cancellationToken); + public Task Create(string route, long instanceId, CancellationToken cancellationToken) + => RunRequest(route, new object(), HttpMethod.Put, instanceId, false, cancellationToken); /// - public Task Patch(string route, long instanceId, CancellationToken cancellationToken) => RunRequest(route, new object(), HttpPatch, instanceId, false, cancellationToken); + public Task Patch(string route, long instanceId, CancellationToken cancellationToken) + => RunRequest(route, new object(), HttpPatch, instanceId, false, cancellationToken); /// public void AddRequestLogger(IRequestLogger requestLogger) => requestLoggers.Add(requestLogger ?? throw new ArgumentNullException(nameof(requestLogger))); diff --git a/src/Tgstation.Server.Client/ApiConflictException.cs b/src/Tgstation.Server.Client/ApiConflictException.cs index 02dd82ea94..52ec9b4eb2 100644 --- a/src/Tgstation.Server.Client/ApiConflictException.cs +++ b/src/Tgstation.Server.Client/ApiConflictException.cs @@ -15,7 +15,8 @@ namespace Tgstation.Server.Client /// /// The for the . /// The for the . - public ApiConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage) + public ApiConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base(errorMessage, responseMessage) { } @@ -30,7 +31,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public ApiConflictException(string message) : base(message) + public ApiConflictException(string message) + : base(message) { } @@ -39,7 +41,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public ApiConflictException(string message, Exception innerException) : base(message, innerException) + public ApiConflictException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/ApiException.cs b/src/Tgstation.Server.Client/ApiException.cs index 3a90907254..f041a869cf 100644 --- a/src/Tgstation.Server.Client/ApiException.cs +++ b/src/Tgstation.Server.Client/ApiException.cs @@ -31,9 +31,10 @@ namespace Tgstation.Server.Client /// /// The returned from the API. /// The . - protected ApiException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base( - responseMessage, - errorMessage?.Message ?? $"HTTP {responseMessage?.StatusCode ?? throw new ArgumentNullException(nameof(responseMessage))}. Unknown API error, ErrorMessage payload not present!") + protected ApiException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base( + responseMessage, + errorMessage?.Message ?? $"HTTP {responseMessage?.StatusCode ?? throw new ArgumentNullException(nameof(responseMessage))}. Unknown API error, ErrorMessage payload not present!") { ServerApiVersion = errorMessage?.ServerApiVersion; AdditionalServerData = errorMessage?.AdditionalData; @@ -45,9 +46,8 @@ namespace Tgstation.Server.Client /// /// The . /// The . - protected ApiException(HttpResponseMessage responseMessage, string message) : base( - responseMessage, - message) + protected ApiException(HttpResponseMessage responseMessage, string message) + : base(responseMessage, message) { } @@ -62,7 +62,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - protected ApiException(string message) : base(message) + protected ApiException(string message) + : base(message) { } @@ -71,7 +72,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - protected ApiException(string message, Exception innerException) : base(message, innerException) + protected ApiException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/ClientException.cs b/src/Tgstation.Server.Client/ClientException.cs index 4647f7bd43..7f2a119119 100644 --- a/src/Tgstation.Server.Client/ClientException.cs +++ b/src/Tgstation.Server.Client/ClientException.cs @@ -19,7 +19,8 @@ namespace Tgstation.Server.Client /// /// The that generated the . /// The message for the . - protected ClientException(HttpResponseMessage responseMessage, string message) : base(message) + protected ClientException(HttpResponseMessage responseMessage, string message) + : base(message) { ResponseMessage = responseMessage ?? throw new ArgumentNullException(nameof(responseMessage)); } @@ -35,7 +36,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - protected ClientException(string message) : base(message) + protected ClientException(string message) + : base(message) { } @@ -44,7 +46,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - protected ClientException(string message, Exception innerException) : base(message, innerException) + protected ClientException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/ConflictException.cs b/src/Tgstation.Server.Client/ConflictException.cs index 7e18a1515b..54882788a4 100644 --- a/src/Tgstation.Server.Client/ConflictException.cs +++ b/src/Tgstation.Server.Client/ConflictException.cs @@ -15,7 +15,8 @@ namespace Tgstation.Server.Client /// /// The for the . /// The for the . - public ConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage) + public ConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base(errorMessage, responseMessage) { } @@ -30,7 +31,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public ConflictException(string message) : base(message) + public ConflictException(string message) + : base(message) { } @@ -39,7 +41,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public ConflictException(string message, Exception innerException) : base(message, innerException) + public ConflictException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/IApiClient.cs b/src/Tgstation.Server.Client/IApiClient.cs index 7758e9aefe..b60b534efb 100644 --- a/src/Tgstation.Server.Client/IApiClient.cs +++ b/src/Tgstation.Server.Client/IApiClient.cs @@ -44,7 +44,8 @@ namespace Tgstation.Server.Client /// The request body. /// The for the operation. /// A resulting in the response body as a . - Task Create(string route, TBody body, CancellationToken cancellationToken) where TBody : class; + Task Create(string route, TBody body, CancellationToken cancellationToken) + where TBody : class; /// /// Run an HTTP PUT request. @@ -73,7 +74,8 @@ namespace Tgstation.Server.Client /// The request body. /// The for the operation. /// A resulting in the response body as a . - Task Update(string route, TBody body, CancellationToken cancellationToken) where TBody : class; + Task Update(string route, TBody body, CancellationToken cancellationToken) + where TBody : class; /// /// Run an HTTP POST request. @@ -92,7 +94,8 @@ namespace Tgstation.Server.Client /// The request body. /// The for the operation. /// A representing the running operation. - Task Update(string route, TBody body, CancellationToken cancellationToken) where TBody : class; + Task Update(string route, TBody body, CancellationToken cancellationToken) + where TBody : class; /// /// Run an HTTP PATCH request. @@ -192,7 +195,8 @@ namespace Tgstation.Server.Client /// The instance to make the request to. /// The for the operation. /// A representing the running operation. - Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class; + Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) + where TBody : class; /// /// Run an HTTP DELETE request. @@ -214,7 +218,8 @@ namespace Tgstation.Server.Client /// The instance to make the request to. /// The for the operation. /// A representing the running operation. - Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class; + Task Delete(string route, TBody body, long instanceId, CancellationToken cancellationToken) + where TBody : class; /// /// Downloads a file for a given . diff --git a/src/Tgstation.Server.Client/InsufficientPermissionsException.cs b/src/Tgstation.Server.Client/InsufficientPermissionsException.cs index 76f7259ea4..b6d0483007 100644 --- a/src/Tgstation.Server.Client/InsufficientPermissionsException.cs +++ b/src/Tgstation.Server.Client/InsufficientPermissionsException.cs @@ -12,9 +12,10 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The for the . - public InsufficientPermissionsException(HttpResponseMessage responseMessage) : base( - responseMessage, - "The current user has insufficient permissions to perform the requested operation!") + public InsufficientPermissionsException(HttpResponseMessage responseMessage) + : base( + responseMessage, + "The current user has insufficient permissions to perform the requested operation!") { } @@ -29,7 +30,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public InsufficientPermissionsException(string message) : base(message) + public InsufficientPermissionsException(string message) + : base(message) { } @@ -38,7 +40,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public InsufficientPermissionsException(string message, Exception innerException) : base(message, innerException) + public InsufficientPermissionsException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/MethodNotSupportedException.cs b/src/Tgstation.Server.Client/MethodNotSupportedException.cs index 88a708bba4..c20a3c41ce 100644 --- a/src/Tgstation.Server.Client/MethodNotSupportedException.cs +++ b/src/Tgstation.Server.Client/MethodNotSupportedException.cs @@ -15,7 +15,8 @@ namespace Tgstation.Server.Client /// /// The for the . /// The for the . - public MethodNotSupportedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage) + public MethodNotSupportedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base(errorMessage, responseMessage) { } @@ -30,7 +31,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public MethodNotSupportedException(string message) : base(message) + public MethodNotSupportedException(string message) + : base(message) { } @@ -39,7 +41,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public MethodNotSupportedException(string message, Exception innerException) : base(message, innerException) + public MethodNotSupportedException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/RateLimitException.cs b/src/Tgstation.Server.Client/RateLimitException.cs index e4caf6bb9c..55ad10862a 100644 --- a/src/Tgstation.Server.Client/RateLimitException.cs +++ b/src/Tgstation.Server.Client/RateLimitException.cs @@ -23,7 +23,8 @@ namespace Tgstation.Server.Client /// /// The for the . /// The for the . - public RateLimitException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage) + public RateLimitException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base(errorMessage, responseMessage) { if (responseMessage == null) throw new ArgumentNullException(nameof(responseMessage)); @@ -47,7 +48,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public RateLimitException(string message) : base(message) + public RateLimitException(string message) + : base(message) { } @@ -56,7 +58,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public RateLimitException(string message, Exception innerException) : base(message, innerException) + public RateLimitException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/RequestTimeoutException.cs b/src/Tgstation.Server.Client/RequestTimeoutException.cs index 7d24457bd5..922f4015c9 100644 --- a/src/Tgstation.Server.Client/RequestTimeoutException.cs +++ b/src/Tgstation.Server.Client/RequestTimeoutException.cs @@ -12,7 +12,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The for the . - public RequestTimeoutException(HttpResponseMessage responseMessage) : base(responseMessage, "The request timed out!") + public RequestTimeoutException(HttpResponseMessage responseMessage) + : base(responseMessage, "The request timed out!") { } @@ -27,7 +28,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public RequestTimeoutException(string message) : base(message) + public RequestTimeoutException(string message) + : base(message) { } @@ -36,7 +38,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public RequestTimeoutException(string message, Exception innerException) : base(message, innerException) + public RequestTimeoutException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/ServerErrorException.cs b/src/Tgstation.Server.Client/ServerErrorException.cs index 805b797440..aae91e2d13 100644 --- a/src/Tgstation.Server.Client/ServerErrorException.cs +++ b/src/Tgstation.Server.Client/ServerErrorException.cs @@ -22,7 +22,8 @@ namespace Tgstation.Server.Client /// /// The for the . /// The for the . - public ServerErrorException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage) + public ServerErrorException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base(errorMessage, responseMessage) { } @@ -30,7 +31,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public ServerErrorException(string message) : base(message) + public ServerErrorException(string message) + : base(message) { } @@ -39,7 +41,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public ServerErrorException(string message, Exception innerException) : base(message, innerException) + public ServerErrorException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/ServiceUnavailableException.cs b/src/Tgstation.Server.Client/ServiceUnavailableException.cs index fb2ae62c28..f26300ccd7 100644 --- a/src/Tgstation.Server.Client/ServiceUnavailableException.cs +++ b/src/Tgstation.Server.Client/ServiceUnavailableException.cs @@ -12,7 +12,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The . - public ServiceUnavailableException(HttpResponseMessage responseMessage) : base(responseMessage, "The service is unavailable!") + public ServiceUnavailableException(HttpResponseMessage responseMessage) + : base(responseMessage, "The service is unavailable!") { } @@ -27,7 +28,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public ServiceUnavailableException(string message) : base(message) + public ServiceUnavailableException(string message) + : base(message) { } @@ -36,7 +38,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public ServiceUnavailableException(string message, Exception innerException) : base(message, innerException) + public ServiceUnavailableException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj index 739ce100b8..67bd6448a3 100644 --- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj +++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj @@ -2,34 +2,15 @@ - $(TgsNugetNetVersion) + $(TgsNugetNetFramework) $(TgsClientVersion) Client library for tgstation-server. json web api tgstation-server tgstation ss13 byond client http Added support for .zip uploads for server updates. Added missing Dispose() call to the StringContents for requests with bodies and added missing ConfigureAwait(false) to async call. - true - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml - - true - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - diff --git a/src/Tgstation.Server.Client/UnauthorizedException.cs b/src/Tgstation.Server.Client/UnauthorizedException.cs index 7a1ad6753b..f7ac53494e 100644 --- a/src/Tgstation.Server.Client/UnauthorizedException.cs +++ b/src/Tgstation.Server.Client/UnauthorizedException.cs @@ -15,7 +15,8 @@ namespace Tgstation.Server.Client /// /// The returned by the API. /// The . - public UnauthorizedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage) + public UnauthorizedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base(errorMessage, responseMessage) { } @@ -30,7 +31,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public UnauthorizedException(string message) : base(message) + public UnauthorizedException(string message) + : base(message) { } @@ -39,7 +41,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public UnauthorizedException(string message, Exception innerException) : base(message, innerException) + public UnauthorizedException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/UnrecognizedResponseException.cs b/src/Tgstation.Server.Client/UnrecognizedResponseException.cs index 30e09da8d0..515c1148ec 100644 --- a/src/Tgstation.Server.Client/UnrecognizedResponseException.cs +++ b/src/Tgstation.Server.Client/UnrecognizedResponseException.cs @@ -12,7 +12,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The . - public UnrecognizedResponseException(HttpResponseMessage responseMessage) : base(responseMessage, "Unrecognized response body!") + public UnrecognizedResponseException(HttpResponseMessage responseMessage) + : base(responseMessage, "Unrecognized response body!") { } @@ -27,7 +28,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public UnrecognizedResponseException(string message) : base(message) + public UnrecognizedResponseException(string message) + : base(message) { } @@ -36,7 +38,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public UnrecognizedResponseException(string message, Exception innerException) : base(message, innerException) + public UnrecognizedResponseException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Client/VersionMismatchException.cs b/src/Tgstation.Server.Client/VersionMismatchException.cs index e6fe4edf9c..0f9a71d3c9 100644 --- a/src/Tgstation.Server.Client/VersionMismatchException.cs +++ b/src/Tgstation.Server.Client/VersionMismatchException.cs @@ -15,7 +15,8 @@ namespace Tgstation.Server.Client /// /// The for the . /// The for the . - public VersionMismatchException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage) + public VersionMismatchException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) + : base(errorMessage, responseMessage) { } @@ -30,7 +31,8 @@ namespace Tgstation.Server.Client /// Initializes a new instance of the class. /// /// The message for the . - public VersionMismatchException(string message) : base(message) + public VersionMismatchException(string message) + : base(message) { } @@ -39,7 +41,8 @@ namespace Tgstation.Server.Client /// /// The message for the . /// The inner for the base . - public VersionMismatchException(string message, Exception innerException) : base(message, innerException) + public VersionMismatchException(string message, Exception innerException) + : base(message, innerException) { } } diff --git a/src/Tgstation.Server.Host.Common/Constants.cs b/src/Tgstation.Server.Common/Constants.cs similarity index 84% rename from src/Tgstation.Server.Host.Common/Constants.cs rename to src/Tgstation.Server.Common/Constants.cs index 9d0133bb0f..f6c1d10954 100644 --- a/src/Tgstation.Server.Host.Common/Constants.cs +++ b/src/Tgstation.Server.Common/Constants.cs @@ -1,4 +1,4 @@ -namespace Tgstation.Server.Host.Common +namespace Tgstation.Server.Common { /// /// Constant values. diff --git a/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj b/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj index d7f263b375..29d40742bc 100644 --- a/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj +++ b/src/Tgstation.Server.Common/Tgstation.Server.Common.csproj @@ -2,30 +2,11 @@ - $(TgsNugetNetVersion) + $(TgsNugetNetFramework) $(TgsCommonLibraryVersion) Common functions for tgstation-server. web tgstation-server tgstation ss13 byond client http Added CachedResponseStream. - true - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml - - true - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - diff --git a/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj b/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj index 90389d89a6..a45edbc7c4 100644 --- a/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj +++ b/src/Tgstation.Server.Host.Common/Tgstation.Server.Host.Common.csproj @@ -1,30 +1,9 @@ - + $(TgsFrameworkVersion);net2.0 $(TgsCoreVersion) - false - true - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml - - true - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/src/Tgstation.Server.Host.Console/Program.cs b/src/Tgstation.Server.Host.Console/Program.cs index 6ba3a851e9..b1803ba2a8 100644 --- a/src/Tgstation.Server.Host.Console/Program.cs +++ b/src/Tgstation.Server.Host.Console/Program.cs @@ -5,6 +5,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; + +using Tgstation.Server.Common; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Watchdog; @@ -35,7 +37,7 @@ namespace Tgstation.Server.Host.Console /// A representing the running operation. internal static async Task Main(string[] args) { - System.Console.Title = $"tgstation-server Host Watchdog v{Assembly.GetExecutingAssembly().GetName().Version.Semver()}"; + System.Console.Title = $"{Constants.CanonicalPackageName} Host Watchdog v{Assembly.GetExecutingAssembly().GetName().Version.Semver()}"; var arguments = new List(args); var trace = arguments.Remove("--trace-host-watchdog"); diff --git a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj index 0cdf6e82c5..7a85df7ea4 100644 --- a/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj +++ b/src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj @@ -1,15 +1,11 @@ - + Exe $(TgsFrameworkVersion) $(TgsCoreVersion) false - false - true - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml ../../build/uac_elevation_manifest.xml @@ -27,11 +23,6 @@ - - - all - runtime; build; native; contentfiles; analyzers - @@ -48,7 +39,6 @@ - diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs index fcd4cdb19e..23a9e45c23 100644 --- a/src/Tgstation.Server.Host.Service/Program.cs +++ b/src/Tgstation.Server.Host.Service/Program.cs @@ -1,5 +1,6 @@ using System; -using System.Diagnostics; +using System.Collections.Specialized; +using System.Configuration.Install; using System.IO; using System.Reflection; using System.ServiceProcess; @@ -87,27 +88,58 @@ namespace Tgstation.Server.Host.Service /// Runs sc.exe to either uninstall a given or install the running . /// /// The name of a service to uninstall. - /// A representing the running operation. - static async ValueTask InvokeSC(string serviceToUninstall) + static void InvokeSC(string serviceToUninstall) { - using var process = new Process(); - process.StartInfo.FileName = "C:/Windows/System32/sc.exe"; + using var installer = new ServiceInstaller(); + if (serviceToUninstall != null) + { + installer.Context = new InstallContext($"old-{serviceToUninstall}-uninstall.log", null); + installer.ServiceName = serviceToUninstall; + installer.Uninstall(null); + } + else + { + var fullPathToAssembly = Path.GetFullPath( + Assembly.GetExecutingAssembly().Location); - var fullPathToAssembly = Path.GetFullPath( - Assembly.GetExecutingAssembly().Location); + var assemblyDirectory = Path.GetDirectoryName(fullPathToAssembly); + var assemblyNameWithoutExtension = Path.GetFileNameWithoutExtension(fullPathToAssembly); + var exePath = Path.Combine(assemblyDirectory, $"{assemblyNameWithoutExtension}.exe"); - var assemblyDirectory = Path.GetDirectoryName(fullPathToAssembly); - var assemblyNameWithoutExtension = Path.GetFileNameWithoutExtension(fullPathToAssembly); - var exePath = Path.Combine(assemblyDirectory, $"{assemblyNameWithoutExtension}.exe"); + var programDataDirectory = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), + Server.Common.Constants.CanonicalPackageName); - process.StartInfo.Arguments = serviceToUninstall == null - ? $"create tgstation-server binPath=\"{exePath}\" start=auto depend=Tcpip/Dhcp/Dnscache" - : $"delete {serviceToUninstall}"; - process.StartInfo.CreateNoWindow = false; + using var processInstaller = new ServiceProcessInstaller(); + processInstaller.Account = ServiceAccount.LocalSystem; - process.Start(); + // Mimicing Tgstation.Server.Host.Service.Wix here, which is the source of truth for this data + installer.Context = new InstallContext( + Path.Combine(programDataDirectory, $"tgs-install-{Guid.NewGuid()}.log"), + new[] + { + $"assemblypath=\"{exePath}\" -p=--appsettings-base-path={programDataDirectory}", + }); + installer.Description = $"{Server.Common.Constants.CanonicalPackageName} running as a Windows service."; + installer.DisplayName = Server.Common.Constants.CanonicalPackageName; + installer.StartType = ServiceStartMode.Automatic; + installer.ServicesDependedOn = new string[] { "Tcpip", "Dhcp", "Dnscache" }; + installer.ServiceName = ServerService.Name; + installer.Parent = processInstaller; - await process.WaitForExitAsync(); + var state = new ListDictionary(); + try + { + installer.Install(state); + + installer.Commit(state); + } + catch + { + installer.Rollback(state); + throw; + } + } } /// @@ -156,17 +188,14 @@ namespace Tgstation.Server.Host.Service } if (match) - { - await InvokeSC(ServerService.Name); - break; - } + InvokeSC(ServerService.Name); } stopped = true; } if (Install) - stopped |= await RunServiceInstall(); + stopped |= RunServiceInstall(); if (Restart) foreach (ServiceController sc in ServiceController.GetServices()) @@ -177,15 +206,14 @@ namespace Tgstation.Server.Host.Service RestartService(sc); sc.Start(); - break; } } /// /// Attempt to install the TGS Service. /// - /// A resulting in if the service was stopped or detached as a result, otherwise. - async ValueTask RunServiceInstall() + /// if the service was stopped or detached as a result, otherwise. + bool RunServiceInstall() { // First check if the service already exists bool serviceStopped = false; @@ -210,11 +238,11 @@ namespace Tgstation.Server.Host.Service RestartService(sc); // And remove it - await InvokeSC(sc.ServiceName); + InvokeSC(sc.ServiceName); } } - await InvokeSC(null); + InvokeSC(null); return serviceStopped; } diff --git a/src/Tgstation.Server.Host.Service/ServerService.cs b/src/Tgstation.Server.Host.Service/ServerService.cs index 80b0fcfd79..69f707194b 100644 --- a/src/Tgstation.Server.Host.Service/ServerService.cs +++ b/src/Tgstation.Server.Host.Service/ServerService.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.EventLog; +using Tgstation.Server.Common; using Tgstation.Server.Host.Common; using Tgstation.Server.Host.Watchdog; diff --git a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj index 0d5b8b429e..48eb72358e 100644 --- a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj +++ b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj @@ -1,43 +1,30 @@ - + WinExe $(TgsFrameworkVersion)-windows $(TgsCoreVersion) - true false - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(RuntimeIdentifier)/$(AssemblyName).xml ../../build/tgs.ico ../../build/uac_elevation_manifest.xml - - true - - - - - 1701;1702;SA1652 - - + + + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -46,7 +33,6 @@ - diff --git a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj index 2ee844505b..4cda1e51b1 100644 --- a/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj +++ b/src/Tgstation.Server.Host.Watchdog/Tgstation.Server.Host.Watchdog.csproj @@ -1,24 +1,10 @@ - + $(TgsFrameworkVersion) - Full false $(TgsHostWatchdogVersion) - false - true - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml - - - - true - - - - - 1701;1702;SA1652 @@ -26,11 +12,6 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -39,10 +20,6 @@ - - - - diff --git a/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs b/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs index b0459db431..16fa34998d 100644 --- a/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs +++ b/src/Tgstation.Server.Host/Components/Byond/ByondManager.cs @@ -11,7 +11,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Components.Events; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index b8038dfe5b..38c561650b 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -14,7 +14,6 @@ using Tgstation.Server.Host.Components.Chat.Commands; using Tgstation.Server.Host.Components.Chat.Providers; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Core; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Components.Chat diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs index 6cc52173d9..35840d67db 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs @@ -7,7 +7,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.Components.Interop; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index 706950db1b..6ead6dc1dc 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Tgstation.Server.Api.Models; +using Tgstation.Server.Common; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Interop.Bridge; using Tgstation.Server.Host.Configuration; @@ -633,7 +634,7 @@ namespace Tgstation.Server.Host.Components using (var systemIdentity = systemIdentityFactory.GetCurrent()) { if (!systemIdentity.CanCreateSymlinks) - throw new InvalidOperationException("The user running tgstation-server cannot create symlinks! Please try running as an administrative user!"); + throw new InvalidOperationException($"The user running {Constants.CanonicalPackageName} cannot create symlinks! Please try running as an administrative user!"); } // This runs before the real socket is opened, ensures we don't perform reattaches unless we're fairly certain the bind won't fail diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs index ee8a96f7c7..1270af68cf 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs @@ -37,7 +37,8 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// /// The to build from. /// The value of . - public TestMergeInformation(Models.TestMerge testMerge, RevisionInformation revision) : base(testMerge) + public TestMergeInformation(Models.TestMerge testMerge, RevisionInformation revision) + : base(testMerge) { TimeMerged = testMerge?.MergedAt.Ticks.ToString(CultureInfo.InvariantCulture) ?? throw new ArgumentNullException(nameof(testMerge)); Revision = revision ?? throw new ArgumentNullException(nameof(revision)); diff --git a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs index 166383353f..236c125112 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs @@ -7,7 +7,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; -using Tgstation.Server.Host.Extensions; namespace Tgstation.Server.Host.Components.Repository { diff --git a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs index c575f7a2e1..2c9007f4f3 100644 --- a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs +++ b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs @@ -48,7 +48,8 @@ namespace Tgstation.Server.Host.Components.Session Models.ReattachInformation copy, IDmbProvider dmb, IDmbProvider initialDmb, - TimeSpan topicRequestTimeout) : base(copy) + TimeSpan topicRequestTimeout) + : base(copy) { Dmb = dmb ?? throw new ArgumentNullException(nameof(dmb)); InitialDmb = initialDmb; diff --git a/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs b/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs index 56410f708c..38c709ec39 100644 --- a/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs @@ -23,6 +23,14 @@ namespace Tgstation.Server.Host.Configuration set => base.Address = value; } + /// + [YamlMember(SerializeAs = typeof(string))] + public override Uri PublicAddress + { + get => base.PublicAddress; + set => base.PublicAddress = value; + } + /// /// The of the swarm controller. If , the current server is considered the controller. /// diff --git a/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs b/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs index 406560f458..8f1a6d503e 100644 --- a/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Configuration +using Tgstation.Server.Common; + +namespace Tgstation.Server.Host.Configuration { /// /// Configuration for the automatic update system. @@ -18,7 +20,7 @@ /// /// The default value of . /// - const string DefaultGitTagPrefix = "tgstation-server-v"; + const string DefaultGitTagPrefix = $"{Constants.CanonicalPackageName}-v"; /// /// The default value of . diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 4a8bb4a152..cada7d1b6c 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -284,7 +284,8 @@ namespace Tgstation.Server.Host.Core services.AddHttpClient(); services.AddSingleton(); - void AddTypedContext() where TContext : DatabaseContext + void AddTypedContext() + where TContext : DatabaseContext { var configureAction = DatabaseContext.GetConfigureAction(); diff --git a/src/Tgstation.Server.Host/Core/CommandPipeReader.cs b/src/Tgstation.Server.Host/Core/CommandPipeReader.cs index 61bad2b474..54f365ab65 100644 --- a/src/Tgstation.Server.Host/Core/CommandPipeReader.cs +++ b/src/Tgstation.Server.Host/Core/CommandPipeReader.cs @@ -10,7 +10,6 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Common; using Tgstation.Server.Host.Configuration; -using Tgstation.Server.Host.Extensions; namespace Tgstation.Server.Host.Core { diff --git a/src/Tgstation.Server.Host/Database/DatabaseCollection.cs b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs index 78e745390e..b2dafa719d 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseCollection.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs @@ -10,7 +10,8 @@ using Microsoft.EntityFrameworkCore; namespace Tgstation.Server.Host.Database { /// - sealed class DatabaseCollection : IDatabaseCollection where TModel : class + sealed class DatabaseCollection : IDatabaseCollection + where TModel : class { /// /// The backing . diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs index 9938fdbf65..3347dde27a 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs @@ -257,7 +257,8 @@ namespace Tgstation.Server.Host.Database /// Initializes a new instance of the class. /// /// The for the . - protected DatabaseContext(DbContextOptions dbContextOptions) : base(dbContextOptions) + protected DatabaseContext(DbContextOptions dbContextOptions) + : base(dbContextOptions) { usersCollection = new DatabaseCollection(Users); instancesCollection = new DatabaseCollection(Instances); diff --git a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs index b37e7b66a7..965eade13e 100644 --- a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore.Design; +using Tgstation.Server.Common; using Tgstation.Server.Host.Configuration; namespace Tgstation.Server.Host.Database.Design @@ -14,6 +15,6 @@ namespace Tgstation.Server.Host.Database.Design => new PostgresSqlDatabaseContext( DesignTimeDbContextFactoryHelpers.CreateDatabaseContextOptions( DatabaseType.PostgresSql, - "Application Name=tgstation-server;Host=127.0.0.1;Password=fake;Username=postgres;Database=TGS_Design")); + $"Application Name={Constants.CanonicalPackageName};Host=127.0.0.1;Password=fake;Username=postgres;Database=TGS_Design")); } } diff --git a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs index d9d005a846..83d109c425 100644 --- a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs @@ -22,7 +22,8 @@ namespace Tgstation.Server.Host.Database /// Initializes a new instance of the class. /// /// The for the . - public MySqlDatabaseContext(DbContextOptions dbContextOptions) : base(dbContextOptions) + public MySqlDatabaseContext(DbContextOptions dbContextOptions) + : base(dbContextOptions) { } diff --git a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs index a5b5d2319a..33cab94dcf 100644 --- a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs @@ -16,7 +16,8 @@ namespace Tgstation.Server.Host.Database /// Initializes a new instance of the class. /// /// The for the . - public SqlServerDatabaseContext(DbContextOptions dbContextOptions) : base(dbContextOptions) + public SqlServerDatabaseContext(DbContextOptions dbContextOptions) + : base(dbContextOptions) { } diff --git a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs index 5acfd9abb3..c4d7e029b5 100644 --- a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs @@ -56,7 +56,8 @@ namespace Tgstation.Server.Host.Extensions /// Change the used as an implementation for calls to . /// /// The implementation to use. - public static void UseChatProviderFactory() where TProviderFactory : IProviderFactory + public static void UseChatProviderFactory() + where TProviderFactory : IProviderFactory { chatProviderFactoryType = typeof(TProviderFactory); } @@ -65,7 +66,8 @@ namespace Tgstation.Server.Host.Extensions /// Change the used as an implementation for calls to . /// /// The implementation to use. - public static void UseGitHubServiceFactory() where TGitHubServiceFactory : IGitHubServiceFactory + public static void UseGitHubServiceFactory() + where TGitHubServiceFactory : IGitHubServiceFactory { gitHubServiceFactoryType = typeof(TGitHubServiceFactory); } @@ -74,7 +76,8 @@ namespace Tgstation.Server.Host.Extensions /// Change the used as an implementation for calls to . /// /// The implementation to use. - public static void UseFileDownloader() where TFileDownloader : IFileDownloader + public static void UseFileDownloader() + where TFileDownloader : IFileDownloader { fileDownloaderType = typeof(TFileDownloader); } @@ -112,7 +115,8 @@ namespace Tgstation.Server.Host.Extensions /// Add an additional to s that call . /// /// The of to add. - public static void UseAdditionalLoggerProvider() where TLoggerProvider : class, ILoggerProvider + public static void UseAdditionalLoggerProvider() + where TLoggerProvider : class, ILoggerProvider { if (additionalLoggerProvider != null) throw new InvalidOperationException("Cannot have multiple additionalLoggerProviders!"); @@ -138,7 +142,8 @@ namespace Tgstation.Server.Host.Extensions /// The to configure. /// The containing the . /// . - public static IServiceCollection UseStandardConfig(this IServiceCollection serviceCollection, IConfiguration configuration) where TConfig : class + public static IServiceCollection UseStandardConfig(this IServiceCollection serviceCollection, IConfiguration configuration) + where TConfig : class { ArgumentNullException.ThrowIfNull(serviceCollection); ArgumentNullException.ThrowIfNull(configuration); diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index fbe5afaaf8..23d36cafd5 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.IO diff --git a/src/Tgstation.Server.Host/Jobs/JobException.cs b/src/Tgstation.Server.Host/Jobs/JobException.cs index ccb1234559..0eb62f2e29 100644 --- a/src/Tgstation.Server.Host/Jobs/JobException.cs +++ b/src/Tgstation.Server.Host/Jobs/JobException.cs @@ -25,7 +25,8 @@ namespace Tgstation.Server.Host.Jobs /// Initializes a new instance of the class. /// /// The message for the . - public JobException(string message) : base(message) + public JobException(string message) + : base(message) { } @@ -34,7 +35,8 @@ namespace Tgstation.Server.Host.Jobs /// /// The message for the . /// The inner for the nase . - public JobException(string message, Exception innerException) : base(message, innerException) + public JobException(string message, Exception innerException) + : base(message, innerException) { } @@ -42,7 +44,8 @@ namespace Tgstation.Server.Host.Jobs /// Initializes a new instance of the class. /// /// The associated . - public JobException(ErrorCode errorCode) : base(errorCode.Describe()) + public JobException(ErrorCode errorCode) + : base(errorCode.Describe()) { ErrorCode = errorCode; } @@ -52,7 +55,8 @@ namespace Tgstation.Server.Host.Jobs /// /// The associated . /// The inner for the nase . - public JobException(ErrorCode errorCode, Exception innerException) : base(errorCode.Describe(), innerException) + public JobException(ErrorCode errorCode, Exception innerException) + : base(errorCode.Describe(), innerException) { ErrorCode = errorCode; } diff --git a/src/Tgstation.Server.Host/Jobs/JobHandler.cs b/src/Tgstation.Server.Host/Jobs/JobHandler.cs index 1bf64380f4..57aae60fdb 100644 --- a/src/Tgstation.Server.Host/Jobs/JobHandler.cs +++ b/src/Tgstation.Server.Host/Jobs/JobHandler.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -using Tgstation.Server.Host.Extensions; - namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Models/Instance.cs b/src/Tgstation.Server.Host/Models/Instance.cs index 33cebaf9df..8acf4f1570 100644 --- a/src/Tgstation.Server.Host/Models/Instance.cs +++ b/src/Tgstation.Server.Host/Models/Instance.cs @@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Models public ICollection Jobs { get; set; } /// - public InstanceResponse ToApi() => new InstanceResponse + public InstanceResponse ToApi() => new () { AutoUpdateInterval = AutoUpdateInterval, ConfigurationType = ConfigurationType, diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index 510a882004..105c7f9837 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -69,7 +69,7 @@ namespace Tgstation.Server.Host.Security var prop = typeToCheck.GetProperties().Where(x => x.PropertyType == nullableRightsType).First(); - var right = prop.GetMethod.Invoke(isInstance ? (object)InstancePermissionSet : PermissionSet, Array.Empty()); + var right = prop.GetMethod.Invoke(isInstance ? InstancePermissionSet : PermissionSet, Array.Empty()); if (right == null) throw new InvalidOperationException("A user right was null!"); diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index dde11140f8..762d0c8aa9 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -21,6 +21,7 @@ using MySqlConnector; using Npgsql; +using Tgstation.Server.Common; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions.Converters; @@ -874,9 +875,15 @@ namespace Tgstation.Server.Host.Setup async Task ParseAddress(string question) { + var first = true; Uri address; do { + if (first) + first = false; + else + await console.WriteAsync("Invalid address!", true, cancellationToken); + await console.WriteAsync(question, false, cancellationToken); var addressString = await console.ReadLineAsync(false, cancellationToken); if (Uri.TryCreate(addressString, UriKind.Absolute, out address) @@ -889,7 +896,8 @@ namespace Tgstation.Server.Host.Setup return address; } - var address = await ParseAddress("Enter this server's HTTP(S) address: "); + var address = await ParseAddress("Enter this server's INTERNAL http(s) address: "); + var publicAddress = await ParseAddress("Enter this server's PUBLIC https(s) address: "); string privateKey; do { @@ -906,6 +914,7 @@ namespace Tgstation.Server.Host.Setup return new SwarmConfiguration { Address = address, + PublicAddress = publicAddress, ControllerAddress = controllerAddress, Identifier = identifer, PrivateKey = privateKey, @@ -1012,7 +1021,7 @@ namespace Tgstation.Server.Host.Setup async Task RunWizard(string userConfigFileName, CancellationToken cancellationToken) { // welcome message - await console.WriteAsync("Welcome to tgstation-server!", true, cancellationToken); + await console.WriteAsync($"Welcome to {Constants.CanonicalPackageName}!", true, cancellationToken); await console.WriteAsync("This wizard will help you configure your server.", true, cancellationToken); var hostingPort = await PromptForHostingPort(cancellationToken); diff --git a/src/Tgstation.Server.Host/Swarm/SwarmService.cs b/src/Tgstation.Server.Host/Swarm/SwarmService.cs index 8c4d66122c..e947ff4ffa 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmService.cs @@ -199,6 +199,7 @@ namespace Tgstation.Server.Host.Swarm new SwarmServerResponse { Address = swarmConfiguration.Address, + PublicAddress = swarmConfiguration.PublicAddress, Controller = swarmController, Identifier = swarmConfiguration.Identifier, }, @@ -571,6 +572,7 @@ namespace Tgstation.Server.Host.Swarm swarmServers.Add(new SwarmServerResponse { + PublicAddress = node.PublicAddress, Address = node.Address, Identifier = node.Identifier, Controller = false, @@ -1239,6 +1241,7 @@ namespace Tgstation.Server.Host.Swarm ServerVersion = assemblyInformationProvider.Version, Identifier = swarmConfiguration.Identifier, Address = swarmConfiguration.Address, + PublicAddress = swarmConfiguration.PublicAddress, }, requestedRegistrationId); diff --git a/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs b/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs index aa035c772f..34d2a9a940 100644 --- a/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs +++ b/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs @@ -2,8 +2,8 @@ using System.Net.Http.Headers; using System.Reflection; +using Tgstation.Server.Common; using Tgstation.Server.Common.Extensions; -using Tgstation.Server.Host.Common; namespace Tgstation.Server.Host.System { diff --git a/src/Tgstation.Server.Host/System/SystemDManager.cs b/src/Tgstation.Server.Host/System/SystemDManager.cs index d7b852ae58..1eaeafbc84 100644 --- a/src/Tgstation.Server.Host/System/SystemDManager.cs +++ b/src/Tgstation.Server.Host/System/SystemDManager.cs @@ -10,7 +10,6 @@ using Mono.Unix; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Core; -using Tgstation.Server.Host.Extensions; namespace Tgstation.Server.Host.System { diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 1b58a03bdd..bb3e366c21 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -1,26 +1,17 @@ - + $(TgsFrameworkVersion) $(TgsCoreVersion) true - true false - ../../build/analyzers.ruleset - bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml API1000 ClientApp/node_modules ClientApp/node_modules/.install-stamp Linux ..\.. ../../build/uac_elevation_manifest.xml - Debug;Release;Installer - - - - true - @@ -99,7 +90,7 @@ - + @@ -130,14 +121,6 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - @@ -147,7 +130,6 @@ - diff --git a/src/Tgstation.Server.Host/Transfer/FileTransferService.cs b/src/Tgstation.Server.Host/Transfer/FileTransferService.cs index eabb99e445..22dee33c7c 100644 --- a/src/Tgstation.Server.Host/Transfer/FileTransferService.cs +++ b/src/Tgstation.Server.Host/Transfer/FileTransferService.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; diff --git a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs index af3ad3229f..69286cc52c 100644 --- a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.WebUtilities; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; namespace Tgstation.Server.Host.Transfer diff --git a/src/Tgstation.Server.Host/appsettings.yml b/src/Tgstation.Server.Host/appsettings.yml index 2371468ca6..7b0f60e8a3 100644 --- a/src/Tgstation.Server.Host/appsettings.yml +++ b/src/Tgstation.Server.Host/appsettings.yml @@ -66,3 +66,10 @@ Security: TGForums: # https://tgstation13.org OAuth configuration Keycloak: # Keycloak OAuth configuration. InvisionCommunity: # Invision Community OAuth configuration. +Swarm: # Should be left empty if using swarm mode is not desired +# Identifier: # Required: The string identifier of the swarm node +# PrivateKey: # Required: The shared API key used for inter-server communication in the swarm. Must be the same secure string on all nodes +# Address: # Required: The internal address of the swarm node's API +# PublicAddress: # The public address of the swarm node +# ControllerAddress: # Required on non-controller nodes. The internal address of the swarm controller's API'. Should be left empty on the controller itself +# UpdateRequiredNodeCount: # The number of nodes expected to be in the swarm before initiating an update. This should count every server irrespective of whether or not they are the controller MINUS 1 diff --git a/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj b/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj index 8443db7356..622b82d8cb 100644 --- a/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj +++ b/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj @@ -1,23 +1,12 @@ - + $(TgsFrameworkVersion) - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - diff --git a/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj b/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj index 0d2d877fe1..b4041bd259 100644 --- a/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj +++ b/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj @@ -1,25 +1,10 @@ - + $(TgsFrameworkVersion) - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj b/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj index e0d44a649e..1e8c6156cb 100644 --- a/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj +++ b/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj @@ -1,25 +1,10 @@ - + $(TgsFrameworkVersion) - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj index 54971a8c9f..996c2f630b 100644 --- a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj +++ b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj @@ -1,30 +1,10 @@ - + $(TgsFrameworkVersion)-windows - - false - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/tests/Tgstation.Server.Host.Tests.Signals/Program.cs b/tests/Tgstation.Server.Host.Tests.Signals/Program.cs index dc222f6331..eaebbc68f5 100644 --- a/tests/Tgstation.Server.Host.Tests.Signals/Program.cs +++ b/tests/Tgstation.Server.Host.Tests.Signals/Program.cs @@ -7,7 +7,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using Tgstation.Server.Host.Core; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; diff --git a/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj b/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj index c67edb6003..d515505048 100644 --- a/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj +++ b/tests/Tgstation.Server.Host.Tests.Signals/Tgstation.Server.Host.Tests.Signals.csproj @@ -8,7 +8,7 @@ - + diff --git a/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs b/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs index 76e2e26ee0..91dacecda9 100644 --- a/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs +++ b/tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs @@ -240,7 +240,8 @@ namespace Tgstation.Server.Host.Setup.Tests "node1", "not a url", "net.tcp://notandhttpAddress.com", - "http://node1:3400", + "http://node1internal:3400", + "http://node1public:3400", "privatekey", "n", "http://controller.com", @@ -274,7 +275,8 @@ namespace Tgstation.Server.Host.Setup.Tests //swarm config "y", "controller", - "https://controller.com", + "https://controllerinternal.com", + "https://controllerpublic.com", "privatekey", "y" }; diff --git a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj index 5f0701e388..f921ae5bf0 100644 --- a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj +++ b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj @@ -1,25 +1,10 @@ - + $(TgsFrameworkVersion) - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj b/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj index a3762c1162..6fc7232b67 100644 --- a/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj +++ b/tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj @@ -1,30 +1,10 @@ - + $(TgsFrameworkVersion) - - false - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs b/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs index 448079fc81..8a85b74abc 100644 --- a/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs +++ b/tests/Tgstation.Server.Tests/Live/LiveTestingServer.cs @@ -168,6 +168,7 @@ namespace Tgstation.Server.Tests.Live swarmArgs.Add($"Swarm:PrivateKey={swarmConfiguration.PrivateKey}"); swarmArgs.Add($"Swarm:Identifier={swarmConfiguration.Identifier}"); swarmArgs.Add($"Swarm:Address={swarmConfiguration.Address}"); + swarmArgs.Add($"Swarm:PublicAddress={swarmConfiguration.PublicAddress}"); if (swarmConfiguration.ControllerAddress != null) swarmArgs.Add($"Swarm:ControllerAddress={swarmConfiguration.ControllerAddress}"); diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs index e1de31f9cd..5de00a2cf3 100644 --- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs +++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs @@ -735,6 +735,7 @@ namespace Tgstation.Server.Tests.Live { Address = controllerAddress, Identifier = "controller", + PublicAddress = new Uri("http://fakecontroller.com"), PrivateKey = PrivateKey, UpdateRequiredNodeCount = 2, }, false, 15011)) @@ -743,6 +744,7 @@ namespace Tgstation.Server.Tests.Live { Address = new Uri("http://localhost:15012"), ControllerAddress = controllerAddress, + PublicAddress = new Uri("http://fakenode1.com"), Identifier = "node1", PrivateKey = PrivateKey }, false, 15012); @@ -792,16 +794,19 @@ namespace Tgstation.Server.Tests.Live Assert.IsNotNull(node1); Assert.AreEqual(node1.Address, new Uri("http://localhost:15012")); Assert.IsFalse(node1.Controller); + Assert.AreEqual(node1.PublicAddress, new Uri("http://fakenode1.com")); var node2 = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "node2"); Assert.IsNotNull(node2); Assert.AreEqual(node2.Address, new Uri("http://localhost:15013")); Assert.IsFalse(node2.Controller); + Assert.IsNull(node2.PublicAddress); var controller = serverInformation.SwarmServers.SingleOrDefault(x => x.Identifier == "controller"); Assert.IsNotNull(controller); Assert.AreEqual(controller.Address, new Uri("http://localhost:15011")); Assert.IsTrue(controller.Controller); + Assert.AreEqual(controller.PublicAddress, new Uri("http://fakecontroller.com")); } CheckInfo(controllerInfo); diff --git a/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj b/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj index 925be86ff4..82c98aa9f0 100644 --- a/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj +++ b/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj @@ -1,25 +1,10 @@ - + $(TgsFrameworkVersion) - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/tgstation-server.sln b/tgstation-server.sln index 7dd40adac4..1b023a2b7d 100644 --- a/tgstation-server.sln +++ b/tgstation-server.sln @@ -32,7 +32,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{6FF654E6 build\GenerateMigrations.sh = build\GenerateMigrations.sh build\NugetCommon.props = build\NugetCommon.props build\OpenApiValidationSettings.json = build\OpenApiValidationSettings.json + build\SrcCommon.props = build\SrcCommon.props build\stylecop.json = build\stylecop.json + build\TestCommon.props = build\TestCommon.props build\tgs.docker.sh = build\tgs.docker.sh build\tgs.ico = build\tgs.ico build\tgs.png = build\tgs.png @@ -130,8 +132,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{E821 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.Tests", "tests\Tgstation.Server.Tests\Tgstation.Server.Tests.csproj", "{09056964-1C74-445A-96EC-33F6DFC07916}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReleaseNotes", "tools\ReleaseNotes\ReleaseNotes.csproj", "{5CB51532-55F0-4255-B6E5-69ED5CCD14CD}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vscode", ".vscode", "{14B3FF87-5600-4981-B40C-9CC838964645}" ProjectSection(SolutionItems) = preProject .vscode\extensions.json = .vscode\extensions.json @@ -252,6 +252,8 @@ Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Tgstation.Server.Host.Servi EndProject Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "Tgstation.Server.Host.Service.Wix.Bundle", "build\package\winget\Tgstation.Server.Host.Service.Wix.Bundle\Tgstation.Server.Host.Service.Wix.Bundle.wixproj", "{9E66C6F1-E235-4979-83B5-C2B3FDAD6E01}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.ReleaseNotes", "tools\Tgstation.Server.ReleaseNotes\Tgstation.Server.ReleaseNotes.csproj", "{69944039-65C2-40E1-9D86-0608FA0C2D70}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -414,18 +416,6 @@ Global {09056964-1C74-445A-96EC-33F6DFC07916}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU {09056964-1C74-445A-96EC-33F6DFC07916}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU {09056964-1C74-445A-96EC-33F6DFC07916}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.DebugNoWindows|Any CPU.ActiveCfg = Debug|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.DebugNoWindows|Any CPU.Build.0 = Debug|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.DebugNoWix|Any CPU.ActiveCfg = Debug|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.DebugNoWix|Any CPU.Build.0 = Debug|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.Release|Any CPU.Build.0 = Release|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.ReleaseNoWindows|Any CPU.ActiveCfg = Release|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU {5813CC33-B16C-485D-A74D-20204DDF6542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5813CC33-B16C-485D-A74D-20204DDF6542}.Debug|Any CPU.Build.0 = Debug|Any CPU {5813CC33-B16C-485D-A74D-20204DDF6542}.DebugNoWindows|Any CPU.ActiveCfg = Debug|Any CPU @@ -510,6 +500,18 @@ Global {9E66C6F1-E235-4979-83B5-C2B3FDAD6E01}.Release|Any CPU.Build.0 = Release|x86 {9E66C6F1-E235-4979-83B5-C2B3FDAD6E01}.ReleaseNoWindows|Any CPU.ActiveCfg = Release|x86 {9E66C6F1-E235-4979-83B5-C2B3FDAD6E01}.ReleaseNoWix|Any CPU.ActiveCfg = Release|x86 + {69944039-65C2-40E1-9D86-0608FA0C2D70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.DebugNoWindows|Any CPU.ActiveCfg = Debug|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.DebugNoWindows|Any CPU.Build.0 = Debug|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.DebugNoWix|Any CPU.ActiveCfg = Debug|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.DebugNoWix|Any CPU.Build.0 = Debug|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.Release|Any CPU.Build.0 = Release|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.ReleaseNoWindows|Any CPU.ActiveCfg = Release|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.ReleaseNoWindows|Any CPU.Build.0 = Release|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.ReleaseNoWix|Any CPU.ActiveCfg = Release|Any CPU + {69944039-65C2-40E1-9D86-0608FA0C2D70}.ReleaseNoWix|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -528,7 +530,6 @@ Global {82066812-6C73-4360-943B-B23F2F491261} = {7E4E7CF6-A48D-410E-8191-C49C6B5AB9CC} {057FAC33-CC31-4948-91C6-B0977C335890} = {F7765A4B-021C-454E-ABB1-2AB1B85F91B4} {09056964-1C74-445A-96EC-33F6DFC07916} = {316141B0-CD21-4769-A013-D53DA9B9EC09} - {5CB51532-55F0-4255-B6E5-69ED5CCD14CD} = {A55C1117-5808-4AB2-BEA6-4D4A3E66A2F2} {FAEAD3B5-2EAB-465C-A9C3-E8CB6AAA7131} = {F7765A4B-021C-454E-ABB1-2AB1B85F91B4} {EB1DDE8C-CA6F-4BE3-947B-597CA8EABEA5} = {82066812-6C73-4360-943B-B23F2F491261} {7B8FC2AF-1B64-4A89-8480-F0FE360DC9EC} = {82066812-6C73-4360-943B-B23F2F491261} @@ -547,6 +548,7 @@ Global {28669D98-E15D-4A62-B1D1-7C11D4CB1DE0} = {506B9092-AF88-4DA2-84FD-C11646B695B0} {82996E9D-5E63-4CC5-8179-612C71B4F56C} = {506B9092-AF88-4DA2-84FD-C11646B695B0} {9E66C6F1-E235-4979-83B5-C2B3FDAD6E01} = {506B9092-AF88-4DA2-84FD-C11646B695B0} + {69944039-65C2-40E1-9D86-0608FA0C2D70} = {A55C1117-5808-4AB2-BEA6-4D4A3E66A2F2} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DFD36C95-3E49-41C7-ACDB-86BAF5B18A79} diff --git a/tools/Tgstation.Server.Migrator.Comms/Program.cs b/tools/Tgstation.Server.Migrator.Comms/Program.cs index 8cebd477c7..2e069acb46 100644 --- a/tools/Tgstation.Server.Migrator.Comms/Program.cs +++ b/tools/Tgstation.Server.Migrator.Comms/Program.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Net.Http.Headers; @@ -53,7 +52,7 @@ static class Program { #if DEBUG Console.WriteLine("Test log line..."); - Debugger.Launch(); + System.Diagnostics.Debugger.Launch(); #endif Console.WriteLine("Connecting to TGS3..."); var status = tgs3Client.ConnectionStatus(out var tgs3Error); diff --git a/tools/Tgstation.Server.Migrator/Program.cs b/tools/Tgstation.Server.Migrator/Program.cs index 3332b5b52e..83afbe2500 100644 --- a/tools/Tgstation.Server.Migrator/Program.cs +++ b/tools/Tgstation.Server.Migrator/Program.cs @@ -21,6 +21,7 @@ using Octokit; using Tgstation.Server.Api; using Tgstation.Server.Client; +using Tgstation.Server.Common; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Common; @@ -134,13 +135,12 @@ try if (service == tgs3Service) continue; - if (checkNewOneIsntInstalled && (service.ServiceName == NewServiceName || service.ServiceName == "tgstation-server-4")) - { - Console.WriteLine("Detected existing TGS4+ install! Cannot continue. Please uninstall any versions of TGS4+ before continuing."); - ExitPause(10); - } - - service.Dispose(); + using (service) + if (checkNewOneIsntInstalled && (service.ServiceName == NewServiceName || service.ServiceName == "tgstation-server-4")) + { + Console.WriteLine("Detected existing TGS4+ install! Cannot continue. Please uninstall any versions of TGS4+ before continuing."); + ExitPause(10); + } } if (checkNewOneIsntInstalled) @@ -438,7 +438,7 @@ try $"assemblypath={Path.Combine(tgsInstallPath, "Tgstation.Server.Host.Service.exe")}" }); installer.Description = "/tg/station 13 server running as a windows service"; - installer.DisplayName = "/tg/station server"; + installer.DisplayName = "tgstation-server"; installer.StartType = ServiceStartMode.Automatic; installer.ServicesDependedOn = new string[] { "Tcpip", "Dhcp", "Dnscache" }; installer.ServiceName = NewServiceName; diff --git a/tools/ReleaseNotes/Program.cs b/tools/Tgstation.Server.ReleaseNotes/Program.cs similarity index 99% rename from tools/ReleaseNotes/Program.cs rename to tools/Tgstation.Server.ReleaseNotes/Program.cs index 94a58bdb58..2b5b9a55b4 100644 --- a/tools/ReleaseNotes/Program.cs +++ b/tools/Tgstation.Server.ReleaseNotes/Program.cs @@ -9,7 +9,7 @@ using System.Xml.Linq; using Octokit; using Octokit.GraphQL; -namespace ReleaseNotes +namespace Tgstation.Server.ReleaseNotes { /// /// Contains the application entrypoint diff --git a/tools/ReleaseNotes/README.md b/tools/Tgstation.Server.ReleaseNotes/README.md similarity index 100% rename from tools/ReleaseNotes/README.md rename to tools/Tgstation.Server.ReleaseNotes/README.md diff --git a/tools/ReleaseNotes/ReleaseNotes.csproj b/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj similarity index 84% rename from tools/ReleaseNotes/ReleaseNotes.csproj rename to tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj index 2f2e6ab506..02af17a6a7 100644 --- a/tools/ReleaseNotes/ReleaseNotes.csproj +++ b/tools/Tgstation.Server.ReleaseNotes/Tgstation.Server.ReleaseNotes.csproj @@ -7,7 +7,7 @@ - +