diff --git a/src/Tgstation.Server.Host/Core/PortAllocator.cs b/src/Tgstation.Server.Host/Core/PortAllocator.cs index 8ff8feba81..27d2bb4371 100644 --- a/src/Tgstation.Server.Host/Core/PortAllocator.cs +++ b/src/Tgstation.Server.Host/Core/PortAllocator.cs @@ -1,10 +1,12 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; @@ -28,16 +30,27 @@ namespace Tgstation.Server.Host.Core /// readonly ILogger logger; + /// + /// The for the . + /// + readonly SwarmConfiguration swarmConfiguration; + /// /// Initializes a new instance of the . /// /// The value of . /// The value of . + /// The containing the value of . /// The value of . - public PortAllocator(IServerPortProvider serverPortProvider, IDatabaseContext databaseContext, ILogger logger) + public PortAllocator( + IServerPortProvider serverPortProvider, + IDatabaseContext databaseContext, + IOptions swarmConfigurationOptions, + ILogger logger) { this.serverPortProvider = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider)); this.databaseContext = databaseContext ?? throw new ArgumentNullException(nameof(databaseContext)); + swarmConfiguration = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); } @@ -49,6 +62,7 @@ namespace Tgstation.Server.Host.Core var ddPorts = await databaseContext .DreamDaemonSettings .AsQueryable() + .Where(x => x.Instance.SwarmIdentifer == swarmConfiguration.Identifier) .Select(x => x.Port) .ToListAsync(cancellationToken) .ConfigureAwait(false); @@ -56,6 +70,7 @@ namespace Tgstation.Server.Host.Core var dmPorts = await databaseContext .DreamMakerSettings .AsQueryable() + .Where(x => x.Instance.SwarmIdentifer == swarmConfiguration.Identifier) .Select(x => x.ApiValidationPort) .ToListAsync(cancellationToken) .ConfigureAwait(false);