Revert protocol 69 pending further discussion (#4962)

This commit is contained in:
Thilo Schulz 2011-04-27 20:17:45 +00:00
parent 88693f9abd
commit d34c6b7e0b
12 changed files with 247 additions and 508 deletions

View file

@ -55,10 +55,8 @@ void SV_GetChallenge(netadr_t from)
int i;
int oldest;
int oldestTime;
int oldestClientTime;
int clientChallenge;
const char *clientChallenge = Cmd_Argv(1);
challenge_t *challenge;
qboolean wasfound = qfalse;
// ignore if we are in single player
if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) {
@ -66,30 +64,15 @@ void SV_GetChallenge(netadr_t from)
}
oldest = 0;
oldestClientTime = oldestTime = 0x7fffffff;
oldestTime = 0x7fffffff;
// see if we already have a challenge for this ip
challenge = &svs.challenges[0];
clientChallenge = atoi(Cmd_Argv(1));
for(i = 0 ; i < MAX_CHALLENGES ; i++, challenge++)
{
if(!challenge->connected && NET_CompareAdr(from, challenge->adr))
{
wasfound = qtrue;
if(challenge->time < oldestClientTime)
oldestClientTime = challenge->time;
}
if(wasfound && i >= MAX_CHALLENGES_MULTI)
{
i = MAX_CHALLENGES;
for (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) {
if (!challenge->connected && NET_CompareAdr( from, challenge->adr ) ) {
break;
}
if(challenge->time < oldestTime)
{
if ( challenge->time < oldestTime ) {
oldestTime = challenge->time;
oldest = i;
}
@ -99,16 +82,17 @@ void SV_GetChallenge(netadr_t from)
{
// this is the first time this client has asked for a challenge
challenge = &svs.challenges[oldest];
challenge->clientChallenge = clientChallenge;
challenge->clientChallenge = 0;
challenge->adr = from;
challenge->firstTime = svs.time;
challenge->time = svs.time;
challenge->connected = qfalse;
}
// always generate a new challenge number, so the client cannot circumvent sv_maxping
challenge->challenge = ( (rand() << 16) ^ rand() ) ^ svs.time;
challenge->wasrefused = qfalse;
challenge->time = svs.time;
#ifndef STANDALONE
// Drop the authorize stuff if this client is coming in via v6 as the auth server does not support ipv6.
@ -137,7 +121,7 @@ void SV_GetChallenge(netadr_t from)
// if they have been challenging for a long time and we
// haven't heard anything from the authorize server, go ahead and
// let them in, assuming the id server is down
else if(svs.time - oldestClientTime > AUTHORIZE_TIMEOUT)
else if(svs.time - challenge->firstTime > AUTHORIZE_TIMEOUT)
Com_DPrintf( "authorize server timed out\n" );
else
{
@ -145,6 +129,10 @@ void SV_GetChallenge(netadr_t from)
cvar_t *fs;
char game[1024];
// If the client provided us with a client challenge, store it...
if(*clientChallenge)
challenge->clientChallenge = atoi(clientChallenge);
Com_DPrintf( "sending getIpAuthorize for %s\n", NET_AdrToString( from ));
strcpy(game, BASEGAME);
@ -165,7 +153,7 @@ void SV_GetChallenge(netadr_t from)
#endif
challenge->pingTime = svs.time;
NET_OutOfBandPrint( NS_SERVER, challenge->adr, "challengeResponse %i %d", challenge->challenge, clientChallenge);
NET_OutOfBandPrint( NS_SERVER, challenge->adr, "challengeResponse %i %s", challenge->challenge, clientChallenge);
}
#ifndef STANDALONE
@ -301,9 +289,6 @@ void SV_DirectConnect( netadr_t from ) {
intptr_t denied;
int count;
char *ip;
#ifdef PROTOCOL_SUPPORT_OLD
qboolean compat = qfalse;
#endif
Com_DPrintf ("SVC_DirectConnect ()\n");
@ -316,21 +301,11 @@ void SV_DirectConnect( netadr_t from ) {
Q_strncpyz( userinfo, Cmd_Argv(1), sizeof(userinfo) );
version = atoi(Info_ValueForKey(userinfo, "protocol"));
#ifdef PROTOCOL_SUPPORT_OLD
if(version > 0 && com_oldprotocol->integer == version)
compat = qtrue;
else
#endif
{
if(version != com_protocol->integer)
{
NET_OutOfBandPrint(NS_SERVER, from, "print\nServer uses protocol version %i "
"(yours is %i).\n", com_protocol->integer, version);
Com_DPrintf(" rejected connect from version %i\n", version);
return;
}
version = atoi( Info_ValueForKey( userinfo, "protocol" ) );
if ( version != com_protocol->integer ) {
NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i (yours is %i).\n", com_protocol->integer, version );
Com_DPrintf (" rejected connect from version %i\n", version);
return;
}
challenge = atoi( Info_ValueForKey( userinfo, "challenge" ) );
@ -512,12 +487,7 @@ gotnewcl:
newcl->challenge = challenge;
// save the address
#ifdef PROTOCOL_SUPPORT_OLD
newcl->compat = compat;
Netchan_Setup(NS_SERVER, &newcl->netchan, from, qport, challenge, compat);
#else
Netchan_Setup(NS_SERVER, &newcl->netchan, from, qport, challenge);
#endif
Netchan_Setup (NS_SERVER, &newcl->netchan , from, qport);
// init the netchan queue
newcl->netchan_end_queue = &newcl->netchan_start_queue;
@ -538,7 +508,7 @@ gotnewcl:
SV_UserinfoChanged( newcl );
// send the connect packet to the client
NET_OutOfBandPrint(NS_SERVER, from, "connectResponse %d", challenge);
NET_OutOfBandPrint( NS_SERVER, from, "connectResponse" );
Com_DPrintf( "Going from CS_FREE to CS_CONNECTED for %s\n", newcl->name );