Skip to content

Commit 8869799

Browse files
authored
Update NWNX/NWN.Core/NWN.Native. (#849)
* Update NWNX/NWN.Core/NWN.Native. * Update image to ubuntu 22.04. * Run container privileged to allow lldb debugger to attach. * Include lldb in dev container dependencies. * Install .NET SOS tools on dev container create. * Add OpenSSL version verification. * Cleanup unused dependencies. Compile OpenSSL 1.1.1t from source. Use 1.1 as OpenSSL version override. * Change base image to debian:trixie-slim.
1 parent e88976f commit 8869799

File tree

7 files changed

+72
-38
lines changed

7 files changed

+72
-38
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
"version": "8.0"
1515
},
1616
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
17-
"packages": "curl,unzip,procps,git"
17+
"packages": "curl,unzip,procps,git,lldb"
1818
}
1919
},
2020
"appPort": ["5121:5121/udp"],
2121
"containerEnv": {
2222
"NWNX_DOTNET_ASSEMBLY": "/workspaces/NWN.Anvil/NWN.Anvil/bin/Debug/net8.0/NWN.Anvil",
2323
"ANVIL_ADD_PLUGIN_PATHS": "/workspaces/NWN.Anvil/NWN.Anvil.TestRunner/bin/Debug:/workspaces/NWN.Anvil/NWN.Anvil.Tests/bin/Debug"
24-
}
24+
},
25+
"runArgs": ["--privileged"],
26+
"onCreateCommand": ["sh", "-c", "dotnet tool install --global dotnet-sos && /root/.dotnet/tools/dotnet-sos install"]
2527
}

NWN.Anvil.TestRunner/NWN.Anvil.TestRunner.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
</ItemGroup>
6464

6565
<ItemGroup>
66-
<PackageReference Include="NWN.Core" Version="8193.37.3" PrivateAssets="compile" />
67-
<PackageReference Include="NWN.Native" Version="8193.37.3" PrivateAssets="compile" />
66+
<PackageReference Include="NWN.Core" Version="8193.37.4" PrivateAssets="compile" />
67+
<PackageReference Include="NWN.Native" Version="8193.37.4" PrivateAssets="compile" />
6868
</ItemGroup>
6969

7070
<ItemGroup>

NWN.Anvil.Tests/NWN.Anvil.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545

4646
<ItemGroup>
4747
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
48-
<PackageReference Include="NWN.Core" Version="8193.37.3" PrivateAssets="compile" />
49-
<PackageReference Include="NWN.Native" Version="8193.37.3" PrivateAssets="compile" />
48+
<PackageReference Include="NWN.Core" Version="8193.37.4" PrivateAssets="compile" />
49+
<PackageReference Include="NWN.Native" Version="8193.37.4" PrivateAssets="compile" />
5050
</ItemGroup>
5151

5252
</Project>

NWN.Anvil/NWN.Anvil.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
6868
<PackageReference Include="NLog" Version="5.4.0" />
6969
<PackageReference Include="Paket.Core" Version="8.0.3" PrivateAssets="all" />
70-
<PackageReference Include="NWN.Core" Version="8193.37.3" PrivateAssets="compile" />
71-
<PackageReference Include="NWN.Native" Version="8193.37.3" PrivateAssets="compile" />
70+
<PackageReference Include="NWN.Core" Version="8193.37.4" PrivateAssets="compile" />
71+
<PackageReference Include="NWN.Native" Version="8193.37.4" PrivateAssets="compile" />
7272
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
7373
</ItemGroup>
7474

NWN.Anvil/src/main/AnvilCore.cs

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Reflection;
33
using System.Runtime.CompilerServices;
44
using System.Runtime.InteropServices;
5+
using System.Security.Cryptography;
56
using Anvil.API;
67
using Anvil.Internal;
78
using Anvil.Services;
@@ -19,10 +20,11 @@ namespace Anvil
1920
/// </summary>
2021
public sealed partial class AnvilCore
2122
{
23+
private const int ExpectedOpenSslVersion = 269488463;
24+
2225
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
2326

2427
private static AnvilCore instance = null!;
25-
2628
private readonly IServiceManager serviceManager;
2729

2830
private AnvilCore(IServiceManager serviceManager)
@@ -79,20 +81,6 @@ public static void Reload()
7981
}, TimeSpan.FromSeconds(0.1));
8082
}
8183

