|
|
@ -639,7 +639,7 @@ void SV_DropClient( sv_client_t *cl, qboolean crash ) |
|
|
|
cl->frames = NULL; |
|
|
|
cl->frames = NULL; |
|
|
|
|
|
|
|
|
|
|
|
if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address )) |
|
|
|
if( NET_CompareBaseAdr( cl->netchan.remote_address, host.rd.address )) |
|
|
|
SV_EndRedirect(); |
|
|
|
SV_EndRedirect( &host.rd ); |
|
|
|
|
|
|
|
|
|
|
|
// throw away any residual garbage in the channel.
|
|
|
|
// throw away any residual garbage in the channel.
|
|
|
|
Netchan_Clear( &cl->netchan ); |
|
|
|
Netchan_Clear( &cl->netchan ); |
|
|
@ -676,22 +676,19 @@ SVC COMMAND REDIRECT |
|
|
|
|
|
|
|
|
|
|
|
============================================================================== |
|
|
|
============================================================================== |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SV_BeginRedirect( netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush)) |
|
|
|
static void SV_BeginRedirect( host_redirect_t *rd, netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( !target || !buffer || !buffersize || !flush ) |
|
|
|
rd->target = target; |
|
|
|
return; |
|
|
|
rd->buffer = buffer; |
|
|
|
|
|
|
|
rd->buffersize = buffersize; |
|
|
|
host.rd.target = target; |
|
|
|
rd->flush = flush; |
|
|
|
host.rd.buffer = buffer; |
|
|
|
rd->address = adr; |
|
|
|
host.rd.buffersize = buffersize; |
|
|
|
rd->buffer[0] = 0; |
|
|
|
host.rd.flush = flush; |
|
|
|
if( rd->lines == 0 ) |
|
|
|
host.rd.address = adr; |
|
|
|
rd->lines = -1; |
|
|
|
host.rd.buffer[0] = 0; |
|
|
|
|
|
|
|
if( host.rd.lines == 0 ) |
|
|
|
|
|
|
|
host.rd.lines = -1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SV_FlushRedirect( netadr_t adr, int dest, char *buf ) |
|
|
|
static void SV_FlushRedirect( netadr_t adr, int dest, char *buf ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT )) |
|
|
|
if( sv.current_client && FBitSet( sv.current_client->flags, FCL_FAKECLIENT )) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -712,18 +709,18 @@ void SV_FlushRedirect( netadr_t adr, int dest, char *buf ) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SV_EndRedirect( void ) |
|
|
|
void SV_EndRedirect( host_redirect_t *rd ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( host.rd.lines > 0 ) |
|
|
|
if( rd->lines > 0 ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if( host.rd.flush ) |
|
|
|
if( rd->flush ) |
|
|
|
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer ); |
|
|
|
rd->flush( rd->address, rd->target, rd->buffer ); |
|
|
|
|
|
|
|
|
|
|
|
host.rd.target = 0; |
|
|
|
rd->target = RD_NONE; |
|
|
|
host.rd.buffer = NULL; |
|
|
|
rd->buffer = NULL; |
|
|
|
host.rd.buffersize = 0; |
|
|
|
rd->buffersize = 0; |
|
|
|
host.rd.flush = NULL; |
|
|
|
rd->flush = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -733,25 +730,27 @@ Rcon_Print |
|
|
|
Print message to rcon buffer and send to rcon redirect target |
|
|
|
Print message to rcon buffer and send to rcon redirect target |
|
|
|
================ |
|
|
|
================ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void Rcon_Print( const char *pMsg ) |
|
|
|
void Rcon_Print( host_redirect_t *rd, const char *pMsg ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( host.rd.target && host.rd.lines && host.rd.flush && host.rd.buffer ) |
|
|
|
size_t len; |
|
|
|
{ |
|
|
|
|
|
|
|
size_t len = Q_strncat( host.rd.buffer, pMsg, host.rd.buffersize ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( len && host.rd.buffer[len-1] == '\n' ) |
|
|
|
if( !rd->target || !rd->lines || !rd->flush || !rd->buffer ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
len = Q_strncat( rd->buffer, pMsg, rd->buffersize ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( len && rd->buffer[len - 1] == '\n' ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer ); |
|
|
|
rd->flush( rd->address, rd->target, rd->buffer ); |
|
|
|
|
|
|
|
|
|
|
|
if( host.rd.lines > 0 ) |
|
|
|
if( rd->lines > 0 ) |
|
|
|
host.rd.lines--; |
|
|
|
rd->lines--; |
|
|
|
|
|
|
|
|
|
|
|
host.rd.buffer[0] = 0; |
|
|
|
rd->buffer[0] = 0; |
|
|
|
|
|
|
|
|
|
|
|
if( !host.rd.lines ) |
|
|
|
if( !rd->lines ) |
|
|
|
Msg( "End of redirection!\n" ); |
|
|
|
Msg( "End of redirection!\n" ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -1090,7 +1089,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg ) |
|
|
|
|
|
|
|
|
|
|
|
if( Rcon_Validate( )) |
|
|
|
if( Rcon_Validate( )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SV_BeginRedirect( from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect ); |
|
|
|
SV_BeginRedirect( &host.rd, from, RD_PACKET, outputbuf, sizeof( outputbuf ) - 16, SV_FlushRedirect ); |
|
|
|
|
|
|
|
|
|
|
|
remaining[0] = 0; |
|
|
|
remaining[0] = 0; |
|
|
|
for( i = 2; i < Cmd_Argc(); i++ ) |
|
|
|
for( i = 2; i < Cmd_Argc(); i++ ) |
|
|
@ -1101,7 +1100,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg ) |
|
|
|
} |
|
|
|
} |
|
|
|
Cmd_ExecuteString( remaining ); |
|
|
|
Cmd_ExecuteString( remaining ); |
|
|
|
|
|
|
|
|
|
|
|
SV_EndRedirect(); |
|
|
|
SV_EndRedirect( &host.rd ); |
|
|
|
} |
|
|
|
} |
|
|
|
else Con_Printf( S_ERROR "Bad rcon_password.\n" ); |
|
|
|
else Con_Printf( S_ERROR "Bad rcon_password.\n" ); |
|
|
|
} |
|
|
|
} |
|
|
|