mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
Add hardcore-ban-ip property for IP banning on hardcore death
This commit introduces a new server property `hardcore-ban-ip` that controls whether players who die in hardcore mode are banned by their IP address. This setting should be set to `false` for playit.gg users! Key changes include: - Updated `banPlayerForHardcoreDeath` in `PlayerList.cpp` to check the `hardcoreBanIp` setting and handle IP bans accordingly. - Added `hardcore-ban-ip` to the default server properties in `ServerProperties.cpp`. - Declared the `hardcoreBanIp` boolean variable in `ServerProperties.h` to store the property value. These changes enhance the server's ability to enforce IP bans based on configuration settings.
This commit is contained in:
parent
090dd49ccd
commit
4a3128d32b
|
|
@ -42,6 +42,7 @@
|
||||||
#include "..\Minecraft.Server\Common\StringUtils.h"
|
#include "..\Minecraft.Server\Common\StringUtils.h"
|
||||||
#include "..\Minecraft.Server\ServerLogger.h"
|
#include "..\Minecraft.Server\ServerLogger.h"
|
||||||
#include "..\Minecraft.Server\ServerLogManager.h"
|
#include "..\Minecraft.Server\ServerLogManager.h"
|
||||||
|
#include "..\Minecraft.Server\ServerProperties.h"
|
||||||
extern bool g_Win64DedicatedServer;
|
extern bool g_Win64DedicatedServer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -1758,23 +1759,31 @@ void PlayerList::banPlayerForHardcoreDeath(ServerPlayer *player)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ban the player's IP address (uses same access path as CliCommandBanIp)
|
// Ban the player's IP address (uses same access path as CliCommandBanIp)
|
||||||
if (player->connection != nullptr && player->connection->connection != nullptr && player->connection->connection->getSocket() != nullptr)
|
auto serverConfig = ServerRuntime::LoadServerPropertiesConfig();
|
||||||
|
if (serverConfig.hardcoreBanIp)
|
||||||
{
|
{
|
||||||
const unsigned char smallId = player->connection->connection->getSocket()->getSmallId();
|
if (player->connection != nullptr && player->connection->connection != nullptr && player->connection->connection->getSocket() != nullptr)
|
||||||
std::string ip;
|
|
||||||
if (smallId != 0 && ServerRuntime::ServerLogManager::TryGetConnectionRemoteIp(smallId, &ip))
|
|
||||||
{
|
{
|
||||||
ServerRuntime::Access::AddIpBan(ip, metadata);
|
const unsigned char smallId = player->connection->connection->getSocket()->getSmallId();
|
||||||
ServerRuntime::LogInfof("Hardcore", "Player %s banned (XUID + IP %s) for dying in hardcore mode.", playerName.c_str(), ip.c_str());
|
std::string ip;
|
||||||
|
if (smallId != 0 && ServerRuntime::ServerLogManager::TryGetConnectionRemoteIp(smallId, &ip))
|
||||||
|
{
|
||||||
|
ServerRuntime::Access::AddIpBan(ip, metadata);
|
||||||
|
ServerRuntime::LogInfof("Hardcore", "Player %s banned (XUID + IP %s) for dying in hardcore mode.", playerName.c_str(), ip.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ServerRuntime::LogInfof("Hardcore", "Player %s banned (XUID only, IP not available) for dying in hardcore mode.", playerName.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerRuntime::LogInfof("Hardcore", "Player %s banned (XUID only, IP not available) for dying in hardcore mode.", playerName.c_str());
|
ServerRuntime::LogInfof("Hardcore", "Player %s banned (XUID only, no connection) for dying in hardcore mode.", playerName.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerRuntime::LogInfof("Hardcore", "Player %s banned (XUID only, no connection) for dying in hardcore mode.", playerName.c_str());
|
ServerRuntime::LogInfof("Hardcore", "Player %s banned (XUID only, IP ban disabled) for dying in hardcore mode.", playerName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send ban reason then defer the actual close to the next tick, because this
|
// Send ban reason then defer the actual close to the next tick, because this
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ static const ServerPropertyDefault kServerPropertyDefaults[] =
|
||||||
{ "gamertags", "true" },
|
{ "gamertags", "true" },
|
||||||
{ "generate-structures", "true" },
|
{ "generate-structures", "true" },
|
||||||
{ "hardcore", "false" },
|
{ "hardcore", "false" },
|
||||||
|
{ "hardcore-ban-ip", "true" },
|
||||||
{ "host-can-be-invisible", "true" },
|
{ "host-can-be-invisible", "true" },
|
||||||
{ "host-can-change-hunger", "true" },
|
{ "host-can-change-hunger", "true" },
|
||||||
{ "host-can-fly", "true" },
|
{ "host-can-fly", "true" },
|
||||||
|
|
@ -863,6 +864,7 @@ ServerPropertiesConfig LoadServerPropertiesConfig()
|
||||||
config.naturalRegeneration = ReadNormalizedBoolProperty(&merged, "natural-regeneration", true, &shouldWrite);
|
config.naturalRegeneration = ReadNormalizedBoolProperty(&merged, "natural-regeneration", true, &shouldWrite);
|
||||||
config.doDaylightCycle = ReadNormalizedBoolProperty(&merged, "do-daylight-cycle", true, &shouldWrite);
|
config.doDaylightCycle = ReadNormalizedBoolProperty(&merged, "do-daylight-cycle", true, &shouldWrite);
|
||||||
config.hardcore = ReadNormalizedBoolProperty(&merged, "hardcore", false, &shouldWrite);
|
config.hardcore = ReadNormalizedBoolProperty(&merged, "hardcore", false, &shouldWrite);
|
||||||
|
config.hardcoreBanIp = ReadNormalizedBoolProperty(&merged, "hardcore-ban-ip", true, &shouldWrite);
|
||||||
|
|
||||||
config.maxBuildHeight = ReadNormalizedIntProperty(&merged, "max-build-height", 256, 64, 256, &shouldWrite);
|
config.maxBuildHeight = ReadNormalizedIntProperty(&merged, "max-build-height", 256, 64, 256, &shouldWrite);
|
||||||
config.motd = ReadNormalizedStringProperty(&merged, "motd", "A Minecraft Server", 255, &shouldWrite);
|
config.motd = ReadNormalizedStringProperty(&merged, "motd", "A Minecraft Server", 255, &shouldWrite);
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,8 @@ namespace ServerRuntime
|
||||||
bool naturalRegeneration;
|
bool naturalRegeneration;
|
||||||
bool doDaylightCycle;
|
bool doDaylightCycle;
|
||||||
bool hardcore;
|
bool hardcore;
|
||||||
|
/** `hardcore-ban-ip` — whether hardcore death bans include IP bans */
|
||||||
|
bool hardcoreBanIp;
|
||||||
|
|
||||||
/** other MinecraftServer runtime settings */
|
/** other MinecraftServer runtime settings */
|
||||||
int maxBuildHeight;
|
int maxBuildHeight;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue