mirror of
https://github.com/ioquake/ioq3.git
synced 2025-05-31 00:51:17 +00:00
- Switch master server protocol to dpmaster for better game separation. Based partly on patch by Zack Middleton
- Get rid of ugly cvars sv_heartbeat and cl_gamename and replace with single com_gamename - Remove sv_flatline. Flatlines are ignored by dpmaster and are considered to be insecure because flatlines can be udp-spoofed.
This commit is contained in:
parent
23f6fd1633
commit
ba385fa43c
9 changed files with 41 additions and 45 deletions
|
@ -109,8 +109,6 @@ cvar_t *cl_guidServerUniq;
|
|||
|
||||
cvar_t *cl_consoleKeys;
|
||||
|
||||
cvar_t *cl_gamename;
|
||||
|
||||
clientActive_t cl;
|
||||
clientConnection_t clc;
|
||||
clientStatic_t cls;
|
||||
|
@ -2306,9 +2304,9 @@ void CL_CheckForResend( void ) {
|
|||
#endif
|
||||
|
||||
// The challenge request shall be followed by a client challenge so no malicious server can hijack this connection.
|
||||
// Add the heartbeat gamename so the server knows we're running the correct game and can reject the client
|
||||
// Add the gamename so the server knows we're running the correct game or can reject the client
|
||||
// with a meaningful message
|
||||
Com_sprintf(data, sizeof(data), "getchallenge %d %s", clc.challenge, Cvar_VariableString("sv_heartbeat"));
|
||||
Com_sprintf(data, sizeof(data), "getchallenge %d %s", clc.challenge, com_gamename->string);
|
||||
|
||||
NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "%s", data);
|
||||
break;
|
||||
|
@ -3472,8 +3470,6 @@ void CL_Init( void ) {
|
|||
// ~ and `, as keys and characters
|
||||
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE);
|
||||
|
||||
cl_gamename = Cvar_Get("cl_gamename", GAMENAME_FOR_MASTER, CVAR_TEMP);
|
||||
|
||||
// userinfo
|
||||
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
|
||||
Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE );
|
||||
|
@ -3696,9 +3692,19 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) {
|
|||
char info[MAX_INFO_STRING];
|
||||
char *infoString;
|
||||
int prot;
|
||||
char *gamename;
|
||||
|
||||
infoString = MSG_ReadString( msg );
|
||||
|
||||
// if this isn't the correct gamename, ignore it
|
||||
gamename = Info_ValueForKey( infoString, "gamename" );
|
||||
|
||||
if (gamename && *gamename && strcmp(gamename, com_gamename->string))
|
||||
{
|
||||
Com_DPrintf( "Game mismatch in info packet: %s\n", infoString );
|
||||
return;
|
||||
}
|
||||
|
||||
// if this isn't the correct protocol version, ignore it
|
||||
prot = atoi( Info_ValueForKey( infoString, "protocol" ) );
|
||||
|
||||
|
@ -4078,16 +4084,17 @@ void CL_GlobalServers_f( void ) {
|
|||
if(v4enabled)
|
||||
{
|
||||
Com_sprintf(command, sizeof(command), "getserversExt %s %s",
|
||||
cl_gamename->string, Cmd_Argv(2));
|
||||
com_gamename->string, Cmd_Argv(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_sprintf(command, sizeof(command), "getserversExt %s %s ipv6",
|
||||
cl_gamename->string, Cmd_Argv(2));
|
||||
com_gamename->string, Cmd_Argv(2));
|
||||
}
|
||||
}
|
||||
else
|
||||
Com_sprintf(command, sizeof(command), "getservers %s", Cmd_Argv(2));
|
||||
Com_sprintf(command, sizeof(command), "getservers %s %s",
|
||||
com_gamename->string, Cmd_Argv(2));
|
||||
|
||||
for (i=3; i < count; i++)
|
||||
{
|
||||
|
|
|
@ -85,6 +85,7 @@ cvar_t *com_minimized;
|
|||
cvar_t *com_maxfpsMinimized;
|
||||
cvar_t *com_abnormalExit;
|
||||
cvar_t *com_standalone;
|
||||
cvar_t *com_gamename;
|
||||
cvar_t *com_protocol;
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
cvar_t *com_legacyprotocol;
|
||||
|
@ -2793,6 +2794,7 @@ void Com_Init( char *commandLine ) {
|
|||
|
||||
s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ );
|
||||
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
|
||||
com_gamename = Cvar_Get("com_gamename", GAMENAME_FOR_MASTER, CVAR_SERVERINFO | CVAR_INIT);
|
||||
com_protocol = Cvar_Get("com_protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_INIT);
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
com_legacyprotocol = Cvar_Get("com_legacyprotocol", va("%i", PROTOCOL_LEGACY_VERSION), CVAR_INIT);
|
||||
|
|
|
@ -31,27 +31,26 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#define BASEGAME "foobar"
|
||||
#define CLIENT_WINDOW_TITLE "changeme"
|
||||
#define CLIENT_WINDOW_MIN_TITLE "changeme2"
|
||||
#define GAMENAME_FOR_MASTER "iofoo3" // must NOT contain whitespaces
|
||||
#define HEARTBEAT_FOR_MASTER GAMENAME_FOR_MASTER
|
||||
#define FLATLINE_FOR_MASTER GAMENAME_FOR_MASTER "dead"
|
||||
#define HOMEPATH_NAME_UNIX ".foo"
|
||||
#define HOMEPATH_NAME_WIN "FooBar"
|
||||
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
|
||||
#define GAMENAME_FOR_MASTER "foobar" // must NOT contain whitespace
|
||||
// #define LEGACY_PROTOCOL // You probably don't need this for your standalone game
|
||||
#else
|
||||
#define PRODUCT_NAME "ioq3"
|
||||
#define BASEGAME "baseq3"
|
||||
#define CLIENT_WINDOW_TITLE "ioquake3"
|
||||
#define CLIENT_WINDOW_MIN_TITLE "ioq3"
|
||||
#define GAMENAME_FOR_MASTER "Quake3Arena"
|
||||
#define HEARTBEAT_FOR_MASTER "QuakeArena-1"
|
||||
#define FLATLINE_FOR_MASTER HEARTBEAT_FOR_MASTER
|
||||
#define HOMEPATH_NAME_UNIX ".q3a"
|
||||
#define HOMEPATH_NAME_WIN "Quake3"
|
||||
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
|
||||
#define GAMENAME_FOR_MASTER "Quake3Arena"
|
||||
#define LEGACY_PROTOCOL
|
||||
#endif
|
||||
|
||||
// Heartbeat for dpmaster protocol. You shouldn't change this unless you know what you're doing
|
||||
#define HEARTBEAT_FOR_MASTER "DarkPlaces"
|
||||
|
||||
#define BASETA "missionpack"
|
||||
|
||||
#ifndef PRODUCT_VERSION
|
||||
|
|
|
@ -870,6 +870,7 @@ extern cvar_t *sv_paused;
|
|||
extern cvar_t *cl_packetdelay;
|
||||
extern cvar_t *sv_packetdelay;
|
||||
|
||||
extern cvar_t *com_gamename;
|
||||
extern cvar_t *com_protocol;
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
extern cvar_t *com_legacyprotocol;
|
||||
|
|
|
@ -294,8 +294,6 @@ extern cvar_t *sv_lanForceRate;
|
|||
extern cvar_t *sv_strictAuth;
|
||||
#endif
|
||||
extern cvar_t *sv_banFile;
|
||||
extern cvar_t *sv_heartbeat;
|
||||
extern cvar_t *sv_flatline;
|
||||
|
||||
extern serverBan_t serverBans[SERVER_MAXBANS];
|
||||
extern int serverBansCount;
|
||||
|
|
|
@ -70,10 +70,10 @@ void SV_GetChallenge(netadr_t from)
|
|||
if(gameName && *gameName)
|
||||
{
|
||||
// reject client if the heartbeat string sent by the client doesn't match ours
|
||||
if(strcmp(gameName, sv_heartbeat->string))
|
||||
if(strcmp(gameName, com_gamename->string))
|
||||
{
|
||||
NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server\n",
|
||||
sv_heartbeat->string);
|
||||
com_gamename->string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -686,8 +686,6 @@ void SV_Init (void)
|
|||
sv_strictAuth = Cvar_Get ("sv_strictAuth", "1", CVAR_ARCHIVE );
|
||||
#endif
|
||||
sv_banFile = Cvar_Get("sv_banFile", "serverbans.dat", CVAR_ARCHIVE);
|
||||
sv_heartbeat = Cvar_Get("sv_heartbeat", HEARTBEAT_FOR_MASTER, CVAR_INIT);
|
||||
sv_flatline = Cvar_Get("sv_flatline", FLATLINE_FOR_MASTER, CVAR_INIT);
|
||||
|
||||
// initialize bot cvars so they are listed and can be set before loading the botlib
|
||||
SV_BotInitCvars();
|
||||
|
|
|
@ -61,9 +61,6 @@ cvar_t *sv_lanForceRate; // dedicated 1 (LAN) server forces local client rates t
|
|||
cvar_t *sv_strictAuth;
|
||||
#endif
|
||||
cvar_t *sv_banFile;
|
||||
cvar_t *sv_heartbeat; // Heartbeat string that is sent to the master
|
||||
cvar_t *sv_flatline; // If the master server supports it we can send a flatline
|
||||
// when server is killed
|
||||
|
||||
serverBan_t serverBans[SERVER_MAXBANS];
|
||||
int serverBansCount = 0;
|
||||
|
@ -338,11 +335,11 @@ Informs all masters that this server is going down
|
|||
void SV_MasterShutdown( void ) {
|
||||
// send a hearbeat right now
|
||||
svs.nextHeartbeatTime = -9999;
|
||||
SV_MasterHeartbeat(sv_flatline->string);
|
||||
SV_MasterHeartbeat(HEARTBEAT_FOR_MASTER);
|
||||
|
||||
// send it again to minimize chance of drops
|
||||
svs.nextHeartbeatTime = -9999;
|
||||
SV_MasterHeartbeat(sv_flatline->string);
|
||||
SV_MasterHeartbeat(HEARTBEAT_FOR_MASTER);
|
||||
|
||||
// when the master tries to poll the server, it won't respond, so
|
||||
// it will be removed from the list
|
||||
|
@ -644,6 +641,8 @@ void SVC_Info( netadr_t from ) {
|
|||
// to prevent timed spoofed reply packets that add ghost servers
|
||||
Info_SetValueForKey( infostring, "challenge", Cmd_Argv(1) );
|
||||
|
||||
Info_SetValueForKey( infostring, "gamename", com_gamename->string );
|
||||
|
||||
#ifdef LEGACY_PROTOCOL
|
||||
if(com_legacyprotocol->integer > 0)
|
||||
Info_SetValueForKey(infostring, "protocol", va("%i", com_legacyprotocol->integer));
|
||||
|
@ -1154,7 +1153,7 @@ void SV_Frame( int msec ) {
|
|||
SV_SendClientMessages();
|
||||
|
||||
// send a heartbeat to the master if needed
|
||||
SV_MasterHeartbeat(sv_heartbeat->string);
|
||||
SV_MasterHeartbeat(HEARTBEAT_FOR_MASTER);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue