diff options
author | M. Kristall <mkpdev@gmail.com> | 2009-10-03 11:54:36 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:30 +0000 |
commit | 45b4d03e66058565129e4de53a719433a50cf4e6 (patch) | |
tree | 452069eb90987e3a95009b399b91b338905010e5 | |
parent | 7145527a1ca44c6afd20adf7e369f5f6f983047b (diff) |
* (bug 3719) IP address fields in admin system are not large enough for IPv6
(Amanieu)
* Prevent the host player on a non-dedicated server from being disconnected
-rw-r--r-- | src/game/g_admin.c | 20 | ||||
-rw-r--r-- | src/game/g_admin.h | 4 | ||||
-rw-r--r-- | src/game/g_client.c | 31 | ||||
-rw-r--r-- | src/game/g_cmds.c | 13 | ||||
-rw-r--r-- | src/game/g_local.h | 2 |
5 files changed, 37 insertions, 33 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index b3f1ace2..36a873b2 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -1597,13 +1597,18 @@ qboolean G_admin_kick( gentity_t *ent, int skiparg ) ADMP( va( "^3!kick: ^7%s\n", err ) ); return qfalse; } - if( !admin_higher( ent, &g_entities[ pids[ 0 ] ] ) ) + vic = &g_entities[ pids[ 0 ] ]; + if( !admin_higher( ent, vic ) ) { ADMP( "^3!kick: ^7sorry, but your intended victim has a higher admin" " level than you\n" ); return qfalse; } - vic = &g_entities[ pids[ 0 ] ]; + if( vic->client->pers.localClient ) + { + ADMP( "^3!kick: ^7disconnecting the host would end the game\n" ); + return qfalse; + } if( g_adminTempBan.integer > 0 ) { admin_create_ban( ent, @@ -1785,9 +1790,6 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) return qfalse; } - G_admin_duration( ( seconds ) ? seconds : -1, - duration, sizeof( duration ) ); - if( ent && !admin_higher_guid( ent->client->pers.guid, g_admin_namelog[ logmatch ]->guid ) ) { @@ -1796,6 +1798,14 @@ qboolean G_admin_ban( gentity_t *ent, int skiparg ) " level than you\n" ); return qfalse; } + if( !strcmp( g_admin_namelog[ logmatch ]->ip, "localhost" ) ) + { + ADMP( "^3!ban: ^7disconnecting the host would end the game\n" ); + return qfalse; + } + + G_admin_duration( ( seconds ) ? seconds : -1, + duration, sizeof( duration ) ); admin_create_ban( ent, g_admin_namelog[ logmatch ]->name[ 0 ], diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 5760f521..87475b02 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -106,7 +106,7 @@ typedef struct g_admin_ban { char name[ MAX_NAME_LENGTH ]; char guid[ 33 ]; - char ip[ 18 ]; + char ip[ 40 ]; char reason[ MAX_ADMIN_BAN_REASON ]; char made[ 18 ]; // big enough for strftime() %c int expires; @@ -126,7 +126,7 @@ g_admin_command_t; typedef struct g_admin_namelog { char name[ MAX_ADMIN_NAMELOG_NAMES ][MAX_NAME_LENGTH ]; - char ip[ 16 ]; + char ip[ 40 ]; char guid[ 33 ]; int slot; qboolean banned; diff --git a/src/game/g_client.c b/src/game/g_client.c index a472daae..731cedc6 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -979,12 +979,6 @@ void ClientUserinfoChanged( int clientNum ) if( !Info_Validate(userinfo) ) strcpy( userinfo, "\\name\\badinfo" ); - // check for local client - s = Info_ValueForKey( userinfo, "ip" ); - - if( !strcmp( s, "localhost" ) ) - client->pers.localClient = qtrue; - // stickyspec toggle s = Info_ValueForKey( userinfo, "cg_stickySpec" ); client->pers.stickySpec = atoi( s ) != 0; @@ -1171,11 +1165,12 @@ char *ClientConnect( int clientNum, qboolean firstTime ) char userinfo[ MAX_INFO_STRING ]; gentity_t *ent; char guid[ 33 ]; - char ip[ 16 ] = {""}; char reason[ MAX_STRING_CHARS ] = {""}; - int i; ent = &g_entities[ clientNum ]; + client = &level.clients[ clientNum ]; + ent->client = client; + memset( client, 0, sizeof( *client ) ); trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) ); @@ -1194,15 +1189,7 @@ char *ClientConnect( int clientNum, qboolean firstTime ) // recommanding PB based IP / GUID banning, the builtin system is pretty limited // check to see if they are on the banned IP list value = Info_ValueForKey( userinfo, "ip" ); - i = 0; - while( *value && i < sizeof( ip ) - 2 ) - { - if( *value != '.' && ( *value < '0' || *value > '9' ) ) - break; - ip[ i++ ] = *value; - value++; - } - ip[ i ] = '\0'; + Q_strncpyz( client->pers.ip, value, sizeof( client->pers.ip ) ); if( G_FilterPacket( value ) ) return "You are banned from this server."; @@ -1213,12 +1200,6 @@ char *ClientConnect( int clientNum, qboolean firstTime ) strcmp( g_password.string, value ) != 0 ) return "Invalid password"; - // they can connect - ent->client = level.clients + clientNum; - client = ent->client; - - memset( client, 0, sizeof(*client) ); - // add guid to session so we don't have to keep parsing userinfo everywhere if( !guid[0] ) { @@ -1229,7 +1210,9 @@ char *ClientConnect( int clientNum, qboolean firstTime ) { Q_strncpyz( client->pers.guid, guid, sizeof( client->pers.guid ) ); } - Q_strncpyz( client->pers.ip, ip, sizeof( client->pers.ip ) ); + // check for local client + if( !strcmp( client->pers.ip, "localhost" ) ) + client->pers.localClient = qtrue; client->pers.adminLevel = G_admin_level( ent ); client->pers.connected = CON_CONNECTING; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index efcf4938..bd819988 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1176,6 +1176,12 @@ void Cmd_CallVote_f( gentity_t *ent ) "print \"callvote: admin is immune from vote kick\n\"" ); return; } + if( level.clients[ clientNum ].pers.localClient ) + { + trap_SendServerCommand( ent-g_entities, + "print \"callvote: host is immute from vote kick\n\"" ); + return; + } // use ip in case this player disconnects before the vote ends Com_sprintf( level.voteString, sizeof( level.voteString ), @@ -1415,7 +1421,12 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) "print \"callteamvote: admin is immune from vote kick\n\"" ); return; } - + if( level.clients[ clientNum ].pers.localClient ) + { + trap_SendServerCommand( ent-g_entities, + "print \"callteamvote: host is immune from vote kick\n\"" ); + return; + } // use ip in case this player disconnects before the vote ends Com_sprintf( level.teamVoteString[ cs_offset ], diff --git a/src/game/g_local.h b/src/game/g_local.h index caa7ff5f..764892ab 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -329,7 +329,7 @@ typedef struct vec3_t lastDeathLocation; char guid[ 33 ]; - char ip[ 16 ]; + char ip[ 40 ]; qboolean muted; qboolean denyBuild; int adminLevel; |