mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
added ipban support
commands: /#ipban <nick> /#ipunban <ip>
This commit is contained in:
parent
371af9c241
commit
5784c14ab7
11 changed files with 271 additions and 1 deletions
|
@ -183,6 +183,44 @@ void cmd_teleport(std::wostringstream &os,
|
|||
os<< L"-!- Teleported.";
|
||||
}
|
||||
|
||||
void cmd_ipbanunban(std::wostringstream &os, ServerCommandContext *ctx)
|
||||
{
|
||||
if((ctx->privs && PRIV_BAN) == 0)
|
||||
{
|
||||
os<<L"-!- You don't have permission to do that";
|
||||
return;
|
||||
}
|
||||
|
||||
if(ctx->parms.size() != 2)
|
||||
{
|
||||
os<<L"-!- Missing parameter";
|
||||
return;
|
||||
}
|
||||
if(ctx->parms[0] == L"ipban")
|
||||
{
|
||||
Player *player = ctx->env->getPlayer(wide_to_narrow(ctx->parms[1]).c_str());
|
||||
|
||||
if(player == NULL)
|
||||
{
|
||||
os<<L"-!- No such Player!";
|
||||
return;
|
||||
}
|
||||
|
||||
con::Peer *peer = ctx->server->getPeerNoEx(player->peer_id);
|
||||
if(peer == NULL)
|
||||
{
|
||||
dstream<<"peer was not found!"<<std::endl;
|
||||
}
|
||||
ctx->server->setIpBanned(peer->address.serializeString());
|
||||
os<<L"-!- IP: "<<narrow_to_wide(peer->address.serializeString())<<L" was banned!";
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->server->unsetIpBanned(wide_to_narrow(ctx->parms[1]));
|
||||
os<<L"-!- IP: "<<ctx->parms[1]<<L" was unbanned!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::wstring processServerCommand(ServerCommandContext *ctx)
|
||||
{
|
||||
|
@ -204,6 +242,8 @@ std::wstring processServerCommand(ServerCommandContext *ctx)
|
|||
os<<L" teleport";
|
||||
if(privs & PRIV_PRIVS)
|
||||
os<<L" grant revoke";
|
||||
if(privs & PRIV_BAN)
|
||||
os<<L" ipban ipunban";
|
||||
}
|
||||
else if(ctx->parms[0] == L"status")
|
||||
{
|
||||
|
@ -233,6 +273,10 @@ std::wstring processServerCommand(ServerCommandContext *ctx)
|
|||
{
|
||||
cmd_teleport(os, ctx);
|
||||
}
|
||||
else if(ctx->parms[0] == L"ipban" || ctx->parms[0] == L"ipunban")
|
||||
{
|
||||
cmd_ipbanunban(os, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
os<<L"-!- Invalid command: " + ctx->parms[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue