summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/cmodel.c3
-rw-r--r--source/cmodel.h2
-rw-r--r--source/mvd_client.c2
-rw-r--r--source/net_common.c10
-rw-r--r--source/sv_ccmds.c14
-rw-r--r--source/sv_init.c2
-rw-r--r--source/sv_local.h1
-rw-r--r--source/sv_main.c47
-rw-r--r--source/sv_public.h1
-rw-r--r--wiki/doc/server.mdwn5
10 files changed, 64 insertions, 23 deletions
diff --git a/source/cmodel.c b/source/cmodel.c
index dc63861..c2e8872 100644
--- a/source/cmodel.c
+++ b/source/cmodel.c
@@ -846,8 +846,7 @@ void CM_TransformedBoxTrace ( trace_t *trace, vec3_t start, vec3_t end,
trace->endpos[2] = start[2] + trace->fraction * (end[2] - start[2]);
}
-
-void CM_ClipEntity( trace_t *dst, trace_t *src, struct edict_s *ent ) {
+void CM_ClipEntity( trace_t *dst, const trace_t *src, struct edict_s *ent ) {
dst->allsolid |= src->allsolid;
dst->startsolid |= src->startsolid;
if( src->fraction < dst->fraction ) {
diff --git a/source/cmodel.h b/source/cmodel.h
index d835c95..c1523a7 100644
--- a/source/cmodel.h
+++ b/source/cmodel.h
@@ -59,7 +59,7 @@ void CM_TransformedBoxTrace( trace_t *trace, vec3_t start, vec3_t end,
vec3_t mins, vec3_t maxs,
mnode_t * headnode, int brushmask,
vec3_t origin, vec3_t angles );
-void CM_ClipEntity( trace_t *dst, trace_t *src, struct edict_s *ent );
+void CM_ClipEntity( trace_t *dst, const trace_t *src, struct edict_s *ent );
// call with topnode set to the headnode, returns with topnode
// set to the first node that splits the box
diff --git a/source/mvd_client.c b/source/mvd_client.c
index efb8ec0..7089a29 100644
--- a/source/mvd_client.c
+++ b/source/mvd_client.c
@@ -838,6 +838,8 @@ void MVD_Spawn_f( void ) {
Cvar_Set( "sv_paused", "0" );
Cvar_Set( "timedemo", "0" );
+ SV_SetConsoleTitle();
+
sv.spawncount = ( rand() | ( rand() << 16 ) ) ^ Sys_Milliseconds();
sv.spawncount &= 0x7FFFFFFF;
diff --git a/source/net_common.c b/source/net_common.c
index 0bbb94f..3db96f8 100644
--- a/source/net_common.c
+++ b/source/net_common.c
@@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "net_sock.h"
#include "net_stream.h"
#include "sys_public.h"
+#include "sv_public.h"
#if defined( _WIN32 )
#define WIN32_LEAN_AND_MEAN
@@ -1155,6 +1156,8 @@ static void NET_Restart_f( void ) {
if( sock != INVALID_SOCKET ) {
NET_Listen( qtrue );
}
+
+ SV_SetConsoleTitle();
}
/*
@@ -1224,6 +1227,10 @@ static size_t NET_DnRate_m( char *buffer, size_t size ) {
return Com_sprintf( buffer, size, "%"PRIz, net_rate_dn );
}
+static void net_param_changed( cvar_t *self ) {
+ NET_Restart_f();
+}
+
/*
====================
NET_Init
@@ -1243,8 +1250,11 @@ void NET_Init( void ) {
#endif
net_ip = Cvar_Get( "net_ip", "localhost", 0 );
+ net_ip->changed = net_param_changed;
net_port = Cvar_Get( "net_port", va( "%i", PORT_SERVER ), 0 );
+ net_port->changed = net_param_changed;
net_clientport = Cvar_Get( "net_clientport", va( "%i", PORT_ANY ), 0 );
+ net_clientport->changed = net_param_changed;
net_dropsim = Cvar_Get( "net_dropsim", "0", 0 );
net_log_active = Cvar_Get( "net_log_active", "0", 0 );
net_log_active->changed = net_log_active_changed;
diff --git a/source/sv_ccmds.c b/source/sv_ccmds.c
index a388e16..530a1e5 100644
--- a/source/sv_ccmds.c
+++ b/source/sv_ccmds.c
@@ -699,6 +699,7 @@ void SV_AddMatch_f( list_t *list ) {
char *s;
addrmatch_t *match;
uint32_t addr, mask;
+ size_t len;
if( Cmd_Argc() < 2 ) {
Com_Printf( "Usage: %s <address/mask>\n", Cmd_Argv( 0 ) );
@@ -719,9 +720,12 @@ void SV_AddMatch_f( list_t *list ) {
}
#endif
- match = Z_Malloc( sizeof( *match ) );
+ s = Cmd_ArgsFrom( 2 );
+ len = strlen( s );
+ match = Z_Malloc( sizeof( *match ) + len );
match->addr = addr;
match->mask = mask;
+ memcpy( match->comment, s, len + 1 );
List_Append( list, &match->entry );
}
@@ -787,6 +791,7 @@ remove:
void SV_ListMatches_f( list_t *list ) {
addrmatch_t *match;
+ char addr[32];
byte ip[4];
int i, count;
@@ -795,6 +800,8 @@ void SV_ListMatches_f( list_t *list ) {
return;
}
+ Com_Printf( "id address/mask comment\n"
+ "-- ------------------ -------\n" );
count = 1;
LIST_FOR_EACH( addrmatch_t, match, list, entry ) {
*( uint32_t * )ip = match->addr;
@@ -803,8 +810,9 @@ void SV_ListMatches_f( list_t *list ) {
break;
}
}
- Com_Printf( "(%d) %d.%d.%d.%d/%d\n",
- count, ip[0], ip[1], ip[2], ip[3], i );
+ Com_sprintf( addr, sizeof( addr ), "%d.%d.%d.%d/%d",
+ ip[0], ip[1], ip[2], ip[3], i );
+ Com_Printf( "%-2d %-18s %s\n", count, addr, match->comment );
count++;
}
}
diff --git a/source/sv_init.c b/source/sv_init.c
index 11f1780..642a09f 100644
--- a/source/sv_init.c
+++ b/source/sv_init.c
@@ -131,6 +131,8 @@ static void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint
Cvar_Set( "sv_paused", "0" );
Cvar_Set( "timedemo", "0" );
+ SV_SetConsoleTitle();
+
Com_Printf ("-------------------------------------\n");
}
diff --git a/source/sv_local.h b/source/sv_local.h
index 26b3ba8..1211546 100644
--- a/source/sv_local.h
+++ b/source/sv_local.h
@@ -325,6 +325,7 @@ typedef struct {
list_t entry;
uint32_t addr;
uint32_t mask;
+ char comment[1];
} addrmatch_t;
typedef struct {
diff --git a/source/sv_main.c b/source/sv_main.c
index 08b1bae..fc58040 100644
--- a/source/sv_main.c
+++ b/source/sv_main.c
@@ -534,12 +534,7 @@ static void SVC_DirectConnect( void ) {
}
if( !NET_IsLocalAddress( &net_from ) ) {
- // check for banned address
- if( SV_MatchAddress( &sv_banlist, &net_from ) ) {
- SV_OobPrintf( "Your IP address is banned.\n" );
- Com_DPrintf( " rejected connect from banned IP\n" );
- return;
- }
+ addrmatch_t *match;
// see if the challenge is valid
for( i = 0; i < MAX_CHALLENGES; i++ ) {
@@ -561,6 +556,17 @@ static void SVC_DirectConnect( void ) {
}
svs.challenges[i].challenge = 0;
+ // check for banned address
+ if( ( match = SV_MatchAddress( &sv_banlist, &net_from ) ) != NULL ) {
+ s = match->comment;
+ if( !*s ) {
+ s = "Your IP address is banned from this server.";
+ }
+ SV_OobPrintf( "%s\nConnection refused.\n", s );
+ Com_DPrintf( " rejected connect from banned IP\n" );
+ return;
+ }
+
if( sv_locked->integer ) {
SV_OobPrintf( "Server is locked.\n" );
Com_DPrintf( " rejected - server is locked.\n" );
@@ -1160,9 +1166,12 @@ static void SV_PacketEvent( neterr_t ret ) {
continue; // already a zombie
}
netchan = client->netchan;
- if( !NET_IsEqualAdr( &net_from, &netchan->remote_address ) ) {
+ if( !NET_IsEqualBaseAdr( &net_from, &netchan->remote_address ) ) {
continue;
}
+ if( net_from.port && netchan->remote_address.port != net_from.port ) {
+ continue;
+ }
client->flags |= CF_ERROR; // drop them soon
break;
}
@@ -1710,6 +1719,16 @@ void SV_UserinfoChanged( client_t *cl ) {
//============================================================================
+void SV_SetConsoleTitle( void ) {
+ char buffer[MAX_STRING_CHARS];
+
+ Com_sprintf( buffer, sizeof( buffer ), "%s (port %d%s)",
+ sv_hostname->string, net_port->integer,
+ sv_running->integer ? "" : ", down" );
+
+ Sys_SetConsoleTitle( buffer );
+}
+
static void sv_status_limit_changed( cvar_t *self ) {
SV_RateInit( &svs.ratelimit_status, self->integer, 1000 );
}
@@ -1720,12 +1739,7 @@ static void sv_badauth_time_changed( cvar_t *self ) {
}
static void sv_hostname_changed( cvar_t *self ) {
- char buffer[MAX_STRING_CHARS];
-
- Com_sprintf( buffer, sizeof( buffer ), "%s (port %d)",
- sv_hostname->string, net_port->integer );
-
- Sys_SetConsoleTitle( buffer );
+ SV_SetConsoleTitle();
}
/*
@@ -1757,7 +1771,6 @@ void SV_Init( void ) {
sv_reserved_slots = Cvar_Get( "sv_reserved_slots", "0", CVAR_LATCH );
sv_hostname = Cvar_Get( "hostname", "noname", CVAR_SERVERINFO|CVAR_ARCHIVE );
sv_hostname->changed = sv_hostname_changed;
- sv_hostname->changed( sv_hostname );
sv_timeout = Cvar_Get( "timeout", "90", 0 );
sv_zombietime = Cvar_Get( "zombietime", "2", 0 );
sv_ghostime = Cvar_Get( "sv_ghostime", "6", 0 );
@@ -1821,6 +1834,8 @@ void SV_Init( void ) {
sv_pmp.flyfriction = 9;
sv_pmp.waterfriction = 1;
sv_pmp.speedMultiplier = 1;
+
+ SV_SetConsoleTitle();
}
/*
@@ -1907,7 +1922,7 @@ before Sys_Quit or Sys_Error
void SV_Shutdown( const char *finalmsg, killtype_t type ) {
Cvar_Set( "sv_running", "0" );
Cvar_Set( "sv_paused", "0" );
-
+
if( !svs.initialized ) {
MVD_Shutdown(); // make sure MVD client is down
return;
@@ -1944,6 +1959,8 @@ void SV_Shutdown( const char *finalmsg, killtype_t type ) {
sv_client = NULL;
sv_player = NULL;
+ SV_SetConsoleTitle();
+
Z_LeakTest( TAG_SERVER );
}
diff --git a/source/sv_public.h b/source/sv_public.h
index 06a7c74..54e860a 100644
--- a/source/sv_public.h
+++ b/source/sv_public.h
@@ -35,5 +35,6 @@ void SV_ProcessEvents( void );
void SV_Init (void);
void SV_Shutdown( const char *finalmsg, killtype_t type );
void SV_Frame (int msec);
+void SV_SetConsoleTitle( void );
qboolean MVD_GetDemoPercent( int *percent, int *bufferPercent );
diff --git a/wiki/doc/server.mdwn b/wiki/doc/server.mdwn
index daa4b63..cd459bd 100644
--- a/wiki/doc/server.mdwn
+++ b/wiki/doc/server.mdwn
@@ -181,8 +181,9 @@ must be reachable. See `passive` [[client#index3h1]] command for more details.
Dumps entity lump of the current map into `maps/<entname>.ent`, which you can later
edit and use as `map_override` file (see above).
-- `addban <address[/mask]>`
-Adds specified address to the ban list. Specify _mask_ to ban the whole network.
+- `addban <address[/mask]> [comment ...]`
+Adds specified address to the ban list. Specify _mask_ to ban entire subnetwork.
+If specified, _comment_ will be printed to banned user(s) when they attempt to connect.
- `delban <address[/mask]|id|all>`
Deletes single matching address from the ban list. You can also specify