diff --git a/build/Version.props b/build/Version.props
index ed5e4717c5..b35f68476a 100644
--- a/build/Version.props
+++ b/build/Version.props
@@ -4,7 +4,7 @@
4.12.0
- 3.0.1
+ 3.1.0
9.0.1
9.0.0
10.0.0
diff --git a/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs b/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs
index 18894682c1..6022ac421a 100644
--- a/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs
+++ b/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs
@@ -10,11 +10,6 @@
///
public const string Section = "Elasticsearch";
- ///
- /// Default value of .
- ///
- const bool DefaultEnable = false;
-
///
/// Default value of .
///
@@ -33,7 +28,7 @@
///
/// Do we want to enable elasticsearch or not?.
///
- public bool Enable { get; set; } = DefaultEnable;
+ public bool Enable { get; set; }
///
/// The host of the elasticsearch endpoint.
diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index 43e0212e91..0e2433be42 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -120,6 +120,7 @@ namespace Tgstation.Server.Host.Core
services.UseStandardConfig(Configuration);
services.UseStandardConfig(Configuration);
services.UseStandardConfig(Configuration);
+ services.UseStandardConfig(Configuration);
// enable options which give us config reloading
services.AddOptions();
@@ -151,7 +152,6 @@ namespace Tgstation.Server.Host.Core
config.MinimumLevel.Override("System.Net.Http.HttpClient", microsoftEventLevel.Value);
}
},
- Configuration,
sinkConfig =>
{
if (postSetupServices.FileLoggingConfiguration.Disable)
@@ -179,7 +179,7 @@ namespace Tgstation.Server.Host.Core
flushToDiskInterval: TimeSpan.FromSeconds(2),
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true);
- });
+ }, postSetupServices.ElasticsearchConfiguration);
// configure bearer token validation
services
diff --git a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs
index ba38928a55..752c2e9459 100644
--- a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs
+++ b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs
@@ -3,13 +3,13 @@ using System.Diagnostics;
using System.Globalization;
using Elastic.CommonSchema.Serilog;
-
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Configuration;
using Serilog.Sinks.Elasticsearch;
+
using Tgstation.Server.Host.Configuration;
namespace Tgstation.Server.Host.Extensions
@@ -59,14 +59,14 @@ namespace Tgstation.Server.Host.Extensions
///
/// The to configure.
/// Additional configuration for a given .
- /// The service configuration for a given .
/// Additional configuration for a given .
+ /// Configuration for a given .
/// The updated .
public static IServiceCollection SetupLogging(
this IServiceCollection serviceCollection,
Action configurationAction,
- IConfiguration tgsConfiguration,
- Action sinkConfigurationAction = null)
+ Action sinkConfigurationAction = null,
+ ElasticsearchConfiguration esc = null)
=> serviceCollection.AddLogging(builder =>
{
builder.ClearProviders();
@@ -89,28 +89,24 @@ namespace Tgstation.Server.Host.Extensions
sinkConfigurationAction?.Invoke(sinkConfiguration);
});
- string elasticsearchEndpoint = tgsConfiguration.GetSection("Elasticsearch").GetSection("Host").Value;
- string elasticsearchUser = tgsConfiguration.GetSection("Elasticsearch").GetSection("Username").Value;
- string elasticsearchPassword = tgsConfiguration.GetSection("Elasticsearch").GetSection("Password").Value;
- string raw_bool = tgsConfiguration.GetSection("Elasticsearch").GetSection("Enable").Value;
- bool elasticsearchEnabled = false;
-
- if (!string.IsNullOrEmpty(raw_bool))
- elasticsearchEnabled = bool.Parse(raw_bool);
-
- if (elasticsearchEnabled)
+ if (esc != null)
{
- if (elasticsearchEndpoint == null)
- throw new InvalidOperationException("Elasticsearch endpoint is null!");
-
- configuration.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(elasticsearchEndpoint))
+ if (esc.Enable)
{
- ModifyConnectionSettings = x => (!string.IsNullOrEmpty(elasticsearchUser) && !string.IsNullOrEmpty(elasticsearchPassword)) ? x.BasicAuthentication(elasticsearchUser, elasticsearchPassword) : null,
- CustomFormatter = new EcsTextFormatter(),
- AutoRegisterTemplate = true,
- AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
- IndexFormat = "tgs4-logs",
- });
+ if (esc.Host == null)
+ throw new InvalidOperationException("Elasticsearch endpoint is null!");
+
+ configuration.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(esc.Host))
+ {
+ // Yes I know this means they cannot use a self signed cert unless they also have authentication, but lets be real here
+ // No one is going to be doing one of thsoe but not the other
+ ModifyConnectionSettings = x => (!string.IsNullOrEmpty(esc.Username) && !string.IsNullOrEmpty(esc.Password)) ? x.BasicAuthentication(esc.Username, esc.Password).ServerCertificateValidationCallback((o, certificate, arg3, arg4) => { return true; }) : null,
+ CustomFormatter = new EcsTextFormatter(),
+ AutoRegisterTemplate = true,
+ AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
+ IndexFormat = "tgs4-logs",
+ });
+ }
}
builder.AddSerilog(configuration.CreateLogger(), true);
diff --git a/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs b/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs
index 43ec10a002..e531d97029 100644
--- a/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs
+++ b/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs
@@ -28,6 +28,11 @@ namespace Tgstation.Server.Host.Setup
///
FileLoggingConfiguration FileLoggingConfiguration { get; }
+ ///
+ /// The .
+ ///
+ ElasticsearchConfiguration ElasticsearchConfiguration { get; }
+
///
/// The .
///
diff --git a/src/Tgstation.Server.Host/Setup/PostSetupServices.cs b/src/Tgstation.Server.Host/Setup/PostSetupServices.cs
index 684b1bc1ab..8c2fe9805f 100644
--- a/src/Tgstation.Server.Host/Setup/PostSetupServices.cs
+++ b/src/Tgstation.Server.Host/Setup/PostSetupServices.cs
@@ -29,6 +29,9 @@ namespace Tgstation.Server.Host.Setup
///
public ILogger Logger { get; }
+ ///
+ public ElasticsearchConfiguration ElasticsearchConfiguration => elasticsearchConfigurationOptions.Value;
+
///
/// Backing for .
///
@@ -49,6 +52,11 @@ namespace Tgstation.Server.Host.Setup
///
readonly IOptions fileLoggingConfigurationOptions;
+ ///
+ /// Backing for .
+ ///
+ readonly IOptions elasticsearchConfigurationOptions;
+
///
/// Initializes a new instance of the class.
///
@@ -58,13 +66,15 @@ namespace Tgstation.Server.Host.Setup
/// The containing the value of .
/// The containing the value of .
/// The containing the value of .
+ /// The containing the value of .
public PostSetupServices(
IPlatformIdentifier platformIdentifier,
ILoggerFactory loggerFactory,
IOptions generalConfigurationOptions,
IOptions databaseConfigurationOptions,
IOptions securityConfigurationOptions,
- IOptions fileLoggingConfigurationOptions)
+ IOptions fileLoggingConfigurationOptions,
+ IOptions elasticsearchConfigurationOptions)
{
PlatformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
if (loggerFactory == null)
@@ -75,6 +85,7 @@ namespace Tgstation.Server.Host.Setup
this.databaseConfigurationOptions = databaseConfigurationOptions ?? throw new ArgumentNullException(nameof(databaseConfigurationOptions));
this.securityConfigurationOptions = securityConfigurationOptions ?? throw new ArgumentNullException(nameof(securityConfigurationOptions));
this.fileLoggingConfigurationOptions = fileLoggingConfigurationOptions ?? throw new ArgumentNullException(nameof(fileLoggingConfigurationOptions));
+ this.elasticsearchConfigurationOptions = elasticsearchConfigurationOptions ?? throw new ArgumentNullException(nameof(elasticsearchConfigurationOptions));
}
}
}
diff --git a/src/Tgstation.Server.Host/Setup/SetupApplication.cs b/src/Tgstation.Server.Host/Setup/SetupApplication.cs
index 9b940fd128..9ab9a8256b 100644
--- a/src/Tgstation.Server.Host/Setup/SetupApplication.cs
+++ b/src/Tgstation.Server.Host/Setup/SetupApplication.cs
@@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.Setup
if (services == null)
throw new ArgumentNullException(nameof(services));
- services.SetupLogging(config => config.MinimumLevel.Override("Microsoft", LogEventLevel.Warning), Configuration);
+ services.SetupLogging(config => config.MinimumLevel.Override("Microsoft", LogEventLevel.Warning));
services.AddSingleton(IOManager);
services.AddSingleton(AssemblyInformationProvider);
@@ -62,6 +62,7 @@ namespace Tgstation.Server.Host.Setup
services.AddSingleton();
services.AddSingleton();
+ // these configs are what's injected into PostSetupServices
services.UseStandardConfig(Configuration);
services.UseStandardConfig(Configuration);
services.UseStandardConfig(Configuration);