82-
private void CheckServerVersion()
83-
{
84-
AssemblyName assemblyName = Assemblies.Anvil.GetName();
85-
Version serverVersion = NwServer.Instance.ServerVersion;
86-
87-
if (assemblyName.Version?.Major != serverVersion.Major || assemblyName.Version.Minor != serverVersion.Minor)
88-
{
89-
Log.Warn("The current version of {Name} targets version {TargetVersion}, but the server is running {ServerVersion}! You may encounter compatibility issues",
90-
assemblyName.Name,
91-
assemblyName.Version,
92-
serverVersion);
93-
}
94-
}
95-
9684
private void Init()
9785
{
9886
runtimeInfo = new RuntimeInfo
@@ -118,6 +106,40 @@ private void Init()
118106

119107
Log.Info($"Loading {runtimeInfo.AssemblyName} {runtimeInfo.AssemblyVersion} (NWN.Core: {runtimeInfo.CoreVersion}, NWN.Native: {runtimeInfo.NativeVersion}, NWNX.NET: {runtimeInfo.NWNXDotNetVersion})");
120108
CheckServerVersion();
109+
CheckOpenSslVersion();
110+
}
111+
112+
private void CheckServerVersion()
113+
{
114+
AssemblyName assemblyName = Assemblies.Anvil.GetName();
115+
Version serverVersion = NwServer.Instance.ServerVersion;
116+
117+
if (assemblyName.Version?.Major != serverVersion.Major || assemblyName.Version.Minor != serverVersion.Minor)
118+
{
119+
Log.Warn("The current version of {Name} targets version {TargetVersion}, but the server is running {ServerVersion}! You may encounter compatibility issues",
120+
assemblyName.Name,
121+
assemblyName.Version,
122+
serverVersion);
123+
}
124+
}
125+
126+
private void CheckOpenSslVersion()
127+
{
128+
if (!OperatingSystem.IsLinux())
129+
{
130+
return;
131+
}
132+
133+
Log.Info("Checking OpenSSL version. If the server crashes, see this page for troubleshooting: https://github.com/nwn-dotnet/Anvil/wiki/Troubleshooting-OpenSSL-Issues");
134+
LogManager.Flush();
135+
136+
long version = SafeEvpPKeyHandle.OpenSslVersion;
137+
if (version != ExpectedOpenSslVersion)
138+
{
139+
Log.Warn($"DotNET is currently using OpenSSL version '{version}' which differs from the bundled game version '{version}'.\n" +
140+
$"You may experience crashes/undefined behaviour.\n" +
141+
$"See this page for troubleshooting: https://github.com/nwn-dotnet/Anvil/wiki/Troubleshooting-OpenSSL-Issues");
142+
}
121143
}
122144

123145
private void LoadAndStart()

dockerfile

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
# Load nwnx image to import nwserver + nwnx plugins
2-
FROM nwnxee/unified:292a2c0 as nwnx
2+
FROM nwnxee/unified:73cf6ab as nwnx
33

44
# Remove incompatible plugins
55
RUN rm -rf /nwn/nwnx/NWNX_Ruby.so \
66
/nwn/nwnx/NWNX_SpellChecker.so \
77
/nwn/nwnx/NWNX_Redis.so
88

9-
FROM ubuntu:20.04
9+
FROM debian:trixie-slim
1010

1111
COPY --from=nwnx /nwn /nwn
1212

13+
ENV OPENSSL_VERSION="OpenSSL_1_1_1t"
14+
1315
RUN apt-get update \
14-
&& apt-get --no-install-recommends -y install ca-certificates wget \
15-
&& wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
16+
&& apt-get install -y --no-install-recommends \
17+
ca-certificates \
18+
wget \
19+
git \
20+
build-essential \
21+
&& git clone https://github.com/openssl/openssl.git \
22+
&& cd openssl \
23+
&& git checkout ${OPENSSL_VERSION} \
24+
&& ./config --prefix=/nwn/lib/openssl --openssldir=/nwn/lib/openssl \
25+
&& make depend \
26+
&& make install \
27+
&& cd .. \
28+
&& rm -rf openssl \
29+
&& wget https://packages.microsoft.com/config/debian/13/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
1630
&& dpkg -i packages-microsoft-prod.deb \
1731
&& rm packages-microsoft-prod.deb \
1832
&& apt-get update \
19-
&& apt-get --no-install-recommends -y install libc6 libstdc++6 \
20-
hunspell \
21-
default-libmysqlclient-dev \
22-
libmariadb3 \
23-
libpq5 \
24-
libsqlite3-0 \
25-
luajit libluajit-5.1-2 \
26-
inotify-tools \
27-
patch \
28-
unzip \
33+
&& apt-get install -y --no-install-recommends \
2934
dotnet-runtime-8.0 \
3035
dotnet-apphost-pack-8.0 \
3136
&& rm -rf /var/cache/apt /var/lib/apt/lists/*
@@ -50,6 +55,7 @@ VOLUME /nwn/home
5055
# Configure nwserver to run with nwnx
5156
ENV NWNX_CORE_LOAD_PATH=/nwn/nwnx/
5257
ENV NWN_LD_PRELOAD="/nwn/nwnx/NWNX_Core.so"
58+
ENV NWN_LD_LIBRARY_PATH="/nwn/lib/openssl/lib"
5359

5460
# Configure nwnx to run with anvil
5561
ENV NWNX_DOTNET_SKIP=n
@@ -76,6 +82,10 @@ ENV DOTNET_CreateDumpVerboseDiagnostics=1
7682
ENV DOTNET_DbgMiniDumpName=/nwn/run/logs.0/anvil-crash-%t.dmp
7783
ENV DOTNET_CreateDumpLogToFile=/nwn/run/logs.0/anvil-crash.log
7884

85+
#Force .NET to use OpenSSL 1.1.1
86+
ENV CLR_OPENSSL_VERSION_OVERRIDE=1.1
87+
ENV DOTNET_OPENSSL_VERSION_OVERRIDE=1.1
88+
7989
# Entrypoint & Executable
8090
EXPOSE ${NWN_PORT:-5121}/udp
8191

docs/NWN.Anvil.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</PropertyGroup>
3131

3232
<ItemGroup>
33-
<PackageReference Include="NWN.Core" Version="8193.37.3" PrivateAssets="compile" />
33+
<PackageReference Include="NWN.Core" Version="8193.37.4" PrivateAssets="compile" />
3434
</ItemGroup>
3535

3636
<ItemGroup>

0 commit comments

Comments
 (0)