Browse Source

engine: server: add rcon_enable cvar to control whether server should accept remote commands

pull/2/head
Alibek Omarov 2 years ago
parent
commit
e1431e1040
  1. 1
      engine/server/server.h
  2. 3
      engine/server/sv_client.c
  3. 2
      engine/server/sv_main.c

1
engine/server/server.h

@ -396,6 +396,7 @@ extern convar_t sv_maxunlag;
extern convar_t sv_unlagpush; extern convar_t sv_unlagpush;
extern convar_t sv_unlagsamples; extern convar_t sv_unlagsamples;
extern convar_t rcon_password; extern convar_t rcon_password;
extern convar_t rcon_enable;
extern convar_t sv_instancedbaseline; extern convar_t sv_instancedbaseline;
extern convar_t sv_background_freeze; extern convar_t sv_background_freeze;
extern convar_t sv_minupdaterate; extern convar_t sv_minupdaterate;

3
engine/server/sv_client.c

@ -1013,6 +1013,9 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg )
char remaining[1024]; char remaining[1024];
int i; int i;
if( !rcon_enable.value )
return;
Con_Printf( "Rcon from %s:\n%s\n", NET_AdrToString( from ), MSG_GetData( msg ) + 4 ); 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 )); 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 ); SV_BeginRedirect( from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect );

2
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_unlagpush, "0.0", 0, "interpolation bias for unlag time" );
CVAR_DEFINE_AUTO( sv_unlagsamples, "1", 0, "max samples to interpolate" ); CVAR_DEFINE_AUTO( sv_unlagsamples, "1", 0, "max samples to interpolate" );
CVAR_DEFINE_AUTO( rcon_password, "", 0, "remote connect password" ); 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_filterban, "1", 0, "filter banned users" );
CVAR_DEFINE_AUTO( sv_cheats, "0", FCVAR_SERVER, "allow cheats on server" ); 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" ); 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( &temp1 );
Cvar_RegisterVariable( &rcon_password ); Cvar_RegisterVariable( &rcon_password );
Cvar_RegisterVariable( &rcon_enable );
Cvar_RegisterVariable( &sv_stepsize ); Cvar_RegisterVariable( &sv_stepsize );
Cvar_RegisterVariable( &sv_newunit ); Cvar_RegisterVariable( &sv_newunit );
Cvar_RegisterVariable( &hostname ); Cvar_RegisterVariable( &hostname );

Loading…
Cancel
Save