TankShield 1.0.0

dotnet add package TankShield --version 1.0.0
NuGet\Install-Package TankShield -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TankShield" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TankShield --version 1.0.0
#r "nuget: TankShield, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TankShield as a Cake Addin
#addin nuget:?package=TankShield&version=1.0.0

// Install TankShield as a Cake Tool
#tool nuget:?package=TankShield&version=1.0.0

TankShield

TankShield é uma pequena biblioteca que pode ser usada para evitar ataques no jogo DDTank.

Instalação

Instale a biblioteca a partir do NuGet.

Install-Package TankShield

Como usar

Bloquear ataques por endereço de IP

Usando IPAddressAttackMgr é possível bloquear ataques ao jogo por endereço de IP.

Cada vez que IPAddressAttackMgr.AddIPAddress(IPAddress ipAddress, int blockInCount = 5) é chamado, o endereço de IP especificado é guardado e ao atingir a quantidade especificada no parâmetro blockInCount o IP é bloqueado no Firewall do Windows.

Exemplo de uso:

var ipAddress = IPAddress.Parse("127.0.0.1");

// Neste exemplo, na 5ª adição o endereço de IP 127.0.0.1 será bloqueado.
IPAddressAttackMgr.AddIPAddress(ipAddress, blockInCount: 5);
Implementação recomendada

Em PacketProcessor.HandlePacket(GSPacketIn packet), procure pela chamada packetHandler.HandlePacket(Client, packet), note que junto dele terá uma condição (if) semelhante a abaixo:

if (packet.Code is 1 || Client.Player is not null)
{
    packetHandler.HandlePacket(Client, packet);
}

Adicione um else para bloquear ataques com pacotes aleatórios enviados para o serviço do jogo:

if (packet.Code is 1 || Client.Player is not null)
{
    packetHandler.HandlePacket(Client, packet);
}
// Adicione um código semelhante ao abaixo.
else
{
    string ipAddressWithoutPort = Client.TcpEndpoint.Split(':').First();

    IPAddressAttackMgr.AddIPAddress(IPAddress.Parse(ipAddressWithoutPort));

    s_log.Error($"O pacote de código '{packet.Code}' não tem um jogador. TcpEndpoint: " +
        $"{Client.TcpEndpoint} - {ipAddressWithoutPort}.");
}

Autores

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 133 2/9/2024