mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 14:37:44 +01:00
Fix default Elasticsearch configuration
This commit is contained in:
@@ -10,21 +10,6 @@
|
||||
/// </summary>
|
||||
public const string Section = "Elasticsearch";
|
||||
|
||||
/// <summary>
|
||||
/// Default value of <see cref="Host"/>.
|
||||
/// </summary>
|
||||
const string DefaultHost = "http://127.0.0.1:9200"; // localhost
|
||||
|
||||
/// <summary>
|
||||
/// Default value of <see cref="Username"/>.
|
||||
/// </summary>
|
||||
const string DefaultUsername = "my_username";
|
||||
|
||||
/// <summary>
|
||||
/// Default value of <see cref="Password"/>.
|
||||
/// </summary>
|
||||
const string DefaultPassword = "my_password";
|
||||
|
||||
/// <summary>
|
||||
/// Do we want to enable elasticsearch or not?.
|
||||
/// </summary>
|
||||
@@ -33,16 +18,16 @@
|
||||
/// <summary>
|
||||
/// The host of the elasticsearch endpoint.
|
||||
/// </summary>
|
||||
public string Host { get; set; } = DefaultHost;
|
||||
public string Host { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Username for elasticsearch.
|
||||
/// </summary>
|
||||
public string Username { get; set; } = DefaultUsername;
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Password for elasticsearch.
|
||||
/// </summary>
|
||||
public string Password { get; set; } = DefaultPassword;
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,11 +196,21 @@ namespace Tgstation.Server.Host.Core
|
||||
rollOnFileSizeLimit: true);
|
||||
},
|
||||
elasticsearchConfiguration.Enable
|
||||
? new ElasticsearchSinkOptions(new Uri(elasticsearchConfiguration.Host ?? throw new InvalidOperationException()))
|
||||
? new ElasticsearchSinkOptions(
|
||||
new Uri(
|
||||
String.IsNullOrWhiteSpace(elasticsearchConfiguration.Host)
|
||||
? throw new InvalidOperationException($"Missing {ElasticsearchConfiguration.Section}:{nameof(elasticsearchConfiguration.Host)}!")
|
||||
: elasticsearchConfiguration.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 = connectionConfigration => (!string.IsNullOrEmpty(elasticsearchConfiguration.Username) && !string.IsNullOrEmpty(elasticsearchConfiguration.Password)) ? connectionConfigration.BasicAuthentication(elasticsearchConfiguration.Username, elasticsearchConfiguration.Password).ServerCertificateValidationCallback((o, certificate, arg3, arg4) => { return true; }) : null,
|
||||
// No one is going to be doing one of those but not the other
|
||||
ModifyConnectionSettings = connectionConfigration => (!String.IsNullOrWhiteSpace(elasticsearchConfiguration.Username) && !String.IsNullOrWhiteSpace(elasticsearchConfiguration.Password))
|
||||
? connectionConfigration
|
||||
.BasicAuthentication(
|
||||
elasticsearchConfiguration.Username,
|
||||
elasticsearchConfiguration.Password)
|
||||
.ServerCertificateValidationCallback((o, certificate, chain, errors) => true)
|
||||
: null,
|
||||
CustomFormatter = new EcsTextFormatter(),
|
||||
AutoRegisterTemplate = true,
|
||||
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
|
||||
|
||||
Reference in New Issue
Block a user