diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..1c9a54e
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,334 @@
+### VisualStudio ###
+
+# Tool Runtime Dir
+**/.dotnet/
+**/.packages/
+**/.tools/
+
+# User-specific files
+**/*.suo
+**/*.user
+**/*.userosscache
+**/*.sln.docstates
+
+# Build results
+**/artifacts/
+**/.idea/
+**/[Dd]ebug/
+**/[Dd]ebugPublic/
+**/[Rr]elease/
+**/[Rr]eleases/
+**/bld/
+**/[Bb]in/
+**/[Oo]bj/
+**/msbuild.log
+**/msbuild.err
+**/msbuild.wrn
+**/msbuild.binlog
+**/.deps/
+**/.dirstamp
+**/.libs/
+**/*.lo
+**/*.o
+
+# Cross building rootfs
+**/cross/rootfs/
+**/cross/android-rootfs/
+
+# Visual Studio
+**/.vs/
+
+# Ionide
+**/.ionide/
+
+# MSTest test Results
+**/[Tt]est[Rr]esult*/
+**/[Bb]uild[Ll]og.*
+
+#NUNIT
+**/*.VisualState.xml
+**/TestResult.xml
+
+# Build Results of an ATL Project
+**/[Dd]ebugPS/
+**/[Rr]eleasePS/
+**/dlldata.c
+
+**/*_i.c
+**/*_p.c
+**/*.ilk
+**/*.meta
+**/*.obj
+**/*.pch
+**/*.pdb
+!**/_.pdb
+**/*.pgc
+**/*.pgd
+**/*.rsp
+**/*.sbr
+**/*.tlb
+**/*.tli
+**/*.tlh
+**/*.tmp
+**/*.tmp_proj
+**/*.log
+**/*.vspscc
+**/*.vssscc
+**/.builds
+**/*.pidb
+**/*.svclog
+**/*.scc
+
+# Chutzpah Test files
+**/_Chutzpah*
+
+# Visual C++ cache files
+**/ipch/
+**/*.aps
+**/*.ncb
+**/*.opendb
+**/*.opensdf
+**/*.sdf
+**/*.cachefile
+**/*.VC.db
+
+# Visual Studio profiler
+**/*.psess
+**/*.vsp
+**/*.vspx
+
+# TFS 2012 Local Workspace
+**/$tf/
+
+# Guidance Automation Toolkit
+**/*.gpState
+
+# ReSharper is a .NET coding add-in
+**/_ReSharper*/
+**/*.[Rr]e[Ss]harper
+**/*.DotSettings.user
+
+# JustCode is a .NET coding addin-in
+**/.JustCode
+
+# TeamCity is a build add-in
+**/_TeamCity*
+
+# DotCover is a Code Coverage Tool
+**/*.dotCover
+
+# NCrunch
+**/_NCrunch_*
+**/.*crunch*.local.xml
+
+# MightyMoose
+**/*.mm.*
+**/AutoTest.Net/
+
+# Web workbench (sass)
+**/.sass-cache/
+
+# Installshield output folder
+**/[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+**/DocProject/buildhelp/
+**/DocProject/Help/*.HxT
+**/DocProject/Help/*.HxC
+**/DocProject/Help/*.hhc
+**/DocProject/Help/*.hhk
+**/DocProject/Help/*.hhp
+**/DocProject/Help/Html2
+**/DocProject/Help/html
+
+# Publish Web Output
+**/*.[Pp]ublish.xml
+**/*.azurePubxml
+**/*.pubxml
+**/*.publishproj
+
+# NuGet Packages
+**/*.nupkg
+**/*.nuget.g.props
+**/*.nuget.g.targets
+**/*.nuget.cache
+**/**/packages/*
+**/project.lock.json
+**/project.assets.json
+**/*.nuget.dgspec.json
+
+# Windows Azure Build Output
+**/csx/
+**/*.build.csdef
+
+# Windows Store app package directory
+**/AppPackages/
+
+# Others
+**/*.Cache
+**/ClientBin/
+**/[Ss]tyle[Cc]op.*
+**/~$*
+**/*.dbmdl
+**/*.dbproj.schemaview
+**/*.pfx
+**/*.publishsettings
+**/node_modules/
+**/*.metaproj
+**/*.metaproj.tmp
+**/bin.localpkg/
+
+# RIA/Silverlight projects
+**/Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+**/_UpgradeReport_Files/
+**/Backup*/
+**/UpgradeLog*.XML
+**/UpgradeLog*.htm
+
+# SQL Server files
+**/*.mdf
+**/*.ldf
+
+# Business Intelligence projects
+**/*.rdl.data
+**/*.bim.layout
+**/*.bim_*.settings
+
+# Microsoft Fakes
+**/FakesAssemblies/
+
+# C/C++ extension for Visual Studio Code
+**/browse.VC.db
+# Local settings folder for Visual Studio Code
+**/**/.vscode/**
+!**/**/.vscode/c_cpp_properties.json
+
+### MonoDevelop ###
+
+**/*.pidb
+**/*.userprefs
+
+### Windows ###
+
+# Windows image file caches
+**/Thumbs.db
+**/ehthumbs.db
+
+# Folder config file
+**/Desktop.ini
+
+# Recycle Bin used on file shares
+**/$RECYCLE.BIN/
+
+# Windows Installer files
+**/*.cab
+**/*.msi
+**/*.msm
+**/*.msp
+
+# Windows shortcuts
+**/*.lnk
+
+### Linux ###
+
+**/*~
+
+# KDE directory preferences
+**/.directory
+
+### OSX ###
+
+**/.DS_Store
+**/.AppleDouble
+**/.LSOverride
+
+# Icon must end with two \r
+**/Icon
+
+# Thumbnails
+**/._*
+
+# Files that might appear on external disk
+**/.Spotlight-V100
+**/.Trashes
+
+# Directories potentially created on remote AFP share
+**/.AppleDB
+**/.AppleDesktop
+**/Network Trash Folder
+**/Temporary Items
+**/.apdisk
+
+# vim temporary files
+**/[._]*.s[a-w][a-z]
+**/[._]s[a-w][a-z]
+**/*.un~
+**/Session.vim
+**/.netrwhist
+**/*~
+
+# Visual Studio Code
+**/.vscode/
+
+# Private test configuration and binaries.
+**/config.ps1
+**/**/IISApplications
+
+# VS debug support files
+**/launchSettings.json
+
+# Snapcraft files
+**/.snapcraft
+**/*.snap
+**/parts/
+**/prime/
+**/stage/
+
+# CLR prebuilt generated files
+!**/src/pal/prebuilt/idl/*_i.c
+
+# Valid 'debug' folder, that contains CLR debugging code
+!**/src/**/debug
+
+# Ignore folders created by the CLR test build
+**/TestWrappers_x64_[d|D]ebug
+**/TestWrappers_x64_[c|C]hecked
+**/TestWrappers_x64_[r|R]elease
+**/TestWrappers_x86_[d|D]ebug
+**/TestWrappers_x86_[c|C]hecked
+**/TestWrappers_x86_[r|R]elease
+**/TestWrappers_arm_[d|D]ebug
+**/TestWrappers_arm_[c|C]hecked
+**/TestWrappers_arm_[r|R]elease
+**/TestWrappers_arm64_[d|D]ebug
+**/TestWrappers_arm64_[c|C]hecked
+**/TestWrappers_arm64_[r|R]elease
+**/tests/src/common/test_runtime/project.json
+
+**/Vagrantfile
+**/.vagrant
+
+# CMake files
+**/CMakeFiles/
+**/cmake_install.cmake
+**/CMakeCache.txt
+**/Makefile
+
+# Cross compilation
+**/cross/rootfs/*
+**/cross/android-rootfs/*
+# add x86 as it is ignored in 'Build results'
+!**/cross/x86
+
+#python import files
+**/*.pyc
+
+# JIT32 files
+**/src/jit32
+
+# performance testing sandbox
+**/sandbox
\ No newline at end of file
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 7cc8f80..34cb210 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -13,20 +13,22 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3.5.2
+ - uses: actions/checkout@main
- name: Setup .NET 8
uses: actions/setup-dotnet@main
with:
dotnet-version: 8.x
- name: Restore
- run: dotnet restore
+ run: dotnet restore NewDarkGlobalServer.sln
- name: Build
- run: dotnet build --no-restore
+ run: dotnet build NewDarkGlobalServer.sln --no-restore
- name: Publish
- run: dotnet publish -p:PublishProfile=Properties/PublishProfiles/linux-x64.pubxml
+ run: dotnet publish NewDarkGlobalServer.sln -p:PublishProfile=Properties/PublishProfiles/linux-x64.pubxml
- name: Upload
uses: actions/upload-artifact@main
with:
name: Binaries (linux-x64)
path: src/bin/Publish/linux-x64
- if-no-files-found: error
\ No newline at end of file
+ if-no-files-found: error
+ - name: docker compose build
+ run: docker compose build
\ No newline at end of file
diff --git a/NewDarkGlobalServer.sln b/NewDarkGlobalServer.sln
index 289a9e3..fa25b6c 100644
--- a/NewDarkGlobalServer.sln
+++ b/NewDarkGlobalServer.sln
@@ -6,15 +6,13 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC2AF12-8010-453B-8971-E688ADC7C9F4}"
ProjectSection(SolutionItems) = preProject
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
- publish_linux-arm64.sh = publish_linux-arm64.sh
- publish_linux-x64.sh = publish_linux-x64.sh
- publish_win-arm64.bat = publish_win-arm64.bat
- publish_win-x64.bat = publish_win-x64.bat
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewDarkGlobalServer", "src\NewDarkGlobalServer.csproj", "{59AC9055-C90F-4CA9-8BAF-483A33B8DB2D}"
EndProject
+Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{A0B1EDF7-85ED-42B6-93D8-A20DD4D6726D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -28,6 +26,12 @@ Global
{59AC9055-C90F-4CA9-8BAF-483A33B8DB2D}.Release|Any CPU.Build.0 = Release|Any CPU
{59AC9055-C90F-4CA9-8BAF-483A33B8DB2D}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU
{59AC9055-C90F-4CA9-8BAF-483A33B8DB2D}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU
+ {A0B1EDF7-85ED-42B6-93D8-A20DD4D6726D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A0B1EDF7-85ED-42B6-93D8-A20DD4D6726D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A0B1EDF7-85ED-42B6-93D8-A20DD4D6726D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A0B1EDF7-85ED-42B6-93D8-A20DD4D6726D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A0B1EDF7-85ED-42B6-93D8-A20DD4D6726D}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
+ {A0B1EDF7-85ED-42B6-93D8-A20DD4D6726D}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/README.md b/README.md
index a63bbc4..2c0954d 100644
--- a/README.md
+++ b/README.md
@@ -44,13 +44,15 @@ Options:
-c, --timeoutclient=VALUE Sets timeout for game clients in seconds. Default
is 3600 seconds (01:00:00).
-u, --timeoutunidentified=VALUE
- Sets timeout for connections to indentify as client
- or server in seconds. Default is 10 seconds (00:00:10).
+ Sets timeout for connections to indentify as
+ client or server in seconds. Default is 10
+ seconds (00:00:10).
-b, --showheartbeatminimal Shows HeartbeatMinimal messages in the log. Each
connected game server sends one every 10 seconds
so the log may become cluttered.
-f, --hidefailedconn Hides failed connections attempts (due to invalid
or unknown messages) from the log.
+ -t, --printtimestamps Adds timestamps to the log output.
-v, --verbose Shows more verbose messages in the log.
-h, --help Prints this helpful option list and exits.
```
diff --git a/docker-compose.dcproj b/docker-compose.dcproj
new file mode 100644
index 0000000..37b5317
--- /dev/null
+++ b/docker-compose.dcproj
@@ -0,0 +1,13 @@
+
+
+
+ 2.1
+ Linux
+ False
+ a0b1edf7-85ed-42b6-93d8-a20dd4d6726d
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..7eb3b1b
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,10 @@
+version: '3.4'
+
+services:
+ newdarkglobalserver:
+ image: ${DOCKER_REGISTRY-}newdarkglobalserver
+ build:
+ context: .
+ dockerfile: src/Dockerfile
+ ports:
+ - 5199:5199
\ No newline at end of file
diff --git a/launchSettings.json b/launchSettings.json
new file mode 100644
index 0000000..ef64f5a
--- /dev/null
+++ b/launchSettings.json
@@ -0,0 +1,11 @@
+{
+ "profiles": {
+ "Docker Compose": {
+ "commandName": "DockerCompose",
+ "commandVersion": "1.0",
+ "serviceActions": {
+ "newdarkglobalserver": "StartDebugging"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Dockerfile b/src/Dockerfile
new file mode 100644
index 0000000..7e90d31
--- /dev/null
+++ b/src/Dockerfile
@@ -0,0 +1,24 @@
+#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
+
+FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base
+EXPOSE 5199
+USER app
+WORKDIR /app
+
+FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
+ARG BUILD_CONFIGURATION=Release
+WORKDIR /src
+COPY ["src/NewDarkGlobalServer.csproj", "src/"]
+RUN dotnet restore "./src/./NewDarkGlobalServer.csproj"
+COPY . .
+WORKDIR "/src/src"
+RUN dotnet build "./NewDarkGlobalServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
+
+FROM build AS publish
+ARG BUILD_CONFIGURATION=Release
+RUN dotnet publish "./NewDarkGlobalServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "NewDarkGlobalServer.dll", "-t"]
\ No newline at end of file
diff --git a/src/Logging.cs b/src/Logging.cs
index 1b4b670..1ab7343 100644
--- a/src/Logging.cs
+++ b/src/Logging.cs
@@ -7,13 +7,18 @@
namespace NewDarkGlobalServer
{
- internal class Logging
+ internal static class Logging
{
///
/// If verbose messages should be logged.
///
public static bool Verbose = false;
+ ///
+ /// If timestamps should be included in logged output.
+ ///
+ public static bool PrintTimeStamps = false;
+
static readonly object _logWriteLineLock = new();
private readonly record struct DelayedWriteLine(DateTimeOffset Timestamp, string PrimayMessage, string SecondaryMessage, string? Verbose);
@@ -24,9 +29,12 @@ public static void LogWriteLine(string message)
{
lock (_logWriteLineLock)
{
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.Write($"[{DateTimeOffset.Now}] ");
- Console.ResetColor();
+ if (PrintTimeStamps)
+ {
+ Console.ForegroundColor = ConsoleColor.DarkGray;
+ Console.Write($"[{DateTimeOffset.Now}] ");
+ Console.ResetColor();
+ }
Console.WriteLine(message);
}
}
@@ -83,9 +91,12 @@ public static void LogWriteLine(Guid guid, string primayMessage, string secondar
private static void LogWriteLineInternal(DateTimeOffset timestamp, string primayMessage, string secondaryMessage, string? verbose = null)
{
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.Write($"[{timestamp}] ");
- Console.ResetColor();
+ if (PrintTimeStamps)
+ {
+ Console.ForegroundColor = ConsoleColor.DarkGray;
+ Console.Write($"[{timestamp}] ");
+ Console.ResetColor();
+ }
if (secondaryMessage == null)
{
@@ -120,8 +131,12 @@ public static void ConnectionsWriteLine(IEnumerable connections)
var serverClosedCount = currentConnections.Count(c => c.Status == ConnectionStatus.AwaitServerCommand && c.ServerInfo?.StateFlags == GameStateFlags.Closed);
var clientCount = currentConnections.Count(c => c.Status == ConnectionStatus.AwaitClientCommand);
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.Write($"[{DateTimeOffset.Now}] ");
+ if (PrintTimeStamps)
+ {
+ Console.ForegroundColor = ConsoleColor.DarkGray;
+ Console.Write($"[{DateTimeOffset.Now}] ");
+ }
+
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write($"{conenctionCount} open connection{(conenctionCount != 1 ? "s" : string.Empty)} ");
Console.ForegroundColor = ConsoleColor.DarkGray;
@@ -136,9 +151,12 @@ public static void ErrorWriteLine(Guid guid, string primayMessage, string? secon
{
FlushDelayed(guid);
- Console.ForegroundColor = ConsoleColor.DarkGray;
- Console.Write($"[{DateTimeOffset.Now}] ");
- Console.ResetColor();
+ if (PrintTimeStamps)
+ {
+ Console.ForegroundColor = ConsoleColor.DarkGray;
+ Console.Write($"[{DateTimeOffset.Now}] ");
+ Console.ResetColor();
+ }
if (secondaryMessage == null)
{
diff --git a/src/NewDarkGlobalServer.csproj b/src/NewDarkGlobalServer.csproj
index c3da38a..e3d8ec5 100644
--- a/src/NewDarkGlobalServer.csproj
+++ b/src/NewDarkGlobalServer.csproj
@@ -7,8 +7,9 @@
NewDarkGlobalServer
App.manifest
App.ico
+ Linux
Debug;Release;ReleaseSigned
- 1.3.0
+ 1.3.1
@@ -39,9 +40,9 @@
full
Speed
- false
+ true
- false
+ true
@@ -49,6 +50,7 @@
+
diff --git a/src/Program.cs b/src/Program.cs
index c4e018e..73ec8a5 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -27,6 +27,7 @@ public static async Task Main(string[] args)
{ "u|timeoutunidentified=", $"Sets timeout for connections to indentify as client or server in seconds. Default is {UnidentifiedConnectionTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture)} seconds ({UnidentifiedConnectionTimeout:c}).", (int u) => UnidentifiedConnectionTimeout = TimeSpan.FromSeconds(u) },
{ "b|showheartbeatminimal", "Shows HeartbeatMinimal messages in the log. Each connected game server sends one every 10 seconds so the log may become cluttered.", b => ShowHeartbeatMinimal = b != null },
{ "f|hidefailedconn", "Hides failed connections attempts (due to invalid or unknown messages) from the log.", f => HideInvalidMessageTypes = f != null },
+ { "t|printtimestamps", "Adds timestamps to the log output.", f => PrintTimeStamps = f != null },
{ "v|verbose", "Shows more verbose messages in the log.", v => Verbose = v != null },
{ "h|help", "Prints this helpful option list and exits.", h => showHelp = h != null },
};
diff --git a/src/Properties/launchSettings.json b/src/Properties/launchSettings.json
new file mode 100644
index 0000000..fe0a0f4
--- /dev/null
+++ b/src/Properties/launchSettings.json
@@ -0,0 +1,14 @@
+{
+ "profiles": {
+ "NewDarkGlobalServer": {
+ "commandName": "Project"
+ },
+ "WSL": {
+ "commandName": "WSL2",
+ "distributionName": ""
+ },
+ "Docker": {
+ "commandName": "Docker"
+ }
+ }
+}
\ No newline at end of file