Skip to content

Commit

Permalink
Update workflow and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila committed Nov 16, 2023
1 parent f57b19e commit 819ee7e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 23 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
name: Build project

on:
workflow_dispatch:
push:
branches: [ master ]
branches:
- 'master'
pull_request:
branches: [ master ]
branches:
- '**'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.5.2
- name: Setup .NET
uses: xt0rted/setup-dotnet@v1.5.0
- name: Setup .NET 8
uses: actions/setup-dotnet@main
with:
dotnet-version: 8.x
include-prerelease: true
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Publish
run: dotnet publish -p:PublishProfile=Properties/PublishProfiles/linux-x64.pubxml --no-restore
1 change: 1 addition & 0 deletions NewDarkGlobalServer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ VisualStudioVersion = 17.0.32112.339
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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Options:
-c, --timeoutclient=VALUE Sets timeout for game clients in seconds. Default
is 3600 seconds (01:00:00).
-u, --timeoutunidentified=VALUE
Sets timeout for game clients 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.
Expand Down
4 changes: 2 additions & 2 deletions src/CodeSigning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Code sign assemblies -->
<Target Name="CodeSignAssembliesBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)'=='ReleaseSigned'">
<Exec Command="powershell &quot;cd $(OutDir); &amp;'$(SignToolPath)signtool.exe' sign /n '$(SignSubjectName)' /tr '$(SignTimestampServerUrl)' /fd certHash /td certHash /tdchw /v ((Get-ChildItem -Include ('*.dll', '*.exe') -Recurse . | select -ExpandProperty FullName | ForEach-Object {'\&quot;' + $_ + '\&quot;\&quot;'}) -join ' ')&quot;" />
<Exec Command="powershell &quot;cd $(OutDir); &amp;'$(SignToolPath)signtool.exe' sign /n '$(SignSubjectName)' /tr '$(SignTimestampServerUrl)' /fd certHash /td certHash /fdchw /tdchw /v ((Get-ChildItem -Include ('*.dll', '*.exe') -Recurse . | select -ExpandProperty FullName | ForEach-Object {'\&quot;' + $_ + '\&quot;\&quot;'}) -join ' ')&quot;" />
</Target>

<Target Name="CodeSignAssembliesPublish" AfterTargets="Publish" Condition="'$(Configuration)'=='ReleaseSigned'">
<Exec Command="powershell &quot;cd $(PublishDir); &amp;'$(SignToolPath)signtool.exe' sign /n '$(SignSubjectName)' /tr '$(SignTimestampServerUrl)' /fd certHash /td certHash /tdchw /v ((Get-ChildItem -Include ('*.dll', '*.exe') -Recurse . | select -ExpandProperty FullName | ForEach-Object {'\&quot;' + $_ + '\&quot;\&quot;'}) -join ' ')&quot;" />
<Exec Command="powershell &quot;cd $(PublishDir); &amp;'$(SignToolPath)signtool.exe' sign /n '$(SignSubjectName)' /tr '$(SignTimestampServerUrl)' /fd certHash /td certHash /fdchw /tdchw /v ((Get-ChildItem -Include ('*.dll', '*.exe') -Recurse . | select -ExpandProperty FullName | ForEach-Object {'\&quot;' + $_ + '\&quot;\&quot;'}) -join ' ')&quot;" />
</Target>
</Project>
12 changes: 6 additions & 6 deletions src/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class Logging

static readonly object _logWriteLineLock = new();

private readonly record struct DelayedWriteLine(DateTime Timestamp, string PrimayMessage, string SecondaryMessage, string? Verbose);
private readonly record struct DelayedWriteLine(DateTimeOffset Timestamp, string PrimayMessage, string SecondaryMessage, string? Verbose);

static readonly ConcurrentDictionary<Guid, List<DelayedWriteLine>> _delayedWriteLines = new();

