From 357547f83c1313e1f734cd0c601cc69ce6b93452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Mon, 16 Jan 2023 08:46:03 +0100 Subject: [PATCH] feat: add movers for bfe, ct, dm, rc, bf, sayi, sayitemt, sayt, spk, rest, raidfhp, raidfmp, ctl, suctl, ptctl, throw, tp, char_sc, die packets --- src/Anonymizer.CLI/Anonymizer.CLI.csproj | 2 -- src/Anonymizer/Anonymizer.csproj | 4 +-- .../Extensions/ServiceCollectionExtensions.cs | 23 ++++++++++++++++ src/Anonymizer/Filters/HeaderFilterOptions.cs | 23 +++++----------- src/Anonymizer/Movers/Basic/BfEPacketMover.cs | 20 ++++++++++++++ src/Anonymizer/Movers/Basic/BfPacketMover.cs | 20 ++++++++++++++ .../Movers/Basic/CInfoPacketMover.cs | 12 +++++++-- .../Movers/Basic/CharScPacketMover.cs | 20 ++++++++++++++ src/Anonymizer/Movers/Basic/CtPacketMover.cs | 21 +++++++++++++++ src/Anonymizer/Movers/Basic/CtlPacketMover.cs | 20 ++++++++++++++ src/Anonymizer/Movers/Basic/DiePacketMover.cs | 23 ++++++++++++++++ src/Anonymizer/Movers/Basic/DmPacketMover.cs | 20 ++++++++++++++ .../Movers/Basic/FinfoPacketMover.cs | 27 +++++++++++++++++++ .../Movers/Basic/FinitPacketMover.cs | 27 +++++++++++++++++++ .../Movers/Basic/GidxPacketMover.cs | 2 +- src/Anonymizer/Movers/Basic/InPacketMover.cs | 2 +- .../Movers/Basic/PinitPacketMover.cs | 2 +- .../Movers/Basic/PtctlPacketMover.cs | 26 ++++++++++++++++++ .../Movers/Basic/RaidfhpPacketMover.cs | 26 ++++++++++++++++++ .../Movers/Basic/RaidfmpPacketMover.cs | 26 ++++++++++++++++++ src/Anonymizer/Movers/Basic/RcPacketMover.cs | 20 ++++++++++++++ .../Movers/Basic/RestPacketMover.cs | 20 ++++++++++++++ .../Movers/Basic/Sayi2PacketMover.cs | 16 +++++++++++ .../Movers/Basic/SayiPacketMover.cs | 20 ++++++++++++++ .../Movers/Basic/SayitemtPacketMover.cs | 21 +++++++++++++++ .../Movers/Basic/SaytPacketMover.cs | 21 +++++++++++++++ src/Anonymizer/Movers/Basic/SpkPacketMover.cs | 21 +++++++++++++++ .../Movers/Basic/SuctlPacketMover.cs | 21 +++++++++++++++ .../Movers/Basic/ThrowPacketMover.cs | 20 ++++++++++++++ src/Anonymizer/Movers/Basic/TpPacketMover.cs | 20 ++++++++++++++ src/Anonymizer/PacketProcessor.cs | 17 ++++++------ 31 files changed, 529 insertions(+), 34 deletions(-) create mode 100644 src/Anonymizer/Movers/Basic/BfEPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/BfPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/CharScPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/CtPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/CtlPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/DiePacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/DmPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/FinfoPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/FinitPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/PtctlPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/RaidfhpPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/RaidfmpPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/RcPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/RestPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/Sayi2PacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/SayiPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/SayitemtPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/SaytPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/SpkPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/SuctlPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/ThrowPacketMover.cs create mode 100644 src/Anonymizer/Movers/Basic/TpPacketMover.cs diff --git a/src/Anonymizer.CLI/Anonymizer.CLI.csproj b/src/Anonymizer.CLI/Anonymizer.CLI.csproj index ed00737..07d1d67 100644 --- a/src/Anonymizer.CLI/Anonymizer.CLI.csproj +++ b/src/Anonymizer.CLI/Anonymizer.CLI.csproj @@ -13,8 +13,6 @@ - - diff --git a/src/Anonymizer/Anonymizer.csproj b/src/Anonymizer/Anonymizer.csproj index e874591..98ef833 100644 --- a/src/Anonymizer/Anonymizer.csproj +++ b/src/Anonymizer/Anonymizer.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/src/Anonymizer/Extensions/ServiceCollectionExtensions.cs b/src/Anonymizer/Extensions/ServiceCollectionExtensions.cs index 748719d..207d781 100644 --- a/src/Anonymizer/Extensions/ServiceCollectionExtensions.cs +++ b/src/Anonymizer/Extensions/ServiceCollectionExtensions.cs @@ -12,7 +12,10 @@ using NosSmooth.Packets; using NosSmooth.Packets.Client; using NosSmooth.Packets.Client.Battle; using NosSmooth.Packets.Client.Inventory; +using NosSmooth.Packets.Client.Mates; using NosSmooth.Packets.Server.Battle; +using NosSmooth.Packets.Server.Buffs; +using NosSmooth.Packets.Server.Buffs.Generated; using NosSmooth.Packets.Server.Character; using NosSmooth.Packets.Server.Chat; using NosSmooth.Packets.Server.Entities; @@ -21,6 +24,7 @@ using NosSmooth.Packets.Server.Groups; using NosSmooth.Packets.Server.Inventory; using NosSmooth.Packets.Server.Login; using NosSmooth.Packets.Server.Maps; +using NosSmooth.Packets.Server.Mates; using NosSmooth.Packets.Server.Raids; using NosSmooth.Packets.Server.UI; @@ -53,6 +57,25 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddBasicMovers(this IServiceCollection serviceCollection) => serviceCollection .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() + .AddMover() .AddMover() .AddMover() .AddMover() diff --git a/src/Anonymizer/Filters/HeaderFilterOptions.cs b/src/Anonymizer/Filters/HeaderFilterOptions.cs index 04485ce..9301a9e 100644 --- a/src/Anonymizer/Filters/HeaderFilterOptions.cs +++ b/src/Anonymizer/Filters/HeaderFilterOptions.cs @@ -20,32 +20,23 @@ public class HeaderFilterOptions "stat", "say", "spk", + "infoi", + "msgi", + "sayi", + "sayi2", + "sayitemt", + "sayit", + "sayit2", "bn", "inv", - "qslot", "umi", "msgi2", "qnai2", - - "die", - - "throw", - - "bf", - "bf_e", - "dm", - "finit", - "finfo", - "ptctl", - "suctl", // figure out what it does - "ct", // figure out what it does }; /// /// Gets or sets the headers to keep. Takes priority before remove headers. /// public IReadOnlyList? KeepHeaders { get; set; } = null; - - // rdlst, raid, raidmbf, raidbf, in, out, c_info, c_mode } \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/BfEPacketMover.cs b/src/Anonymizer/Movers/Basic/BfEPacketMover.cs new file mode 100644 index 0000000..7478eee --- /dev/null +++ b/src/Anonymizer/Movers/Basic/BfEPacketMover.cs @@ -0,0 +1,20 @@ +// +// BfEPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Buffs; + +namespace Anonymizer.Movers.Basic; + +/// +public class BfEPacketMover : AbstractMover +{ + /// + public override BfEPacket Move(IAnonymizer anonymizer, BfEPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/BfPacketMover.cs b/src/Anonymizer/Movers/Basic/BfPacketMover.cs new file mode 100644 index 0000000..0318d5f --- /dev/null +++ b/src/Anonymizer/Movers/Basic/BfPacketMover.cs @@ -0,0 +1,20 @@ +// +// BfPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Buffs; + +namespace Anonymizer.Movers.Basic; + +/// +public class BfPacketMover : AbstractMover +{ + /// + public override BfPacket Move(IAnonymizer anonymizer, BfPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/CInfoPacketMover.cs b/src/Anonymizer/Movers/Basic/CInfoPacketMover.cs index 53db81d..cda0937 100644 --- a/src/Anonymizer/Movers/Basic/CInfoPacketMover.cs +++ b/src/Anonymizer/Movers/Basic/CInfoPacketMover.cs @@ -5,6 +5,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using NosSmooth.Packets.Server.Character; +using NosSmooth.PacketSerializer.Abstractions; +using NosSmooth.PacketSerializer.Abstractions.Common; namespace Anonymizer.Movers.Basic; @@ -17,8 +19,14 @@ public class CInfoPacketMover : AbstractMover { CharacterId = anonymizer.AnonymizeId(packet.CharacterId), Name = anonymizer.AnonymizeName(packet.Name), - FamilyId = packet.FamilyId is null ? null : anonymizer.AnonymizeName(packet.FamilyId), - FamilyName = packet.FamilyName is null ? null : anonymizer.AnonymizeName(packet.FamilyName), + FamilySubPacket = packet.FamilySubPacket.Value is null ? null : packet.FamilySubPacket with + { + Value = packet.FamilySubPacket.Value with + { + FamilyId = anonymizer.AnonymizeId(packet.FamilySubPacket.Value.FamilyId) + } + }, + FamilyName = anonymizer.AnonymizeName(packet.FamilyName), GroupId = packet.GroupId is null ? null : anonymizer.AnonymizeId(packet.GroupId.Value) }; } \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/CharScPacketMover.cs b/src/Anonymizer/Movers/Basic/CharScPacketMover.cs new file mode 100644 index 0000000..9272ae1 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/CharScPacketMover.cs @@ -0,0 +1,20 @@ +// +// CharScPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Entities; + +namespace Anonymizer.Movers.Basic; + +/// +public class CharScPacketMover : AbstractMover +{ + /// + public override CharScPacket Move(IAnonymizer anonymizer, CharScPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/CtPacketMover.cs b/src/Anonymizer/Movers/Basic/CtPacketMover.cs new file mode 100644 index 0000000..70bdd87 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/CtPacketMover.cs @@ -0,0 +1,21 @@ +// +// CtPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Battle; + +namespace Anonymizer.Movers.Basic; + +/// +public class CtPacketMover : AbstractMover +{ + /// + public override CtPacket Move(IAnonymizer anonymizer, CtPacket packet) + => packet with + { + CasterEntityId = anonymizer.AnonymizeId(packet.CasterEntityId), + TargetEntityId = packet.TargetEntityId is null ? null : anonymizer.AnonymizeId(packet.TargetEntityId.Value) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/CtlPacketMover.cs b/src/Anonymizer/Movers/Basic/CtlPacketMover.cs new file mode 100644 index 0000000..e0e33bb --- /dev/null +++ b/src/Anonymizer/Movers/Basic/CtlPacketMover.cs @@ -0,0 +1,20 @@ +// +// CtlPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Mates; + +namespace Anonymizer.Movers.Basic; + +/// +public class CtlPacketMover : AbstractMover +{ + /// + public override CtlPacket Move(IAnonymizer anonymizer, CtlPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/DiePacketMover.cs b/src/Anonymizer/Movers/Basic/DiePacketMover.cs new file mode 100644 index 0000000..e590bdd --- /dev/null +++ b/src/Anonymizer/Movers/Basic/DiePacketMover.cs @@ -0,0 +1,23 @@ +// +// DiePacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Entities; + +namespace Anonymizer.Movers.Basic; + +/// +public class DiePacketMover : AbstractMover +{ + /// + public override DiePacket Move(IAnonymizer anonymizer, DiePacket packet) + { + return packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId), + TargetEntityId = anonymizer.AnonymizeId(packet.TargetEntityId) + }; + } +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/DmPacketMover.cs b/src/Anonymizer/Movers/Basic/DmPacketMover.cs new file mode 100644 index 0000000..e84c6fc --- /dev/null +++ b/src/Anonymizer/Movers/Basic/DmPacketMover.cs @@ -0,0 +1,20 @@ +// +// DmPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Battle; + +namespace Anonymizer.Movers.Basic; + +/// +public class DmPacketMover : AbstractMover +{ + /// + public override DmPacket Move(IAnonymizer anonymizer, DmPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/FinfoPacketMover.cs b/src/Anonymizer/Movers/Basic/FinfoPacketMover.cs new file mode 100644 index 0000000..0aac82a --- /dev/null +++ b/src/Anonymizer/Movers/Basic/FinfoPacketMover.cs @@ -0,0 +1,27 @@ +// +// FinfoPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Relations; + +namespace Anonymizer.Movers.Basic; + +/// +public class FinfoPacketMover : AbstractMover +{ + /// + public override FInfoPacket Move(IAnonymizer anonymizer, FInfoPacket packet) + => packet with + { + FriendSubPackets = packet.FriendSubPackets.Select + ( + x => x with + { + PlayerId = anonymizer.AnonymizeId(x.PlayerId), + Name = anonymizer.AnonymizeName(x.Name) + } + ).ToArray() + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/FinitPacketMover.cs b/src/Anonymizer/Movers/Basic/FinitPacketMover.cs new file mode 100644 index 0000000..445c2f1 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/FinitPacketMover.cs @@ -0,0 +1,27 @@ +// +// FinitPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Relations; + +namespace Anonymizer.Movers.Basic; + +/// +public class FinitPacketMover : AbstractMover +{ + /// + public override FInitPacket Move(IAnonymizer anonymizer, FInitPacket packet) + => packet with + { + FriendSubPackets = packet.FriendSubPackets.Select + ( + x => x with + { + Name = anonymizer.AnonymizeName(x.Name), + PlayerId = anonymizer.AnonymizeId(x.PlayerId) + } + ).ToArray() + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/GidxPacketMover.cs b/src/Anonymizer/Movers/Basic/GidxPacketMover.cs index a2a7b2e..686182e 100644 --- a/src/Anonymizer/Movers/Basic/GidxPacketMover.cs +++ b/src/Anonymizer/Movers/Basic/GidxPacketMover.cs @@ -22,7 +22,7 @@ public class GidxPacketMover : AbstractMover { Value = packet.FamilySubPacket.Value is null ? null : packet.FamilySubPacket.Value with { - FamilyId = anonymizer.AnonymizeName(packet.FamilySubPacket.Value.FamilyId) + FamilyId = anonymizer.AnonymizeId(packet.FamilySubPacket.Value.FamilyId) } } }; diff --git a/src/Anonymizer/Movers/Basic/InPacketMover.cs b/src/Anonymizer/Movers/Basic/InPacketMover.cs index b4c88af..122c2be 100644 --- a/src/Anonymizer/Movers/Basic/InPacketMover.cs +++ b/src/Anonymizer/Movers/Basic/InPacketMover.cs @@ -35,7 +35,7 @@ public class InPacketMover : AbstractMover ? null : packet.PlayerSubPacket.FamilySubPacket.Value with { - FamilyId = anonymizer.AnonymizeName + FamilyId = anonymizer.AnonymizeId (packet.PlayerSubPacket.FamilySubPacket.Value.FamilyId) } } diff --git a/src/Anonymizer/Movers/Basic/PinitPacketMover.cs b/src/Anonymizer/Movers/Basic/PinitPacketMover.cs index 09545b8..7381599 100644 --- a/src/Anonymizer/Movers/Basic/PinitPacketMover.cs +++ b/src/Anonymizer/Movers/Basic/PinitPacketMover.cs @@ -17,7 +17,7 @@ public class PinitPacketMover : AbstractMover { return packet with { - PinitSubPackets = packet.PinitSubPackets?.Select + PinitSubPackets = packet.PinitSubPackets.Select ( x => x with { diff --git a/src/Anonymizer/Movers/Basic/PtctlPacketMover.cs b/src/Anonymizer/Movers/Basic/PtctlPacketMover.cs new file mode 100644 index 0000000..0580be8 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/PtctlPacketMover.cs @@ -0,0 +1,26 @@ +// +// PtctlPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Client.Mates; + +namespace Anonymizer.Movers.Basic; + +/// +public class PtctlPacketMover : AbstractMover +{ + /// + public override PtctlPacket Move(IAnonymizer anonymizer, PtctlPacket packet) + => packet with + { + Controls = packet.Controls.Select + ( + x => x with + { + MateTransportId = anonymizer.AnonymizeId(x.MateTransportId) + } + ).ToArray() + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/RaidfhpPacketMover.cs b/src/Anonymizer/Movers/Basic/RaidfhpPacketMover.cs new file mode 100644 index 0000000..8fd46da --- /dev/null +++ b/src/Anonymizer/Movers/Basic/RaidfhpPacketMover.cs @@ -0,0 +1,26 @@ +// +// RaidfhpPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Raids; + +namespace Anonymizer.Movers.Basic; + +/// +public class RaidfhpPacketMover : AbstractMover +{ + /// + public override RaidfhpPacket Move(IAnonymizer anonymizer, RaidfhpPacket packet) + => packet with + { + HpSubPackets = packet.HpSubPackets.Select + ( + x => x with + { + PlayerId = anonymizer.AnonymizeId(x.PlayerId) + } + ).ToArray() + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/RaidfmpPacketMover.cs b/src/Anonymizer/Movers/Basic/RaidfmpPacketMover.cs new file mode 100644 index 0000000..e15af7c --- /dev/null +++ b/src/Anonymizer/Movers/Basic/RaidfmpPacketMover.cs @@ -0,0 +1,26 @@ +// +// RaidfmpPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Raids; + +namespace Anonymizer.Movers.Basic; + +/// +public class RaidfmpPacketMover : AbstractMover +{ + /// + public override RaidfmpPacket Move(IAnonymizer anonymizer, RaidfmpPacket packet) + => packet with + { + HpSubPackets = packet.HpSubPackets.Select + ( + x => x with + { + PlayerId = anonymizer.AnonymizeId(x.PlayerId) + } + ).ToArray() + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/RcPacketMover.cs b/src/Anonymizer/Movers/Basic/RcPacketMover.cs new file mode 100644 index 0000000..33d4c0b --- /dev/null +++ b/src/Anonymizer/Movers/Basic/RcPacketMover.cs @@ -0,0 +1,20 @@ +// +// RcPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Battle; + +namespace Anonymizer.Movers.Basic; + +/// +public class RcPacketMover : AbstractMover +{ + /// + public override RcPacket Move(IAnonymizer anonymizer, RcPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/RestPacketMover.cs b/src/Anonymizer/Movers/Basic/RestPacketMover.cs new file mode 100644 index 0000000..f4f96bd --- /dev/null +++ b/src/Anonymizer/Movers/Basic/RestPacketMover.cs @@ -0,0 +1,20 @@ +// +// RestPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.UI; + +namespace Anonymizer.Movers.Basic; + +/// +public class RestPacketMover : AbstractMover +{ + /// + public override RestPacket Move(IAnonymizer anonymizer, RestPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/Sayi2PacketMover.cs b/src/Anonymizer/Movers/Basic/Sayi2PacketMover.cs new file mode 100644 index 0000000..d784ddf --- /dev/null +++ b/src/Anonymizer/Movers/Basic/Sayi2PacketMover.cs @@ -0,0 +1,16 @@ +// +// Sayi2PacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Chat; + +namespace Anonymizer.Movers.Basic; + +/* +public class Sayi2PacketMover : AbstractMover +{ + +} +*/ \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/SayiPacketMover.cs b/src/Anonymizer/Movers/Basic/SayiPacketMover.cs new file mode 100644 index 0000000..8d49cbb --- /dev/null +++ b/src/Anonymizer/Movers/Basic/SayiPacketMover.cs @@ -0,0 +1,20 @@ +// +// SayiPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Chat; + +namespace Anonymizer.Movers.Basic; + +/// +public class SayiPacketMover : AbstractMover +{ + /// + public override SayiPacket Move(IAnonymizer anonymizer, SayiPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/SayitemtPacketMover.cs b/src/Anonymizer/Movers/Basic/SayitemtPacketMover.cs new file mode 100644 index 0000000..a0ad6cb --- /dev/null +++ b/src/Anonymizer/Movers/Basic/SayitemtPacketMover.cs @@ -0,0 +1,21 @@ +// +// SayitemtPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Chat; + +namespace Anonymizer.Movers.Basic; + +/// +public class SayitemtPacketMover : AbstractMover +{ + /// + public override SayitemtPacket Move(IAnonymizer anonymizer, SayitemtPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId), + Name = anonymizer.AnonymizeName(packet.Name) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/SaytPacketMover.cs b/src/Anonymizer/Movers/Basic/SaytPacketMover.cs new file mode 100644 index 0000000..75fde7d --- /dev/null +++ b/src/Anonymizer/Movers/Basic/SaytPacketMover.cs @@ -0,0 +1,21 @@ +// +// SaytPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Chat; + +namespace Anonymizer.Movers.Basic; + +/// +public class SaytPacketMover : AbstractMover +{ + /// + public override SaytPacket Move(IAnonymizer anonymizer, SaytPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId), + Name = anonymizer.AnonymizeName(packet.Name) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/SpkPacketMover.cs b/src/Anonymizer/Movers/Basic/SpkPacketMover.cs new file mode 100644 index 0000000..89ff034 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/SpkPacketMover.cs @@ -0,0 +1,21 @@ +// +// SpkPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Chat; + +namespace Anonymizer.Movers.Basic; + +/// +public class SpkPacketMover : AbstractMover +{ + /// + public override SpkPacket Move(IAnonymizer anonymizer, SpkPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId), + Name = anonymizer.AnonymizeName(packet.Name) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/SuctlPacketMover.cs b/src/Anonymizer/Movers/Basic/SuctlPacketMover.cs new file mode 100644 index 0000000..fe745e0 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/SuctlPacketMover.cs @@ -0,0 +1,21 @@ +// +// SuctlPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Client.Mates; + +namespace Anonymizer.Movers.Basic; + +/// +public class SuctlPacketMover : AbstractMover +{ + /// + public override SuctlPacket Move(IAnonymizer anonymizer, SuctlPacket packet) + => packet with + { + MateTransportId = anonymizer.AnonymizeId(packet.MateTransportId), + TargetId = anonymizer.AnonymizeId(packet.TargetId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/ThrowPacketMover.cs b/src/Anonymizer/Movers/Basic/ThrowPacketMover.cs new file mode 100644 index 0000000..49ed8c6 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/ThrowPacketMover.cs @@ -0,0 +1,20 @@ +// +// ThrowPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Maps; + +namespace Anonymizer.Movers.Basic; + +/// +public class ThrowPacketMover : AbstractMover +{ + /// + public override ThrowPacket Move(IAnonymizer anonymizer, ThrowPacket packet) + => packet with + { + DropId = anonymizer.AnonymizeId(packet.DropId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/Movers/Basic/TpPacketMover.cs b/src/Anonymizer/Movers/Basic/TpPacketMover.cs new file mode 100644 index 0000000..a732db1 --- /dev/null +++ b/src/Anonymizer/Movers/Basic/TpPacketMover.cs @@ -0,0 +1,20 @@ +// +// TpPacketMover.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using NosSmooth.Packets.Server.Maps; + +namespace Anonymizer.Movers.Basic; + +/// +public class TpPacketMover : AbstractMover +{ + /// + public override TpPacket Move(IAnonymizer anonymizer, TpPacket packet) + => packet with + { + EntityId = anonymizer.AnonymizeId(packet.EntityId) + }; +} \ No newline at end of file diff --git a/src/Anonymizer/PacketProcessor.cs b/src/Anonymizer/PacketProcessor.cs index 9d762e2..52765ed 100644 --- a/src/Anonymizer/PacketProcessor.cs +++ b/src/Anonymizer/PacketProcessor.cs @@ -82,18 +82,17 @@ public class PacketProcessor { if (mover.ShouldHandle(packet)) { - var movedPacket = mover.Move(_anonymizer, packet); - var serializedResult = _packetSerializer.Serialize(movedPacket); - if (!serializedResult.IsDefined(out var serialized)) - { - return Result.FromError(serializedResult); - } - - return new ProcessedPacket(packetInfo.Packet, serialized, true); + packet = mover.Move(_anonymizer, packet); } } - return new ProcessedPacket(packetInfo.Packet, packetInfo.Packet, true); + var serializedResult = _packetSerializer.Serialize(packet); + if (!serializedResult.IsDefined(out var serialized)) + { + return Result.FromError(serializedResult); + } + + return new ProcessedPacket(packetInfo.Packet, serialized, true); } /// -- 2.48.1