c++ - 如何在 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 - 问:比较 C 中的字段 (Libfdr) 和数组
- rx-java - 为 Object Flux 实现 Upsert 功能
- tensorflow - 为什么在 conda 虚拟环境中使用 pip 会产生全局效果?
- kotlin - Ktor 客户端身份验证功能不发送授权标头
- javascript - 找不到与 @angular-devkit/build-angular@0.901.1 匹配的版本
- python - 在 Windows 中安装 Python-saml 包时出错
- angular - angular2材料设计如何从dataSource动态填充mat-card?
- java - 如何通过 servlet 提供批量文件以供下载?
- linux - 在 ubuntu16.04 上编译 opencv3.2.0 失败
- matlab - 在matlab中编写计算悬臂梁弯矩的脚本