mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-14 21:20:26 +01:00
engine: client: only accept server list from master servers (thanks @tyabus for idea)
This commit is contained in:
parent
5a5e72c424
commit
01a3321d63
@ -2095,6 +2095,12 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
||||
}
|
||||
else if( !Q_strcmp( c, "f" ))
|
||||
{
|
||||
if( !NET_IsMasterAdr( from ))
|
||||
{
|
||||
Con_Printf( S_WARN "unexpected server list packet from %s\n", NET_AdrToString( from ));
|
||||
return;
|
||||
}
|
||||
|
||||
// serverlist got from masterserver
|
||||
while( MSG_GetNumBitsLeft( msg ) > 8 )
|
||||
{
|
||||
|
@ -868,6 +868,7 @@ void GAME_EXPORT ID_SetCustomClientID( const char *id );
|
||||
void NET_InitMasters( void );
|
||||
void NET_SaveMasters( void );
|
||||
qboolean NET_SendToMasters( netsrc_t sock, size_t len, const void *data );
|
||||
qboolean NET_IsMasterAdr( netadr_t adr );
|
||||
|
||||
#ifdef REF_DLL
|
||||
#error "common.h in ref_dll"
|
||||
|
@ -21,6 +21,7 @@ typedef struct master_s
|
||||
qboolean sent;
|
||||
qboolean save;
|
||||
string address;
|
||||
netadr_t adr; // temporary, rewritten after each send
|
||||
} master_t;
|
||||
|
||||
struct masterlist_s
|
||||
@ -44,31 +45,32 @@ qboolean NET_SendToMasters( netsrc_t sock, size_t len, const void *data )
|
||||
|
||||
for( list = ml.list; list; list = list->next )
|
||||
{
|
||||
netadr_t adr;
|
||||
int res;
|
||||
|
||||
if( list->sent )
|
||||
continue;
|
||||
|
||||
res = NET_StringToAdrNB( list->address, &adr );
|
||||
res = NET_StringToAdrNB( list->address, &list->adr );
|
||||
|
||||
if( !res )
|
||||
{
|
||||
Con_Reportf( "Can't resolve adr: %s\n", list->address );
|
||||
list->sent = true;
|
||||
list->adr.type = NA_UNUSED;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( res == 2 )
|
||||
{
|
||||
list->sent = false;
|
||||
list->adr.type = NA_UNUSED;
|
||||
wait = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
list->sent = true;
|
||||
|
||||
NET_SendPacket( sock, len, data, adr );
|
||||
NET_SendPacket( sock, len, data, list->adr );
|
||||
}
|
||||
|
||||
if( !wait )
|
||||
@ -85,6 +87,25 @@ qboolean NET_SendToMasters( netsrc_t sock, size_t len, const void *data )
|
||||
return wait;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
NET_IsMasterAdr
|
||||
|
||||
========================
|
||||
*/
|
||||
qboolean NET_IsMasterAdr( netadr_t adr )
|
||||
{
|
||||
master_t *master;
|
||||
|
||||
for( master = ml.list; master; master = master->next )
|
||||
{
|
||||
if( NET_CompareAdr( adr, master->adr ))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
NET_AddMaster
|
||||
@ -107,6 +128,7 @@ static void NET_AddMaster( const char *addr, qboolean save )
|
||||
master->sent = false;
|
||||
master->save = save;
|
||||
master->next = NULL;
|
||||
master->adr.type = NA_UNUSED;
|
||||
|
||||
// link in
|
||||
if( last )
|
||||
@ -161,7 +183,10 @@ static void NET_ListMasters_f( void )
|
||||
|
||||
for( i = 1, list = ml.list; list; i++, list = list->next )
|
||||
{
|
||||
Msg( "%d\t%s\n", i, list->address );
|
||||
Msg( "%d\t%s", i, list->address );
|
||||
if( list->adr.type != NA_UNUSED )
|
||||
Msg( "\t%s\n", NET_AdrToString( list->adr ));
|
||||
else Msg( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user