Expand All @@ -25,7 +25,7 @@ public static void LogWriteLine(string message)
lock (_logWriteLineLock)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write($"[{DateTime.Now}] ");
Console.Write($"[{DateTimeOffset.Now}] ");
Console.ResetColor();
Console.WriteLine(message);
}
Expand All @@ -36,7 +36,7 @@ public static void LogWriteLineDelayed(Guid guid, string primayMessage, string s
if (guid == default)
return;

var newEntry = new DelayedWriteLine(DateTime.Now, primayMessage, secondaryMessage, verbose);
var newEntry = new DelayedWriteLine(DateTimeOffset.Now, primayMessage, secondaryMessage, verbose);

if (_delayedWriteLines.TryGetValue(guid, out var delayedWriteLines))
{
Expand Down Expand Up @@ -81,7 +81,7 @@ public static void LogWriteLine(Guid guid, string primayMessage, string secondar
}
}

private static void LogWriteLineInternal(DateTime timestamp, string primayMessage, string secondaryMessage, string? verbose = null)
private static void LogWriteLineInternal(DateTimeOffset timestamp, string primayMessage, string secondaryMessage, string? verbose = null)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write($"[{timestamp}] ");
Expand Down Expand Up @@ -121,7 +121,7 @@ public static void ConnectionsWriteLine(IEnumerable<Connection> connections)
var clientCount = currentConnections.Count(c => c.Status == ConnectionStatus.AwaitClientCommand);

Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write($"[{DateTime.Now}] ");
Console.Write($"[{DateTimeOffset.Now}] ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write($"{conenctionCount} open connection{(conenctionCount != 1 ? "s" : string.Empty)} ");
Console.ForegroundColor = ConsoleColor.DarkGray;
Expand All @@ -137,7 +137,7 @@ public static void ErrorWriteLine(Guid guid, string primayMessage, string? secon
FlushDelayed(guid);

Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write($"[{DateTime.Now}] ");
Console.Write($"[{DateTimeOffset.Now}] ");
Console.ResetColor();

if (secondaryMessage == null)
Expand Down
15 changes: 10 additions & 5 deletions src/NewDarkGlobalServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<Features>strict</Features>
<WarningsAsErrors>nullable</WarningsAsErrors>
<AssemblyName>NewDarkGlobalServer</AssemblyName>
<RootNamespace>NewDarkGlobalServer</RootNamespace>
<ApplicationManifest>App.manifest</ApplicationManifest>
<ApplicationIcon>App.ico</ApplicationIcon>
<Configurations>Debug;Release;ReleaseSigned</Configurations>
<VersionPrefix>1.3.0</VersionPrefix>
<VersionSuffix>preview</VersionSuffix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

<!-- C# compiler -->
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<Features>strict</Features>
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>

<!-- Debug builds -->
Expand All @@ -32,6 +36,7 @@

<!-- AOT settings -->
<PropertyGroup Condition="'$(Configuration)'=='Release' or '$(Configuration)'=='ReleaseSigned'">
<TrimMode>full</TrimMode>
<OptimizationPreference>Speed</OptimizationPreference>
<!-- remove cultures/localizations -->
<InvariantGlobalization>false</InvariantGlobalization>
Expand Down
2 changes: 1 addition & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static async Task Main(string[] args)
{ "p|port=", $"Sets the port for this global server. Default is {Port.ToString(CultureInfo.InvariantCulture)}.", (int p) => Port = p },
{ "s|timeoutserver=", $"Sets timeout for game servers in seconds. Default is {ServerConnectionTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture)} seconds ({ServerConnectionTimeout:c}).", (int s) => ServerConnectionTimeout = TimeSpan.FromSeconds(s) },
{ "c|timeoutclient=", $"Sets timeout for game clients in seconds. Default is {ClientConnectionTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture)} seconds ({ClientConnectionTimeout:c}).", (int c) => ClientConnectionTimeout = TimeSpan.FromSeconds(c) },
{ "u|timeoutunidentified=", $"Sets timeout for game clients in seconds. Default is {UnidentifiedConnectionTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture)} seconds ({UnidentifiedConnectionTimeout:c}).", (int u) => UnidentifiedConnectionTimeout = TimeSpan.FromSeconds(u) },
{ "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 },
{ "v|verbose", "Shows more verbose messages in the log.", v => Verbose = v != null },
Expand Down

0 comments on commit 819ee7e

Please sign in to comment.