首页 > 解决方案 > 如何在 Windows 中阻止 http 洪水连接

问题描述

我有一个用 c++ 制作的应用程序,它充当服务器。游戏服务器.exe

问题是他们设法通过 http 洪水连接攻击 gameserver.exe,例如 http://ip:port

这些攻击是从一个名为“railgun”的应用程序发出的

如何阻止或阻止这些 http 连接?

目前我在gameserver.exe应用程序中使用了防洪,基本上就是这样。

int gObjGetIPIndex(char* IpAddress)
{
    int Ret = -1;

    for (int x = 0; x < LastIPList; x++)
    {
        if (IPList[x][0] == IpAddress[0])
        {
            if (strcmp(IPList[x], IpAddress) == 0)
            {
                return x;
                break;
            }
        }
    }

    Ret = LastIPList;
    sprintf(IPList[LastIPList], "%s", IpAddress);
    LastIPList++;
    if (LastIPList >= 2000)LastIPList = 0;
    return Ret;
}


short gObjAdd(SOCKET socket, char* IpAddress, int aIndex) // OK stdafx.h ? 
{
    if (OBJECT_RANGE(aIndex) == 0)
    {
        return -1;
    }

    if (gObj[aIndex].Connected != OBJECT_OFFLINE)
    {
        return -1;
    }

    //========================================
    // Anti Flood Fix 13/08/2020
    //========================================

    if (gServerInfo.m_EnableAntiflood == 1)
    {
        int IPIndex = gObjGetIPIndex(IpAddress);

        DWORD CurTick = GetTickCount();

        if ((CurTick - LastConnect[IPIndex]) < 1000)
        {
            LastConnect[IPIndex] = CurTick;


            LogAdd(LOG_RED, "[AntiFlood][%d] BlockAttack (%s)", aIndex, IpAddress);

            return -1;
        }

        LastConnect[IPIndex] = CurTick;
    }

谢谢你的时间。

标签: c++

解决方案


推荐阅读