Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions NWN.Anvil/src/main/AnvilCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Anvil
/// </summary>
public sealed partial class AnvilCore
{
private const string ExpectedOpenSslEnvironmentValue = "1.1";
private const int ExpectedOpenSslVersion = 269488463;

private static readonly Logger Log = LogManager.GetCurrentClassLogger();
Expand Down Expand Up @@ -131,6 +132,14 @@ private void CheckOpenSslVersion()
}

Log.Info("Checking OpenSSL version. If the server crashes, see this page for troubleshooting: https://github.com/nwn-dotnet/Anvil/wiki/Troubleshooting-OpenSSL-Issues");

if (EnvironmentConfig.OpenSslVersionOverride != ExpectedOpenSslEnvironmentValue)
{
const string message = "Environment variable 'DOTNET_OPENSSL_VERSION_OVERRIDE' is not set. Please see the OpenSSL troubleshooting page for more info.";
Log.Fatal(message);
throw new Exception(message);
}

LogManager.Flush();

long version = SafeEvpPKeyHandle.OpenSslVersion;
Expand Down
19 changes: 5 additions & 14 deletions NWN.Anvil/src/main/Internal/EnvironmentConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ public static class EnvironmentConfig
{
private static readonly string[] VariablePrefixes = ["ANVIL_", "NWM_"];

public static readonly string? OpenSslVersionOverride = Environment.GetEnvironmentVariable("DOTNET_OPENSSL_VERSION_OVERRIDE");

public static readonly string AnvilHome = GetAnvilVariableString("HOME", "./anvil");
public static readonly string Encoding = GetAnvilVariableString("ENCODING", "windows-1252");

public static readonly LogMode LogMode = GetAnvilVariableEnum("LOG_MODE", LogMode.Default);

public static readonly bool NativePrelinkEnabled = GetAnvilVariableBool("PRELINK_ENABLED", true);
public static readonly bool PreventStartNoPlugin = GetAnvilVariableBool("PREVENT_START_NO_PLUGIN");
public static readonly bool ReloadEnabled = GetAnvilVariableBool("RELOAD_ENABLED");
public static readonly string[] AdditionalPluginPaths = GetAnvilVariableArrayString("ADD_PLUGIN_PATHS");

static EnvironmentConfig()
{
ValidateUnset("NLOG_CONFIG");
ValidateUnset("PLUGIN_PATH");
}
public static readonly string[] AdditionalPluginPaths = GetAnvilVariableArrayString("ADD_PLUGIN_PATHS");

public static bool GetIsPluginDisabled(string pluginName)
{
Expand Down Expand Up @@ -65,13 +64,5 @@ private static string[] GetAnvilVariableArrayString(string key, string[]? defaul

return value != null ? value.Split(Path.PathSeparator) : defaultValue;
}

private static void ValidateUnset(string key)
{
if (Environment.GetEnvironmentVariable(key) != null)
{
throw new Exception($"Unsupported environment variable {key}. Please see the changelog for more information.");
}
}
}
}
Loading