From: Mattia Basaglia Date: Fri, 16 Jan 2015 15:06:30 +0000 (+0100) Subject: Allow the server to kickban unconnected clients and prevent them from calling votes X-Git-Tag: xonotic-v0.8.1~139^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3b28561db09e63d23afd1773aa10610a43f24a68;p=xonotic%2Fxonotic-data.pk3dir.git Allow the server to kickban unconnected clients and prevent them from calling votes --- diff --git a/qcsrc/server/command/banning.qc b/qcsrc/server/command/banning.qc index 794854ded..aed01c7cb 100644 --- a/qcsrc/server/command/banning.qc +++ b/qcsrc/server/command/banning.qc @@ -69,7 +69,7 @@ void BanCommand_kickban(float request, float argc, string command) if(argc >= 2) { entity client = GetIndexedEntity(argc, 1); - float accepted = VerifyClientEntity(client, TRUE, FALSE); + float accepted = VerifyKickableEntity(client); float reason_arg, bantime, masksize; string reason; diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index c5ae7c7be..04ed4b284 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -21,6 +21,14 @@ string GetCallerName(entity caller) return admin_name(); //((autocvar_sv_adminnick != "") ? autocvar_sv_adminnick : autocvar_hostname); } +// verify that the client provided is acceptable for kicking +float VerifyKickableEntity(entity client) +{ + if (!IS_REAL_CLIENT(client)) + return CLIENT_NOT_REAL; + return CLIENT_ACCEPTABLE; +} + // verify that the client provided is acceptable for use float VerifyClientEntity(entity client, float must_be_real, float must_be_bots) { diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 214083eae..522ef4b7a 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -792,6 +792,7 @@ void VoteCommand_call(float request, entity caller, float argc, string vote_comm else if(!autocvar_sv_vote_gamestart && time < game_starttime) { print_to(caller, "^1Vote calling is not allowed before the match has started."); } else if(vote_called) { print_to(caller, "^1There is already a vote called."); } else if(!spectators_allowed && (caller && !IS_PLAYER(caller))) { print_to(caller, "^1Only players can call a vote."); } + else if(caller && !IS_CLIENT(caller)) { print_to(caller, "^1Only connected clients can vote."); } else if(timeout_status) { print_to(caller, "^1You can not call a vote while a timeout is active."); } else if(caller && (time < caller.vote_waittime)) { print_to(caller, strcat("^1You have to wait ^2", ftos(ceil(caller.vote_waittime - time)), "^1 seconds before you can again call a vote.")); } else if (!VoteCommand_checknasty(vote_command)) { print_to(caller, "^1Syntax error in command, see 'vhelp' for more info."); } diff --git a/qcsrc/server/ipban.qc b/qcsrc/server/ipban.qc index d3d7fdca6..666c3c2ce 100644 --- a/qcsrc/server/ipban.qc +++ b/qcsrc/server/ipban.qc @@ -459,7 +459,7 @@ float Ban_MaybeEnforceBanOnce(entity client) if(client.ban_checked) return FALSE; client.ban_checked = TRUE; - return Ban_MaybeEnforceBan(self); + return Ban_MaybeEnforceBan(client); } string Ban_Enforce(float i, string reason) @@ -604,6 +604,6 @@ void Ban_KickBanClient(entity client, float bantime, float masksize, string reas * not needed, as we enforce the ban in Ban_Insert anyway // and kick him sprint(client, strcat("Kickbanned: ", reason, "\n")); - dropclient(client); */ + dropclient(client); }