chore: file header adjustment

This commit is contained in:
Timothy Schenk 2024-02-07 16:40:36 +01:00
parent 6147a76d16
commit 7ac4c8c0ef
Signed by: rainote
SSH key fingerprint: SHA256:pnkNSDwpAnaip00xaZlVFHKKsS7T8UtOomMzvs0yITE
95 changed files with 281 additions and 264 deletions

View file

@ -23,10 +23,13 @@ indent_style = space
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
file_header_template = Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
[*.(yaml|yml)]
indent_size = 2
[*.cs] [*.cs]
dotnet_diagnostic.MA0004.severity = none dotnet_diagnostic.MA0004.severity = none
file_header_template = Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
indent_size = 4 indent_size = 4
dotnet_sort_system_directives_first = true dotnet_sort_system_directives_first = true
dotnet_diagnostic.MA0007.severity = none dotnet_diagnostic.MA0007.severity = none

View file

@ -6,8 +6,8 @@ on:
- develop - develop
- master - master
paths: paths:
- Wiki/** - Wiki/**
- Wiki.Dockerfile - Wiki.Dockerfile
env: env:
# Name of module and id separated by a slash # Name of module and id separated by a slash
@ -25,103 +25,103 @@ jobs:
outputs: outputs:
sanitized_branch_name: ${{ steps.sanitize.outputs.sanitized_branch_name }} sanitized_branch_name: ${{ steps.sanitize.outputs.sanitized_branch_name }}
steps: steps:
- name: Sanitize branch name - name: Sanitize branch name
id: sanitize id: sanitize
run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')" run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')"
docs: docs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: registry.jetbrains.team/p/writerside/builder/writerside-builder:${{env.DOCKER_VERSION}} container: registry.jetbrains.team/p/writerside/builder/writerside-builder:${{env.DOCKER_VERSION}}
steps: steps:
- name: Install basic dependencies - name: Install basic dependencies
run: | run: |
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
echo "::add-path::$HOME/.nvm" echo "::add-path::$HOME/.nvm"
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 18 nvm install 18
nvm use 18 nvm use 18
echo "::add-path::$(dirname $(which npm))" echo "::add-path::$(dirname $(which npm))"
nvm --version nvm --version
- name: Check Node.js version - name: Check Node.js version
run: | run: |
node -v node -v
npm -v npm -v
- name: Checkout repository - name: Checkout repository
uses: https://github.com/actions/checkout@v3 uses: https://github.com/actions/checkout@v3
- name: Build docs - name: Build docs
run: | run: |
set -e set -e
export DISPLAY=:99 export DISPLAY=:99
Xvfb :99 & Xvfb :99 &
/opt/builder/bin/idea.sh helpbuilderinspect -source-dir . -product ${{env.INSTANCE}} -output-dir artifacts/ || true /opt/builder/bin/idea.sh helpbuilderinspect -source-dir . -product ${{env.INSTANCE}} -output-dir artifacts/ || true
echo "Test existing of ${{ env.ARTIFACT }} artifact" echo "Test existing of ${{ env.ARTIFACT }} artifact"
test -e artifacts/${{ env.ARTIFACT }} test -e artifacts/${{ env.ARTIFACT }}
- name: rename artifact - name: rename artifact
run: | run: |
mv artifacts/${{ env.ARTIFACT }} artifacts/wiki.zip mv artifacts/${{ env.ARTIFACT }} artifacts/wiki.zip
- name: Upload documentation - name: Upload documentation
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: wiki.zip name: wiki.zip
path: artifacts/wiki.zip path: artifacts/wiki.zip
retention-days: 14 retention-days: 14
- name: Upload algolia-indexes - name: Upload algolia-indexes
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: algolia-indexes.zip name: algolia-indexes.zip
path: artifacts/${{ env.ALGOLIA_ARTIFACT }} path: artifacts/${{ env.ALGOLIA_ARTIFACT }}
retention-days: 14 retention-days: 14
build-docs-container: build-docs-container:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest@sha256:5f2ff408985b10de9da4a8ea735b7f07d4f98c61608180ebb8964deb37f7580a container: catthehacker/ubuntu:act-latest@sha256:5f2ff408985b10de9da4a8ea735b7f07d4f98c61608180ebb8964deb37f7580a
needs: [docs, preprocess] needs: [ docs, preprocess ]
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: https://github.com/actions/checkout@v3 uses: https://github.com/actions/checkout@v3
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ github.server_url }} registry: ${{ github.server_url }}
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
- name: Retrieve docs artifact - name: Retrieve docs artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: wiki.zip name: wiki.zip
path: ${{ github.workspace }} path: ${{ github.workspace }}
- name: Unzip wiki.zip into .public - name: Unzip wiki.zip into .public
run: | run: |
mkdir .public mkdir .public
unzip -jo -qq ./wiki.zip/wiki.zip -d .public unzip -jo -qq ./wiki.zip/wiki.zip -d .public
- name: Build and push - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
file: Wiki.Dockerfile file: Wiki.Dockerfile
push: true push: true
tags: forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki tags: forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
- name: Build and push to latest - name: Build and push to latest
if: github.ref_name == 'master' if: github.ref_name == 'master'
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
file: Wiki.Dockerfile file: Wiki.Dockerfile
push: true push: true
tags: forge.rainote.dev/${{ github.repository }}:latest-wiki tags: forge.rainote.dev/${{ github.repository }}:latest-wiki
platforms: linux/amd64, linux/arm64 platforms: linux/amd64, linux/arm64
deploy-wiki: deploy-wiki:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest@sha256:5f2ff408985b10de9da4a8ea735b7f07d4f98c61608180ebb8964deb37f7580a container: catthehacker/ubuntu:act-latest@sha256:5f2ff408985b10de9da4a8ea735b7f07d4f98c61608180ebb8964deb37f7580a
needs: [build-docs-container, docs, preprocess] needs: [ build-docs-container, docs, preprocess ]
steps: steps:
- name: Deploy Image to CapRrover - name: Deploy Image to CapRrover
run: | run: |
docker run caprover/cli-caprover:2.2.3 caprover deploy --caproverUrl ${{ secrets.CAPROVER_SERVER }} --appToken ${{ secrets.WIKI_APP_TOKEN }} --imageName forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki -a ${{ secrets.WIKI_APP_NAME }} docker run caprover/cli-caprover:2.2.3 caprover deploy --caproverUrl ${{ secrets.CAPROVER_SERVER }} --appToken ${{ secrets.WIKI_APP_TOKEN }} --imageName forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }}-wiki -a ${{ secrets.WIKI_APP_NAME }}

View file

@ -1,7 +1,7 @@
repos: repos:
- repo: local - repo: local
hooks: hooks:
#Use dotnet format already installed on your machine #Use dotnet format already installed on your machine
- id: dotnet-format - id: dotnet-format
name: dotnet-format name: dotnet-format
language: system language: system
@ -17,3 +17,8 @@ repos:
hooks: hooks:
- id: hadolint-docker - id: hadolint-docker
args: [--ignore, SC2086] args: [--ignore, SC2086]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Security.Cryptography; using System.Security.Cryptography;
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
@ -13,14 +13,14 @@ namespace Benchmarks;
[Config(typeof(GenericConfig))] [Config(typeof(GenericConfig))]
public class Argon2Benchmarks public class Argon2Benchmarks
{ {
private byte[] _additionalData = null!;
[Params(2, 4)] public int _iterations; [Params(2, 4)] public int _iterations;
[Params(16)] public int _length;
[Params(16, 32)] public int _memory; [Params(16, 32)] public int _memory;
[Params(1, 2)] public int _parallelism; [Params(1, 2)] public int _parallelism;
private byte[] _salt = null!;
private byte[] _additionalData = null!;
[Params(16)] public int _length;
private byte[] _password = null!; private byte[] _password = null!;
private byte[] _salt = null!;
[GlobalSetup] [GlobalSetup]
public void Setup() public void Setup()
@ -39,7 +39,7 @@ public class Argon2Benchmarks
MemorySize = 1024 * _memory, MemorySize = 1024 * _memory,
DegreeOfParallelism = _parallelism, DegreeOfParallelism = _parallelism,
AssociatedData = _additionalData, AssociatedData = _additionalData,
Salt = _salt, Salt = _salt
}.GetBytes(_length); }.GetBytes(_length);
} }
@ -52,7 +52,7 @@ public class Argon2Benchmarks
MemorySize = 1024 * _memory, MemorySize = 1024 * _memory,
DegreeOfParallelism = _parallelism, DegreeOfParallelism = _parallelism,
AssociatedData = _additionalData, AssociatedData = _additionalData,
Salt = _salt, Salt = _salt
}.GetBytes(_length); }.GetBytes(_length);
} }
@ -65,7 +65,7 @@ public class Argon2Benchmarks
MemorySize = 1024 * _memory, MemorySize = 1024 * _memory,
DegreeOfParallelism = _parallelism, DegreeOfParallelism = _parallelism,
AssociatedData = _additionalData, AssociatedData = _additionalData,
Salt = _salt, Salt = _salt
}.GetBytes(_length); }.GetBytes(_length);
} }
@ -82,7 +82,7 @@ public class Argon2Benchmarks
HashLength = _length, HashLength = _length,
Salt = _salt, Salt = _salt,
AssociatedData = _additionalData, AssociatedData = _additionalData,
Password = _password, Password = _password
}; };
var argon2 = new Argon2(config); var argon2 = new Argon2(config);
return argon2.Hash().Buffer; return argon2.Hash().Buffer;
@ -101,7 +101,7 @@ public class Argon2Benchmarks
HashLength = _length, HashLength = _length,
Salt = _salt, Salt = _salt,
AssociatedData = _additionalData, AssociatedData = _additionalData,
Password = _password, Password = _password
}; };
var argon2 = new Argon2(config); var argon2 = new Argon2(config);
return argon2.Hash().Buffer; return argon2.Hash().Buffer;
@ -120,7 +120,7 @@ public class Argon2Benchmarks
HashLength = _length, HashLength = _length,
Salt = _salt, Salt = _salt,
AssociatedData = _additionalData, AssociatedData = _additionalData,
Password = _password, Password = _password
}; };
var argon2 = new Argon2(config); var argon2 = new Argon2(config);
return argon2.Hash().Buffer; return argon2.Hash().Buffer;

View file

@ -13,10 +13,10 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" /> <PackageReference Include="BenchmarkDotNet" Version="0.13.12"/>
<PackageReference Include="DotNext.Unsafe" Version="0.14.0" /> <PackageReference Include="DotNext.Unsafe" Version="0.14.0"/>
<PackageReference Include="Isopoh.Cryptography.Argon2" Version="2.0.0" /> <PackageReference Include="Isopoh.Cryptography.Argon2" Version="2.0.0"/>
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0" /> <PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0"/>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Security.Cryptography; using System.Security.Cryptography;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Immutable; using System.Collections.Immutable;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using BenchmarkDotNet.Analysers; using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Columns; using BenchmarkDotNet.Columns;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Reflection; using System.Reflection;
using BenchmarkDotNet.Running; using BenchmarkDotNet.Running;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Net.Sockets; using System.Net.Sockets;
using Continuity.AuthServer.Packets; using Continuity.AuthServer.Packets;
@ -12,8 +12,8 @@ namespace Continuity.AuthServer;
public class AuthSession : TcpSession public class AuthSession : TcpSession
{ {
private readonly ILogger<AuthSession> _logger;
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService; private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
private readonly ILogger<AuthSession> _logger;
private readonly IMediator _mediator; private readonly IMediator _mediator;
public AuthSession(TcpServer public AuthSession(TcpServer

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Diagnostics; using System.Diagnostics;
using Continuity.AuthServer.Packets; using Continuity.AuthServer.Packets;
@ -12,9 +12,8 @@ namespace Continuity.AuthServer.Consumers;
[UsedImplicitly] [UsedImplicitly]
public class PacketConsumer : IConsumer<RawPacket>, IDisposable public class PacketConsumer : IConsumer<RawPacket>, IDisposable
{ {
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
private readonly ActivitySource _activitySource; private readonly ActivitySource _activitySource;
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
public PacketConsumer(PacketDistributorService<OperationCode, AuthSession> distributorService) public PacketConsumer(PacketDistributorService<OperationCode, AuthSession> distributorService)
{ {

View file

@ -40,14 +40,14 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="DotNext" Version="5.3.1" /> <PackageReference Include="DotNext" Version="5.3.1"/>
<PackageReference Include="DotNext.IO" Version="5.3.0" /> <PackageReference Include="DotNext.IO" Version="5.3.0"/>
<PackageReference Include="DotNext.Metaprogramming" Version="5.3.0" /> <PackageReference Include="DotNext.Metaprogramming" Version="5.3.0"/>
<PackageReference Include="DotNext.Threading" Version="5.3.0" /> <PackageReference Include="DotNext.Threading" Version="5.3.0"/>
<PackageReference Include="DotNext.Unsafe" Version="5.3.0" /> <PackageReference Include="DotNext.Unsafe" Version="5.3.0"/>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0"/> <PackageReference Include="JetBrains.Annotations" Version="2023.3.0"/>
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0"/> <PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0"/>
<PackageReference Include="MassTransit" Version="8.1.3" /> <PackageReference Include="MassTransit" Version="8.1.3"/>
<PackageReference Include="MassTransit.Analyzers" Version="8.1.3"> <PackageReference Include="MassTransit.Analyzers" Version="8.1.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -60,10 +60,10 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.3"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.3"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -79,23 +79,23 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="NetCoreServer" Version="8.0.7" /> <PackageReference Include="NetCoreServer" Version="8.0.7"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/> <PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2"/>
<PackageReference Include="Npgsql.OpenTelemetry" Version="8.0.2" /> <PackageReference Include="Npgsql.OpenTelemetry" Version="8.0.2"/>
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.15.6169"> <PackageReference Include="Nullable.Extended.Analyzer" Version="1.15.6169">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="OpenTelemetry" Version="1.7.0" /> <PackageReference Include="OpenTelemetry" Version="1.7.0"/>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0"/>
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.7.0"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.10"/> <PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.10"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.1" /> <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.1"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Process" Version="1.0.0-alpha.6" /> <PackageReference Include="OpenTelemetry.Instrumentation.Process" Version="1.0.0-alpha.6"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.7.0" /> <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.7.0"/>
<PackageReference Include="OpenTelemetry.PersistentStorage.FileSystem" Version="1.0.0"/> <PackageReference Include="OpenTelemetry.PersistentStorage.FileSystem" Version="1.0.0"/>
<PackageReference Include="OpenTelemetry.ResourceDetectors.Container" Version="1.0.0-beta.6"/> <PackageReference Include="OpenTelemetry.ResourceDetectors.Container" Version="1.0.0-beta.6"/>
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0"/> <PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0"/>

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Continuity.AuthServer.DB.Documents; namespace Continuity.AuthServer.DB.Documents;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Continuity.AuthServer.DB.Documents; namespace Continuity.AuthServer.DB.Documents;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
#nullable disable #nullable disable

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
#nullable disable #nullable disable

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB.Documents; using Continuity.AuthServer.DB.Documents;
using JetBrains.Annotations; using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.PacketHandlers; using Continuity.AuthServer.PacketHandlers;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB.Documents; using Continuity.AuthServer.DB.Documents;
using Wonderking.Game.Data.Character; using Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB; using Continuity.AuthServer.DB;
using Continuity.AuthServer.DB.Documents; using Continuity.AuthServer.DB.Documents;
@ -27,11 +27,12 @@ public partial class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPa
var guildNameResponsePacket = new CharacterSelectionSetGuildNamePacket { GuildNames = Array.Empty<string>() }; var guildNameResponsePacket = new CharacterSelectionSetGuildNamePacket { GuildNames = Array.Empty<string>() };
var accountExists = var accountExists =
await _wonderkingContext.Accounts.AsNoTracking().AnyAsync(a => a.Id == session.AccountId, cancellationToken: cancellationToken); await _wonderkingContext.Accounts.AsNoTracking()
.AnyAsync(a => a.Id == session.AccountId, cancellationToken);
var amountOfCharacter = await _wonderkingContext.Characters.AsNoTracking().Include(c => c.Account) var amountOfCharacter = await _wonderkingContext.Characters.AsNoTracking().Include(c => c.Account)
.Where(c => c.Account.Id == session.AccountId).Take(3) .Where(c => c.Account.Id == session.AccountId).Take(3)
.CountAsync(cancellationToken: cancellationToken); .CountAsync(cancellationToken);
if (!accountExists) if (!accountExists)
{ {
@ -52,7 +53,7 @@ public partial class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPa
await _wonderkingContext.Characters.AsNoTracking().Include(c => c.Account).Include(c => c.GuildMember) await _wonderkingContext.Characters.AsNoTracking().Include(c => c.Account).Include(c => c.GuildMember)
.ThenInclude(gm => gm.Guild) .ThenInclude(gm => gm.Guild)
.Where(c => c.Account.Id == session.AccountId && c.GuildMember.Guild != null) .Where(c => c.Account.Id == session.AccountId && c.GuildMember.Guild != null)
.Select(c => c.GuildMember.Guild.Name).Take(3).ToArrayAsync(cancellationToken: cancellationToken); .Select(c => c.GuildMember.Guild.Name).Take(3).ToArrayAsync(cancellationToken);
} }
else else
{ {

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB; using Continuity.AuthServer.DB;
using Continuity.AuthServer.DB.Documents; using Continuity.AuthServer.DB.Documents;
@ -30,8 +30,8 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket,
public async Task HandleAsync(CharacterCreationPacket packet, AuthSession session, public async Task HandleAsync(CharacterCreationPacket packet, AuthSession session,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var account =
var account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Id == session.AccountId, cancellationToken: cancellationToken); await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Id == session.AccountId, cancellationToken);
if (account is null) if (account is null)
{ {
@ -93,7 +93,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket,
private static Character CreateDefaultCharacter(CharacterCreationPacket packet, Account account, private static Character CreateDefaultCharacter(CharacterCreationPacket packet, Account account,
InventoryItem[] items, JobSpecificMapping firstJobConfig) InventoryItem[] items, JobSpecificMapping firstJobConfig)
{ {
return new Character() return new Character
{ {
Account = account, Account = account,
MapId = 300, MapId = 300,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB; using Continuity.AuthServer.DB;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -17,10 +17,11 @@ public class CharacterDeletionHandler : IPacketHandler<CharacterDeletePacket, Au
_wonderkingContext = wonderkingContext; _wonderkingContext = wonderkingContext;
} }
public async Task HandleAsync(CharacterDeletePacket packet, AuthSession session, CancellationToken cancellationToken) public async Task HandleAsync(CharacterDeletePacket packet, AuthSession session,
CancellationToken cancellationToken)
{ {
var character = await _wonderkingContext.Characters.FirstOrDefaultAsync(x => x.Name == packet.Name && var character = await _wonderkingContext.Characters.FirstOrDefaultAsync(x => x.Name == packet.Name &&
x.Account.Id == session.AccountId, cancellationToken: cancellationToken); x.Account.Id == session.AccountId, cancellationToken);
var response = new CharacterDeleteResponsePacket { HasToBeZero = 0 }; var response = new CharacterDeleteResponsePacket { HasToBeZero = 0 };
if (character == null) if (character == null)

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB; using Continuity.AuthServer.DB;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -22,7 +22,7 @@ public class CharacterNameCheckHandler : IPacketHandler<CharacterNameCheckPacket
{ {
var isTaken = var isTaken =
await _wonderkingContext.Characters.AnyAsync(c => c.Name == packet.Name, await _wonderkingContext.Characters.AnyAsync(c => c.Name == packet.Name,
cancellationToken: cancellationToken); cancellationToken);
var responsePacket = new CharacterNameCheckPacketResponse { IsTaken = isTaken }; var responsePacket = new CharacterNameCheckPacketResponse { IsTaken = isTaken };
await session.SendAsync(responsePacket); await session.SendAsync(responsePacket);

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Diagnostics; using System.Diagnostics;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -19,10 +19,10 @@ namespace Continuity.AuthServer.PacketHandlers;
public class LoginHandler : IPacketHandler<LoginInfoPacket, AuthSession> public class LoginHandler : IPacketHandler<LoginInfoPacket, AuthSession>
{ {
private static readonly ActivitySource _activitySource = new(nameof(Server));
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly ILogger<LoginHandler> _logger; private readonly ILogger<LoginHandler> _logger;
private readonly WonderkingContext _wonderkingContext; private readonly WonderkingContext _wonderkingContext;
private static readonly ActivitySource _activitySource = new(nameof(Server));
public LoginHandler(ILogger<LoginHandler> logger, WonderkingContext wonderkingContext, IConfiguration configuration) public LoginHandler(ILogger<LoginHandler> logger, WonderkingContext wonderkingContext, IConfiguration configuration)
{ {
@ -35,14 +35,17 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket, AuthSession>
{ {
LoginResponseReason loginResponseReason; LoginResponseReason loginResponseReason;
_logger.LoginData(packet.Username, packet.Password); _logger.LoginData(packet.Username, packet.Password);
var account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username, cancellationToken: cancellationToken); var account =
await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username,
cancellationToken);
if (account == null) if (account == null)
{ {
if (_configuration.GetSection("Testing").GetValue<bool>("CreateAccountOnLogin")) if (_configuration.GetSection("Testing").GetValue<bool>("CreateAccountOnLogin"))
{ {
loginResponseReason = await CreateAccountOnLoginAsync(packet.Username, packet.Password); loginResponseReason = await CreateAccountOnLoginAsync(packet.Username, packet.Password);
account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username, cancellationToken: cancellationToken); account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username,
cancellationToken);
} }
else else
{ {

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using MassTransit; using MassTransit;
using Wonderking.Packets; using Wonderking.Packets;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Collections.Concurrent; using System.Collections.Concurrent;
using Continuity.AuthServer.DB.Documents; using Continuity.AuthServer.DB.Documents;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations; using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations; using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations; using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Rai.PacketMediator; namespace Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Diagnostics; using System.Diagnostics;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -6,11 +6,9 @@ using JetBrains.Annotations;
namespace Rai.PacketMediator; namespace Rai.PacketMediator;
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)] [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public interface IPacketHandler<in TIncomingPacket, in TSession> : IPacketHandler<TSession> where TIncomingPacket : IIncomingPacket public interface IPacketHandler<in TIncomingPacket, in TSession> : IPacketHandler<TSession>
where TIncomingPacket : IIncomingPacket
{ {
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public Task HandleAsync(TIncomingPacket packet, TSession session, CancellationToken cancellationToken);
async Task<bool> IPacketHandler<TSession>.TryHandleAsync(IIncomingPacket packet, TSession session, async Task<bool> IPacketHandler<TSession>.TryHandleAsync(IIncomingPacket packet, TSession session,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
@ -20,12 +18,15 @@ public interface IPacketHandler<in TIncomingPacket, in TSession> : IPacketHandle
} }
using var activity = new ActivitySource(nameof(PacketMediator)).StartActivity(nameof(HandleAsync)); using var activity = new ActivitySource(nameof(PacketMediator)).StartActivity(nameof(HandleAsync));
activity?.AddTag("Handler", this.ToString()); activity?.AddTag("Handler", ToString());
activity?.AddTag("Packet", packet.ToString()); activity?.AddTag("Packet", packet.ToString());
await HandleAsync(tPacket, session, cancellationToken); await HandleAsync(tPacket, session, cancellationToken);
return true; return true;
} }
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public Task HandleAsync(TIncomingPacket packet, TSession session, CancellationToken cancellationToken);
} }
public interface IPacketHandler<in TSession> public interface IPacketHandler<in TSession>

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Immutable; using System.Collections.Immutable;
@ -15,12 +15,10 @@ public class PacketDistributor<TPacketIdEnum, TSession> where TPacketIdEnum : En
{ {
private readonly Channel<ValueTuple<byte[], TPacketIdEnum, TSession>> _channel; private readonly Channel<ValueTuple<byte[], TPacketIdEnum, TSession>> _channel;
private readonly ConcurrentDictionary<TPacketIdEnum, IPacketHandler<TSession>?> _packetHandlersInstantiation;
private readonly ImmutableDictionary<TPacketIdEnum, private readonly ImmutableDictionary<TPacketIdEnum,
Func<byte[], IIncomingPacket>> _deserializationMap; Func<byte[], IIncomingPacket>> _deserializationMap;
public ImmutableDictionary<Type, TPacketIdEnum> PacketIdMap { get; } private readonly ConcurrentDictionary<TPacketIdEnum, IPacketHandler<TSession>?> _packetHandlersInstantiation;
public PacketDistributor(IServiceProvider serviceProvider, public PacketDistributor(IServiceProvider serviceProvider,
IEnumerable<Assembly> sourcesContainingPackets, IEnumerable<Assembly> sourcesContainingPacketHandlers) IEnumerable<Assembly> sourcesContainingPackets, IEnumerable<Assembly> sourcesContainingPacketHandlers)
@ -37,7 +35,7 @@ public class PacketDistributor<TPacketIdEnum, TSession> where TPacketIdEnum : En
var packetHandlers = GetAllPacketHandlersWithId(sourcesContainingPacketHandlers); var packetHandlers = GetAllPacketHandlersWithId(sourcesContainingPacketHandlers);
this.PacketIdMap = allOutgoingPackets.Select(x => new { PacketId = x.Key, Type = x.Value }) PacketIdMap = allOutgoingPackets.Select(x => new { PacketId = x.Key, Type = x.Value })
.ToImmutableDictionary(x => x.Type, x => x.PacketId); .ToImmutableDictionary(x => x.Type, x => x.PacketId);
var tempDeserializationMap = var tempDeserializationMap =
@ -69,6 +67,8 @@ public class PacketDistributor<TPacketIdEnum, TSession> where TPacketIdEnum : En
_deserializationMap = tempDeserializationMap.ToImmutableDictionary(); _deserializationMap = tempDeserializationMap.ToImmutableDictionary();
} }
public ImmutableDictionary<Type, TPacketIdEnum> PacketIdMap { get; }
private static IEnumerable<KeyValuePair<TPacketIdEnum, Type>> GetAllPackets( private static IEnumerable<KeyValuePair<TPacketIdEnum, Type>> GetAllPackets(
IEnumerable<Assembly> sourcesContainingPackets, Type packetType) IEnumerable<Assembly> sourcesContainingPackets, Type packetType)
{ {

View file

@ -1,10 +1,11 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Reflection; using System.Reflection;
using Microsoft.Extensions.Hosting;
namespace Rai.PacketMediator; namespace Rai.PacketMediator;
public class PacketDistributorService<TPacketIdEnum, TSession> : Microsoft.Extensions.Hosting.IHostedService public class PacketDistributorService<TPacketIdEnum, TSession> : IHostedService
where TPacketIdEnum : Enum where TPacketIdEnum : Enum
{ {
private readonly PacketDistributor<TPacketIdEnum, TSession> _packetDistributor; private readonly PacketDistributor<TPacketIdEnum, TSession> _packetDistributor;
@ -21,20 +22,20 @@ public class PacketDistributorService<TPacketIdEnum, TSession> : Microsoft.Exten
return _packetDistributor.DequeuePacketAsync(cancellationToken); return _packetDistributor.DequeuePacketAsync(cancellationToken);
} }
public Task AddPacketAsync(byte[] packetData, TPacketIdEnum operationCode, TSession session)
{
return this._packetDistributor.AddPacketAsync(packetData, operationCode, session);
}
public Task StopAsync(CancellationToken cancellationToken) public Task StopAsync(CancellationToken cancellationToken)
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }
public Task AddPacketAsync(byte[] packetData, TPacketIdEnum operationCode, TSession session)
{
return _packetDistributor.AddPacketAsync(packetData, operationCode, session);
}
public TPacketIdEnum GetOperationCodeByPacketType(IPacket packet) public TPacketIdEnum GetOperationCodeByPacketType(IPacket packet)
{ {
var type = packet.GetType(); var type = packet.GetType();
this._packetDistributor.PacketIdMap.TryGetValue(type, out var value); _packetDistributor.PacketIdMap.TryGetValue(type, out var value);
if (value is null) if (value is null)
{ {
throw new ArgumentOutOfRangeException(type.Name); throw new ArgumentOutOfRangeException(type.Name);

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Rai.PacketMediator; namespace Rai.PacketMediator;

View file

@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DotNext" Version="5.0.1" /> <PackageReference Include="DotNext" Version="5.0.1"/>
<PackageReference Include="DotNext.Metaprogramming" Version="5.0.1" /> <PackageReference Include="DotNext.Metaprogramming" Version="5.0.1"/>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" /> <PackageReference Include="JetBrains.Annotations" Version="2023.3.0"/>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.139"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.139">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0"/>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14"> <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Game.Data.Character; namespace Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Game.Data.Character; namespace Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Game.Data.Item; namespace Wonderking.Game.Data.Item;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Wonderking.Game.Data.Item; using Wonderking.Game.Data.Item;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Reflection; using System.Reflection;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations; using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using JetBrains.Annotations; using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
/* Nicht gemergte Änderung aus Projekt "Wonderking(net7.0)" /* Nicht gemergte Änderung aus Projekt "Wonderking(net7.0)"
Vor: Vor:

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Text; using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Wonderking.Game.Data.Item; using Wonderking.Game.Data.Item;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator; using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text; using System.Text;
using Rai.PacketMediator; using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text; using System.Text;
using Rai.PacketMediator; using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text; using System.Text;
using Rai.PacketMediator; using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text; using System.Text;
using Rai.PacketMediator; using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Packets; namespace Wonderking.Packets;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Text; using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Text; using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator; using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator; using Rai.PacketMediator;
@ -8,6 +8,7 @@ namespace Wonderking.Packets.Outgoing;
public class CharacterNameCheckPacketResponse : IOutgoingPacket public class CharacterNameCheckPacketResponse : IOutgoingPacket
{ {
public required bool IsTaken { get; set; } public required bool IsTaken { get; set; }
public byte[] Serialize() public byte[] Serialize()
{ {
Span<byte> data = stackalloc byte[1]; Span<byte> data = stackalloc byte[1];

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text; using System.Text;
using Rai.PacketMediator; using Rai.PacketMediator;
@ -9,6 +9,7 @@ namespace Wonderking.Packets.Outgoing;
public class CharacterSelectionSetGuildNamePacket : IOutgoingPacket public class CharacterSelectionSetGuildNamePacket : IOutgoingPacket
{ {
public required string[] GuildNames { get; set; } public required string[] GuildNames { get; set; }
public byte[] Serialize() public byte[] Serialize()
{ {
Span<byte> data = stackalloc byte[1 + (1 + 16 + 1) * GuildNames.Length]; Span<byte> data = stackalloc byte[1 + (1 + 16 + 1) * GuildNames.Length];

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using JetBrains.Annotations; using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Wonderking.Game.Data.Character; using Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Packets.Outgoing.Data; namespace Wonderking.Packets.Outgoing.Data;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary; using System.Buffers.Binary;
using Rai.PacketMediator; using Rai.PacketMediator;
@ -14,6 +14,7 @@ public class LoginResponsePacket : IOutgoingPacket
public required bool IsGameMaster { get; set; } public required bool IsGameMaster { get; set; }
public required ServerChannelData[] ChannelData { get; set; } public required ServerChannelData[] ChannelData { get; set; }
public byte[] Serialize() public byte[] Serialize()
{ {
const int sizeOfServerChannelData = 5; const int sizeOfServerChannelData = 5;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator; using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. // Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View file

@ -22,7 +22,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3"/>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.9.28"> <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.9.28">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -42,6 +42,6 @@
<Folder Include="Game\Writer\"/> <Folder Include="Game\Writer\"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Rai.PacketMediator\Rai.PacketMediator.csproj" /> <ProjectReference Include="..\Rai.PacketMediator\Rai.PacketMediator.csproj"/>
</ItemGroup> </ItemGroup>
</Project> </Project>