chore: apply dotnet format
All checks were successful
Test if Server can be built / build-server (push) Successful in 22s
All checks were successful
Test if Server can be built / build-server (push) Successful in 22s
This commit is contained in:
parent
a6b804dfe7
commit
1455bdd75a
29 changed files with 178 additions and 215 deletions
|
@ -414,6 +414,9 @@ dotnet_naming_rule.parameters_rule.symbols = parameters_group
|
|||
dotnet_naming_rule.parameters_rule.style = camel_case_style
|
||||
dotnet_naming_rule.parameters_rule.severity = warning
|
||||
|
||||
# Disable warnings for using LoggerMessage delegates
|
||||
dotnet_diagnostic.CA1848.severity = none
|
||||
|
||||
##########################################
|
||||
# License
|
||||
##########################################
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Benchmarks;
|
||||
namespace Benchmarks;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using BenchmarkDotNet.Running;
|
||||
|
||||
BenchmarkRunner.Run(Assembly.GetExecutingAssembly());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server;
|
||||
namespace Server;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
@ -30,7 +30,9 @@ public class ChannelSession : TcpSession
|
|||
aes.Key = Key;
|
||||
aes.IV = Iv;
|
||||
aes.Padding = PaddingMode.None;
|
||||
#pragma warning disable SEC0026
|
||||
aes.Mode = CipherMode.ECB;
|
||||
#pragma warning restore SEC0026
|
||||
|
||||
this.decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
this.encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Consumers;
|
||||
namespace Server.Consumers;
|
||||
|
||||
using MassTransit;
|
||||
using Packets;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.DB.Documents;
|
||||
namespace Server.DB.Documents;
|
||||
|
||||
public class Account
|
||||
{
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
namespace Server.DB.Documents;
|
||||
namespace Server.DB.Documents;
|
||||
|
||||
public class Character
|
||||
{
|
||||
public byte ServerId { get; set; }
|
||||
public Guid AccountId { get; set; }
|
||||
public Account Account { get; set; } = null!;
|
||||
public Account Account { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public ushort MapId { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.DB.Documents;
|
||||
namespace Server.DB.Documents;
|
||||
|
||||
public enum Gender : byte
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.DB.Documents;
|
||||
namespace Server.DB.Documents;
|
||||
|
||||
public enum PvPLevel : byte
|
||||
{
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Server.DB.Migrations
|
||||
{
|
||||
namespace Server.DB.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable(
|
||||
name: "Accounts",
|
||||
columns: table => new
|
||||
{
|
||||
|
@ -22,17 +18,9 @@ namespace Server.DB.Migrations
|
|||
PermissionLevel = table.Column<byte>(type: "smallint", nullable: false),
|
||||
Salt = table.Column<byte[]>(type: "bytea", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Accounts", x => x.Id);
|
||||
});
|
||||
}
|
||||
constraints: table => table.PrimaryKey("PK_Accounts", x => x.Id));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable(
|
||||
name: "Accounts");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Server.DB.Migrations
|
||||
{
|
||||
namespace Server.DB.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class CharacterDataDraft : Migration
|
||||
{
|
||||
|
@ -97,7 +95,7 @@ namespace Server.DB.Migrations
|
|||
table: "Accounts",
|
||||
type: "bytea",
|
||||
nullable: false,
|
||||
defaultValue: new byte[0],
|
||||
defaultValue: Array.Empty<byte>(),
|
||||
oldClrType: typeof(byte[]),
|
||||
oldType: "bytea",
|
||||
oldNullable: true);
|
||||
|
@ -107,7 +105,7 @@ namespace Server.DB.Migrations
|
|||
table: "Accounts",
|
||||
type: "bytea",
|
||||
nullable: false,
|
||||
defaultValue: new byte[0],
|
||||
defaultValue: Array.Empty<byte>(),
|
||||
oldClrType: typeof(byte[]),
|
||||
oldType: "bytea",
|
||||
oldNullable: true);
|
||||
|
@ -123,4 +121,3 @@ namespace Server.DB.Migrations
|
|||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.DB;
|
||||
namespace Server.DB;
|
||||
|
||||
using Documents;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.PacketHandlers;
|
||||
namespace Server.PacketHandlers;
|
||||
|
||||
using DB;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.PacketHandlers;
|
||||
namespace Server.PacketHandlers;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using NetCoreServer;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.PacketHandlers;
|
||||
namespace Server.PacketHandlers;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
@ -33,10 +33,12 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
|
||||
// https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Chea1t_Sheet.html#argon2id
|
||||
// "Use Argon2id with a minimum configuration of 19 MiB of memory, an iteration count of 2, and 1 degree of parallelism."
|
||||
var argon2Id = new Argon2id(Encoding.ASCII.GetBytes(packet.Password));
|
||||
argon2Id.MemorySize = 1024 * 19;
|
||||
argon2Id.Iterations = 2;
|
||||
argon2Id.DegreeOfParallelism = 1;
|
||||
var argon2Id = new Argon2id(Encoding.ASCII.GetBytes(packet.Password))
|
||||
{
|
||||
MemorySize = 1024 * 19,
|
||||
Iterations = 2,
|
||||
DegreeOfParallelism = 1
|
||||
};
|
||||
if (account == null)
|
||||
{
|
||||
if (this.configuration.GetSection("Testing").GetValue<bool>("CreateAccountOnLogin"))
|
||||
|
@ -44,13 +46,13 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
argon2Id.Salt = RandomNumberGenerator.GetBytes(16);
|
||||
var finalAccount =
|
||||
await this.wonderkingContext.Accounts.AddAsync(new Account(packet.Username, Array.Empty<byte>(), "",
|
||||
0, argon2Id.Salt));
|
||||
await this.wonderkingContext.SaveChangesAsync();
|
||||
0, argon2Id.Salt)).ConfigureAwait(true);
|
||||
await this.wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
argon2Id.AssociatedData = finalAccount.Entity.Id.ToByteArray();
|
||||
finalAccount.Entity.Password = await argon2Id.GetBytesAsync(16);
|
||||
finalAccount.Entity.Password = await argon2Id.GetBytesAsync(16).ConfigureAwait(true);
|
||||
this.wonderkingContext.Accounts.Update(finalAccount.Entity);
|
||||
loginResponseReason = LoginResponseReason.Ok;
|
||||
await this.wonderkingContext.SaveChangesAsync();
|
||||
await this.wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,7 +64,7 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
|
|||
{
|
||||
argon2Id.Salt = account.Salt;
|
||||
argon2Id.AssociatedData = account.Id.ToByteArray();
|
||||
var tempPasswordBytes = await argon2Id.GetBytesAsync(16);
|
||||
var tempPasswordBytes = await argon2Id.GetBytesAsync(16).ConfigureAwait(true);
|
||||
loginResponseReason = tempPasswordBytes.SequenceEqual(account.Password)
|
||||
? LoginResponseReason.Ok
|
||||
: LoginResponseReason.WrongPassword;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets;
|
||||
namespace Server.Packets;
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Incoming;
|
||||
namespace Server.Packets.Incoming;
|
||||
|
||||
[PacketId(OperationCode.ChannelSelection)]
|
||||
public class ChannelSelectionPacket : IPacket
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Incoming;
|
||||
namespace Server.Packets.Incoming;
|
||||
|
||||
using System.Text;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets;
|
||||
namespace Server.Packets;
|
||||
|
||||
public enum OperationCode : ushort
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Outgoing;
|
||||
namespace Server.Packets.Outgoing;
|
||||
|
||||
[PacketId(OperationCode.LoginResponse)]
|
||||
public class LoginResponsePacket : IPacket
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Outgoing;
|
||||
namespace Server.Packets.Outgoing;
|
||||
|
||||
public enum LoginResponseReason : byte
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets.Outgoing;
|
||||
namespace Server.Packets.Outgoing;
|
||||
|
||||
public struct ServerChannelData
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets;
|
||||
namespace Server.Packets;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class PacketIdAttribute : Attribute
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Packets;
|
||||
namespace Server.Packets;
|
||||
|
||||
using MassTransit;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma warning disable AV1500
|
||||
#pragma warning disable AV1500
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using MassTransit;
|
||||
|
@ -38,8 +38,8 @@ using var host = builder.Build();
|
|||
await using (var scope = host.Services.CreateAsyncScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<WonderkingContext>();
|
||||
await db.Database.MigrateAsync();
|
||||
await db.Database.MigrateAsync().ConfigureAwait(true);
|
||||
}
|
||||
|
||||
await host.RunAsync();
|
||||
await host.RunAsync().ConfigureAwait(true);
|
||||
#pragma warning restore AV1500
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Services;
|
||||
namespace Server.Services;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Immutable;
|
||||
|
@ -12,8 +12,8 @@ using Microsoft.VisualBasic.CompilerServices;
|
|||
using Newtonsoft.Json;
|
||||
using PacketHandlers;
|
||||
using Packets;
|
||||
using static DotNext.Metaprogramming.CodeGenerator;
|
||||
using static DotNext.Linq.Expressions.ExpressionBuilder;
|
||||
using static DotNext.Metaprogramming.CodeGenerator;
|
||||
|
||||
public class PacketDistributorService : IHostedService
|
||||
{
|
||||
|
@ -79,11 +79,8 @@ public class PacketDistributorService : IHostedService
|
|||
.ToDictionary(type => type.GetCustomAttribute<PacketIdAttribute>().Code);
|
||||
if (packetsWithId is not { Count: 0 })
|
||||
{
|
||||
packetsWithId.AsParallel().ForAll(packet =>
|
||||
{
|
||||
this.logger.LogTrace("Packet with ID: {PacketID} has been added as {PacketName}", packet.Key,
|
||||
packet.Value.FullName);
|
||||
});
|
||||
packetsWithId.AsParallel().ForAll(packet => this.logger.LogTrace("Packet with ID: {PacketID} has been added as {PacketName}", packet.Key,
|
||||
packet.Value.FullName));
|
||||
return packetsWithId;
|
||||
}
|
||||
|
||||
|
@ -99,16 +96,13 @@ public class PacketDistributorService : IHostedService
|
|||
i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPacketHandler<>))).ToDictionary(type =>
|
||||
type.GetInterfaces().First(t =>
|
||||
t is { IsGenericType: true } && t.GetGenericTypeDefinition() == typeof(IPacketHandler<>))
|
||||
.GetGenericArguments().First().GetCustomAttribute<PacketIdAttribute>()!.Code);
|
||||
.GetGenericArguments().First().GetCustomAttribute<PacketIdAttribute>().Code);
|
||||
|
||||
if (packetHandlersWithId is not { Count: 0 })
|
||||
{
|
||||
packetHandlersWithId.AsParallel().ForAll(packetHandler =>
|
||||
{
|
||||
this.logger.LogTrace("PacketHandler with ID: {PacketID} has been added as {PacketName}",
|
||||
packetHandlersWithId.AsParallel().ForAll(packetHandler => this.logger.LogTrace("PacketHandler with ID: {PacketID} has been added as {PacketName}",
|
||||
packetHandler.Key,
|
||||
packetHandler.Value.FullName);
|
||||
});
|
||||
packetHandler.Value.FullName));
|
||||
return packetHandlersWithId;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Server.Services;
|
||||
namespace Server.Services;
|
||||
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Nuke.Common;
|
||||
using Nuke.Common.CI;
|
||||
using Nuke.Common.CI.GitHubActions;
|
||||
using Nuke.Common.Execution;
|
||||
using Nuke.Common.Git;
|
||||
using Nuke.Common.IO;
|
||||
using Nuke.Common.ProjectModel;
|
||||
using Nuke.Common.Tooling;
|
||||
using Nuke.Common.Tools.CodeMetrics;
|
||||
using Nuke.Common.Tools.Docker;
|
||||
using Nuke.Common.Tools.DotNet;
|
||||
using Nuke.Common.Tools.SonarScanner;
|
||||
using Nuke.Common.Utilities.Collections;
|
||||
using Serilog;
|
||||
using static Nuke.Common.EnvironmentInfo;
|
||||
using static Nuke.Common.IO.FileSystemTasks;
|
||||
using static Nuke.Common.IO.PathConstruction;
|
||||
|
||||
class Build : NukeBuild
|
||||
{
|
||||
|
@ -42,16 +30,10 @@ class Build : NukeBuild
|
|||
|
||||
Target Clean => _ => _
|
||||
.Before(Restore)
|
||||
.Executes(() =>
|
||||
{
|
||||
DotNetTasks.DotNetClean();
|
||||
});
|
||||
.Executes(() => DotNetTasks.DotNetClean());
|
||||
|
||||
Target Restore => _ => _
|
||||
.Executes(() =>
|
||||
{
|
||||
DotNetTasks.DotNetRestore();
|
||||
});
|
||||
.Executes(() => DotNetTasks.DotNetRestore());
|
||||
|
||||
Target Compile => _ => _
|
||||
.DependsOn(Clean)
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Nuke.Common.Tooling;
|
||||
|
||||
[TypeConverter(typeof(TypeConverter<Configuration>))]
|
||||
|
@ -9,8 +7,5 @@ public class Configuration : Enumeration
|
|||
public static Configuration Debug { get; } = new() { Value = nameof(Debug) };
|
||||
public static Configuration Release { get; } = new() { Value = nameof(Release) };
|
||||
|
||||
public static implicit operator string(Configuration configuration)
|
||||
{
|
||||
return configuration.Value;
|
||||
}
|
||||
public static implicit operator string(Configuration configuration) => configuration.Value;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue