From e1431e10401c1ca2711f854f7d5e0451c21f657c Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 12 Dec 2022 08:02:56 +0300 Subject: [PATCH] engine: server: add rcon_enable cvar to control whether server should accept remote commands --- engine/server/server.h | 1 + engine/server/sv_client.c | 3 +++ engine/server/sv_main.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/engine/server/server.h b/engine/server/server.h index d2df0bdc..a6dac467 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -396,6 +396,7 @@ extern convar_t sv_maxunlag; extern convar_t sv_unlagpush; extern convar_t sv_unlagsamples; extern convar_t rcon_password; +extern convar_t rcon_enable; extern convar_t sv_instancedbaseline; extern convar_t sv_background_freeze; extern convar_t sv_minupdaterate; diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index c713a1e2..ac4fd2ff 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -1013,6 +1013,9 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg ) char remaining[1024]; int i; + if( !rcon_enable.value ) + return; + Con_Printf( "Rcon from %s:\n%s\n", NET_AdrToString( from ), MSG_GetData( msg ) + 4 ); Log_Printf( "Rcon: \"%s\" from \"%s\"\n", MSG_GetData( msg ) + 4, NET_AdrToString( from )); SV_BeginRedirect( from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect ); diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index eefad86c..6aaa2238 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -30,6 +30,7 @@ CVAR_DEFINE_AUTO( sv_maxunlag, "0.5", 0, "max latency value which can be interpo CVAR_DEFINE_AUTO( sv_unlagpush, "0.0", 0, "interpolation bias for unlag time" ); CVAR_DEFINE_AUTO( sv_unlagsamples, "1", 0, "max samples to interpolate" ); CVAR_DEFINE_AUTO( rcon_password, "", 0, "remote connect password" ); +CVAR_DEFINE_AUTO( rcon_enable, "1", 0, "enable rcon" ); CVAR_DEFINE_AUTO( sv_filterban, "1", 0, "filter banned users" ); CVAR_DEFINE_AUTO( sv_cheats, "0", FCVAR_SERVER, "allow cheats on server" ); CVAR_DEFINE_AUTO( sv_instancedbaseline, "1", 0, "allow to use instanced baselines to saves network overhead" ); @@ -909,6 +910,7 @@ void SV_Init( void ) Cvar_RegisterVariable( &temp1 ); Cvar_RegisterVariable( &rcon_password ); + Cvar_RegisterVariable( &rcon_enable ); Cvar_RegisterVariable( &sv_stepsize ); Cvar_RegisterVariable( &sv_newunit ); Cvar_RegisterVariable( &hostname );