本文整理汇总了C++中Sys_IsLANAddress函数的典型用法代码示例。如果您正苦于以下问题:C++ Sys_IsLANAddress函数的具体用法?C++ Sys_IsLANAddress怎么用?C++ Sys_IsLANAddress使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sys_IsLANAddress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CL_ReadyToSendPacket
/*
=================
CL_ReadyToSendPacket
Returns qfalse if we are over the maxpackets limit
and should choke back the bandwidth a bit by not sending
a packet this frame. All the commands will still get
delivered in the next packet, but saving a header and
getting more delta compression will reduce total bandwidth.
=================
*/
qboolean
CL_ReadyToSendPacket(void)
{
int oldPacketNum;
int delta;
// don't send anything if playing back a demo
if (clc.demoplaying || clc.state == CA_CINEMATIC)
{
return qfalse;
}
// If we are downloading, we send no less than 50ms between packets
if (*clc.downloadTempName && cls.realtime - clc.lastPacketSentTime < 50)
{
return qfalse;
}
// if we don't have a valid gamestate yet, only send
// one packet a second
if (clc.state != CA_ACTIVE &&
clc.state != CA_PRIMED &&
!*clc.downloadTempName && cls.realtime - clc.lastPacketSentTime < 1000)
{
return qfalse;
}
// send every frame for loopbacks
if (clc.netchan.remoteAddress.type == NA_LOOPBACK)
{
return qtrue;
}
// send every frame for LAN
if (cl_lanForcePackets->integer
&& Sys_IsLANAddress(clc.netchan.remoteAddress))
{
return qtrue;
}
// check for exceeding cl_maxpackets
if (cl_maxpackets->integer < 15)
{
Cvar_Set("cl_maxpackets", "15");
}
else if (cl_maxpackets->integer > 125)
{
Cvar_Set("cl_maxpackets", "125");
}
oldPacketNum = (clc.netchan.outgoingSequence - 1) & PACKET_MASK;
delta = cls.realtime - cl.outPackets[oldPacketNum].p_realtime;
if (delta < 1000 / cl_maxpackets->integer)
{
// the accumulated commands will go out in the next packet
return qfalse;
}
return qtrue;
}
示例2: SV_UserinfoChanged
/*
=================
SV_UserinfoChanged
Pull specific info from a newly changed userinfo string
into a more C friendly form.
=================
*/
void SV_UserinfoChanged( client_t *cl ) {
char *val=NULL, *ip=NULL;
int i=0, len=0;
// name for C code
Q_strncpyz( cl->name, Info_ValueForKey (cl->userinfo, "name"), sizeof(cl->name) );
// rate command
// if the client is on the same subnet as the server and we aren't running an
// internet public server, assume they don't need a rate choke
if ( Sys_IsLANAddress( cl->netchan.remoteAddress ) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1 ) {
cl->rate = 99999; // lans should not rate limit
} else {
val = Info_ValueForKey (cl->userinfo, "rate");
if (strlen(val)) {
i = atoi(val);
cl->rate = i;
if (cl->rate < 1000) {
cl->rate = 1000;
} else if (cl->rate > 90000) {
cl->rate = 90000;
}
} else {
cl->rate = 3000;
}
}
// snaps command
//Note: cl->snapshotMsec is also validated in sv_main.cpp -> SV_CheckCvars if sv_fps, sv_snapsMin or sv_snapsMax is changed
int minSnaps = Com_Clampi( 1, sv_snapsMax->integer, sv_snapsMin->integer ); // between 1 and sv_snapsMax ( 1 <-> 40 )
int maxSnaps = min( sv_fps->integer, sv_snapsMax->integer ); // can't produce more than sv_fps snapshots/sec, but can send less than sv_fps snapshots/sec
val = Info_ValueForKey( cl->userinfo, "snaps" );
cl->wishSnaps = atoi( val );
i = Com_Clampi( minSnaps, maxSnaps, cl->wishSnaps );
cl->snapshotMsec = 1000/i;
// TTimo
// maintain the IP information
// the banning code relies on this being consistently present
if( NET_IsLocalAddress(cl->netchan.remoteAddress) )
ip = "localhost";
else
ip = (char*)NET_AdrToString( cl->netchan.remoteAddress );
val = Info_ValueForKey( cl->userinfo, "ip" );
if( val[0] )
len = strlen( ip ) - strlen( val ) + strlen( cl->userinfo );
else
len = strlen( ip ) + 4 + strlen( cl->userinfo );
if( len >= MAX_INFO_STRING )
SV_DropClient( cl, "userinfo string length exceeded" );
else
Info_SetValueForKey( cl->userinfo, "ip", ip );
}
示例3: SV_GetChallenge
void SV_GetChallenge( netadr_t from )
{
if ( SV_Private(ServerPrivate::LanOnly) && !Sys_IsLANAddress(from) )
{
return;
}
auto challenge = ChallengeManager::GenerateChallenge( from );
Net::OutOfBandPrint( netsrc_t::NS_SERVER, from, "challengeResponse %s", challenge );
}
示例4: SV_GetChallenge
/*
=================
SV_GetChallenge
A "getchallenge" OOB command has been received
Returns a challenge number that can be used
in a subsequent connectResponse command.
We do this to prevent denial of service attacks that
flood the server with invalid connection IPs. With a
challenge, they must give a valid IP address.
If we are authorizing, a challenge request will cause a packet
to be sent to the authorize server.
When an authorizeip is returned, a challenge response will be
sent to that ip.
=================
*/
void SV_GetChallenge( netadr_t from ) {
int i;
int oldest;
int oldestTime;
challenge_t *challenge;
// ignore if we are in single player
/*
if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) {
return;
}
*/
if (Cvar_VariableValue("ui_singlePlayerActive"))
{
return;
}
oldest = 0;
oldestTime = 0x7fffffff;
// see if we already have a challenge for this ip
challenge = &svs.challenges[0];
for (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) {
if ( !challenge->connected && NET_CompareAdr( from, challenge->adr ) ) {
break;
}
if ( challenge->time < oldestTime ) {
oldestTime = challenge->time;
oldest = i;
}
}
if (i == MAX_CHALLENGES) {
// this is the first time this client has asked for a challenge
challenge = &svs.challenges[oldest];
challenge->challenge = ( (rand() << 16) ^ rand() ) ^ svs.time;
challenge->adr = from;
challenge->firstTime = svs.time;
challenge->time = svs.time;
challenge->connected = qfalse;
i = oldest;
}
// if they are on a lan address, send the challengeResponse immediately
if ( Sys_IsLANAddress( from ) ) {
challenge->pingTime = svs.time;
NET_OutOfBandPrint( NS_SERVER, from, "challengeResponse %i", challenge->challenge );
return;
}
}
示例5: SV_SendClientMessages
/*
=======================
SV_SendClientMessages
=======================
*/
void SV_SendClientMessages( void )
{
int i;
client_t* c;
// send a message to each connected client
for ( i = 0; i < sv_maxclients->integer; i++ )
{
c = &svs.clients[i];
if ( !c->state )
continue; // not connected
if ( *c->downloadName )
continue; // Client is downloading, don't send snapshots
if ( c->netchan.unsentFragments || c->netchan_start_queue )
{
c->rateDelayed = true;
continue; // Drop this snapshot if the packet queue is still full or delta compression will break
}
if ( !( c->netchan.remoteAddress.type == NA_LOOPBACK ||
( sv_lanForceRate->integer && Sys_IsLANAddress( c->netchan.remoteAddress ) ) ) )
{
// rate control for clients not on LAN
if ( svs.time - c->lastSnapshotTime < c->snapshotMsec * com_timescale->value )
continue; // It's not time yet
if ( SV_RateMsec( c ) > 0 )
{
// Not enough time since last packet passed through the line
c->rateDelayed = true;
continue;
}
}
// generate and send a new message
SV_SendClientSnapshot( c );
c->lastSnapshotTime = svs.time;
c->rateDelayed = false;
}
}
示例6: SV_GetChallenge
/*
=================
SV_GetChallenge
A "getchallenge" OOB command has been received
Returns a challenge number that can be used
in a subsequent connectResponse command.
We do this to prevent denial of service attacks that
flood the server with invalid connection IPs. With a
challenge, they must give a valid IP address.
If we are authorizing, a challenge request will cause a packet
to be sent to the authorize server.
When an authorizeip is returned, a challenge response will be
sent to that ip.
=================
*/
void SV_GetChallenge( netadr_t from ) {
int i;
int oldest;
int oldestTime;
challenge_t *challenge;
// ignore if we are in single player
if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) {
return;
}
oldest = 0;
oldestTime = 0x7fffffff;
// see if we already have a challenge for this ip
challenge = &svs.challenges[0];
for (i = 0 ; i < MAX_CHALLENGES ; i++, challenge++) {
if ( !challenge->connected && NET_CompareAdr( from, challenge->adr ) ) {
break;
}
if ( challenge->time < oldestTime ) {
oldestTime = challenge->time;
oldest = i;
}
}
if (i == MAX_CHALLENGES) {
// this is the first time this client has asked for a challenge
challenge = &svs.challenges[oldest];
challenge->challenge = ( (rand() << 16) ^ rand() ) ^ svs.time;
challenge->adr = from;
challenge->firstTime = svs.time;
challenge->time = svs.time;
challenge->connected = qfalse;
i = oldest;
}
// if they are on a lan address, send the challengeResponse immediately
if ( Sys_IsLANAddress( from ) ) {
challenge->pingTime = svs.time;
NET_OutOfBandPrint( NS_SERVER, from, "challengeResponse %i", challenge->challenge );
return;
}
// look up the authorize server's IP
if ( !svs.authorizeAddress.ip[0] && svs.authorizeAddress.type != NA_BAD ) {
Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME );
if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &svs.authorizeAddress ) ) {
Com_Printf( "Couldn't resolve address\n" );
return;
}
svs.authorizeAddress.port = BigShort( PORT_AUTHORIZE );
Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", AUTHORIZE_SERVER_NAME,
svs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1],
svs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3],
BigShort( svs.authorizeAddress.port ) );
}
// 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
if ( svs.time - challenge->firstTime > AUTHORIZE_TIMEOUT ) {
Com_DPrintf( "authorize server timed out\n" );
challenge->pingTime = svs.time;
NET_OutOfBandPrint( NS_SERVER, challenge->adr,
"challengeResponse %i", challenge->challenge );
return;
}
// otherwise send their ip to the authorize server
if ( svs.authorizeAddress.type != NA_BAD ) {
cvar_t *fs;
char game[1024];
Com_DPrintf( "sending getIpAuthorize for %s\n", NET_AdrToString( from ));
strcpy(game, BASEGAME);
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO );
if (fs && fs->string[0] != 0) {
strcpy(game, fs->string);
//.........这里部分代码省略.........
示例7: SV_UserinfoChanged
/*
=================
SV_UserinfoChanged
Pull specific info from a newly changed userinfo string
into a more C friendly form.
=================
*/
void SV_UserinfoChanged( client_t *cl )
{
const char *val;
int i;
// name for C code
Q_strncpyz( cl->name, Info_ValueForKey( cl->userinfo, "name" ), sizeof( cl->name ) );
// rate command
// if the client is on the same subnet as the server and we aren't running an
// Internet server, assume that they don't need a rate choke
if ( Sys_IsLANAddress( cl->netchan.remoteAddress )
&& SV_Private(ServerPrivate::LanOnly)
&& sv_lanForceRate->integer == 1 )
{
cl->rate = 99999; // lans should not rate limit
}
else
{
val = Info_ValueForKey( cl->userinfo, "rate" );
if ( strlen( val ) )
{
i = atoi( val );
cl->rate = i;
if ( cl->rate < 1000 )
{
cl->rate = 1000;
}
else if ( cl->rate > 90000 )
{
cl->rate = 90000;
}
}
else
{
cl->rate = 5000;
}
}
// snaps command
val = Info_ValueForKey( cl->userinfo, "snaps" );
if ( strlen( val ) )
{
i = atoi( val );
if ( i < 1 )
{
i = 1;
}
else if ( i > sv_fps->integer )
{
i = sv_fps->integer;
}
cl->snapshotMsec = 1000 / i;
}
else
{
cl->snapshotMsec = 50;
}
// TTimo
// maintain the IP information
// this is set in SV_DirectConnect (directly on the server, not transmitted), may be lost when client updates its userinfo
// the banning code relies on this being consistently present
// zinx - modified to always keep this consistent, instead of only
// when "ip" is 0-length, so users can't supply their own IP address
//Log::Debug("Maintain IP address in userinfo for '%s'", cl->name);
if ( !NET_IsLocalAddress( cl->netchan.remoteAddress ) )
{
Info_SetValueForKey( cl->userinfo, "ip", NET_AdrToString( cl->netchan.remoteAddress ), false );
#ifdef HAVE_GEOIP
Info_SetValueForKey( cl->userinfo, "geoip", NET_GeoIP_Country( &cl->netchan.remoteAddress ), false );
#endif
}
else
{
// force the "ip" info key to "loopback" for local clients
Info_SetValueForKey( cl->userinfo, "ip", "loopback", false );
#ifdef HAVE_GEOIP
Info_SetValueForKey( cl->userinfo, "geoip", nullptr, false );
#endif
}
}
示例8: SV_DirectConnect
/*
==================
SV_DirectConnect
A "connect" OOB command has been received
==================
*/
void SV_DirectConnect( netadr_t from ) {
char userinfo[MAX_INFO_STRING];
int i;
client_t *cl, *newcl;
MAC_STATIC client_t temp;
sharedEntity_t *ent;
int clientNum;
int version;
int qport;
int challenge;
char *password;
int startIndex;
char *denied;
int count;
char *ip;
#ifdef _XBOX
bool reconnect = false;
#endif
Com_DPrintf ("SVC_DirectConnect ()\n");
Q_strncpyz( userinfo, Cmd_Argv(1), sizeof(userinfo) );
version = atoi( Info_ValueForKey( userinfo, "protocol" ) );
if ( version != PROTOCOL_VERSION ) {
NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i.\n", PROTOCOL_VERSION );
Com_DPrintf (" rejected connect from version %i\n", version);
return;
}
challenge = atoi( Info_ValueForKey( userinfo, "challenge" ) );
qport = atoi( Info_ValueForKey( userinfo, "qport" ) );
// quick reject
for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {
/* This was preventing sv_reconnectlimit from working. It seems like commenting this
out has solved the problem. HOwever, if there is a future problem then it could
be this.
if ( cl->state == CS_FREE ) {
continue;
}
*/
if ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress )
&& ( cl->netchan.qport == qport
|| from.port == cl->netchan.remoteAddress.port ) ) {
if (( svs.time - cl->lastConnectTime)
< (sv_reconnectlimit->integer * 1000)) {
NET_OutOfBandPrint( NS_SERVER, from, "print\nReconnect rejected : too soon\n" );
Com_DPrintf ("%s:reconnect rejected : too soon\n", NET_AdrToString (from));
return;
}
break;
}
}
// don't let "ip" overflow userinfo string
if ( NET_IsLocalAddress (from) )
ip = "localhost";
else
ip = (char *)NET_AdrToString( from );
if( ( strlen( ip ) + strlen( userinfo ) + 4 ) >= MAX_INFO_STRING ) {
NET_OutOfBandPrint( NS_SERVER, from,
"print\nUserinfo string length exceeded. "
"Try removing setu cvars from your config.\n" );
return;
}
Info_SetValueForKey( userinfo, "ip", ip );
// see if the challenge is valid (LAN clients don't need to challenge)
if ( !NET_IsLocalAddress (from) ) {
int ping;
for (i=0 ; i<MAX_CHALLENGES ; i++) {
if (NET_CompareAdr(from, svs.challenges[i].adr)) {
if ( challenge == svs.challenges[i].challenge ) {
break; // good
}
}
}
if (i == MAX_CHALLENGES) {
NET_OutOfBandPrint( NS_SERVER, from, "print\nNo or bad challenge for address.\n" );
return;
}
ping = svs.time - svs.challenges[i].pingTime;
Com_Printf( SE_GetString("MP_SVGAME", "CLIENT_CONN_WITH_PING"), i, ping);//"Client %i connecting with %i challenge ping\n", i, ping );
svs.challenges[i].connected = qtrue;
// never reject a LAN client based on ping
if ( !Sys_IsLANAddress( from ) ) {
//.........这里部分代码省略.........
示例9: SV_UserinfoChanged
/*
=================
SV_UserinfoChanged
Pull specific info from a newly changed userinfo string
into a more C friendly form.
=================
*/
void SV_UserinfoChanged( client_t *cl ) {
char *val;
char *ip;
int i;
int len;
// name for C code
Q_strncpyz( cl->name, Info_ValueForKey (cl->userinfo, "name"), sizeof(cl->name) );
// rate command
// if the client is on the same subnet as the server and we aren't running an
// internet public server, assume they don't need a rate choke
if ( Sys_IsLANAddress( cl->netchan.remoteAddress ) && com_dedicated->integer != 2 ) {
cl->rate = 99999; // lans should not rate limit
} else {
val = Info_ValueForKey (cl->userinfo, "rate");
if (strlen(val)) {
i = atoi(val);
cl->rate = i;
if (cl->rate < 1000) {
cl->rate = 1000;
} else if (cl->rate > 90000) {
cl->rate = 90000;
}
} else {
cl->rate = 3000;
}
}
val = Info_ValueForKey (cl->userinfo, "handicap");
if (strlen(val)) {
i = atoi(val);
if (i<=0 || i>100 || strlen(val) > 4) {
Info_SetValueForKey( cl->userinfo, "handicap", "100" );
}
}
// snaps command
val = Info_ValueForKey (cl->userinfo, "snaps");
if (strlen(val)) {
i = atoi(val);
if ( i < 1 ) {
i = 1;
} else if ( i > 30 ) {
i = 30;
}
cl->snapshotMsec = 1000/i;
} else {
cl->snapshotMsec = 50;
}
// TTimo
// maintain the IP information
// the banning code relies on this being consistently present
if( NET_IsLocalAddress(cl->netchan.remoteAddress) )
ip = "localhost";
else
ip = (char*)NET_AdrToString( cl->netchan.remoteAddress );
val = Info_ValueForKey( cl->userinfo, "ip" );
if( val[0] )
len = strlen( ip ) - strlen( val ) + strlen( cl->userinfo );
else
len = strlen( ip ) + 4 + strlen( cl->userinfo );
if( len >= MAX_INFO_STRING )
SV_DropClient( cl, "userinfo string length exceeded" );
else
Info_SetValueForKey( cl->userinfo, "ip", ip );
}
示例10: SV_UserinfoChanged
/*
=================
SV_UserinfoChanged
Pull specific info from a newly changed userinfo string
into a more C friendly form.
=================
*/
void SV_UserinfoChanged( client_t *cl ) {
char *val;
int i;
// name for C code
Q_strncpyz( cl->name, Info_ValueForKey (cl->userinfo, "name"), sizeof(cl->name) );
// rate command
// if the client is on the same subnet as the server and we aren't running an
// internet public server, assume they don't need a rate choke
if ( Sys_IsLANAddress( cl->netchan.remoteAddress ) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1) {
cl->rate = 99999; // lans should not rate limit
} else {
val = Info_ValueForKey (cl->userinfo, "rate");
if (strlen(val)) {
i = atoi(val);
cl->rate = i;
if (cl->rate < 1000) {
cl->rate = 1000;
} else if (cl->rate > 90000) {
cl->rate = 90000;
}
} else {
cl->rate = 3000;
}
}
val = Info_ValueForKey (cl->userinfo, "handicap");
if (strlen(val)) {
i = atoi(val);
if (i<=0 || i>100 || strlen(val) > 4) {
Info_SetValueForKey( cl->userinfo, "handicap", "100" );
}
}
// snaps command
val = Info_ValueForKey (cl->userinfo, "snaps");
if (strlen(val)) {
i = atoi(val);
if ( i < 1 ) {
i = 1;
} else if ( i > sv_fps->integer ) {
i = sv_fps->integer;
}
cl->snapshotMsec = 1000/i;
} else {
cl->snapshotMsec = 50;
}
// TTimo
// maintain the IP information
// this is set in SV_DirectConnect (directly on the server, not transmitted), may be lost when client updates it's userinfo
// the banning code relies on this being consistently present
val = Info_ValueForKey (cl->userinfo, "ip");
if (!val[0])
{
//Com_DPrintf("Maintain IP in userinfo for '%s'\n", cl->name);
if ( !NET_IsLocalAddress(cl->netchan.remoteAddress) )
Info_SetValueForKey( cl->userinfo, "ip", NET_AdrToString( cl->netchan.remoteAddress ) );
else
// force the "ip" info key to "localhost" for local clients
Info_SetValueForKey( cl->userinfo, "ip", "localhost" );
}
}
示例11: SVC_RemoteCommand
/*
===============
SVC_RemoteCommand
An rcon packet arrived from the network.
Shift down the remaining args
Redirect all printfs
===============
*/
void SVC_RemoteCommand( netadr_t from, msg_t *msg ) {
qboolean valid;
unsigned int time;
char remaining[1024];
// TTimo - scaled down to accumulate, but not overflow anything network wise, print wise etc.
// (OOB messages are the bottleneck here)
#define SV_OUTPUTBUF_LENGTH (1024 - 16)
char sv_outputbuf[SV_OUTPUTBUF_LENGTH];
static unsigned int lasttime = 0;
char *cmd_aux;
// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=534
// I believe that this code (and the dead link above) are to address a brute
// force attack that guesses the rcon password.
time = Com_Milliseconds();
if ( !strlen( sv_rconPassword->string ) ||
strcmp (Cmd_Argv(1), sv_rconPassword->string) ) {
if ( (unsigned)( time - lasttime ) < 500u ) {
return;
}
valid = qfalse;
if (sv_logRconArgs->integer > 0) {
Com_Printf("Bad rcon from %s\n", NET_AdrToString(from));
}
else {
Com_Printf("Bad rcon from %s:\n%s\n", NET_AdrToString(from), Cmd_Argv(2));
}
} else {
if (!Sys_IsLANAddress(from) && (unsigned) (time - lasttime) < 100u) {
return;
}
valid = qtrue;
remaining[0] = 0;
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=543
// get the command directly, "rcon <pass> <command>" to avoid quoting issues
// extract the command by walking
// since the cmd formatting can fuckup (amount of spaces), using a dumb step by step parsing
cmd_aux = Cmd_Cmd();
cmd_aux+=4;
while(cmd_aux[0]==' ')
cmd_aux++;
while(cmd_aux[0] && cmd_aux[0]!=' ') // password
cmd_aux++;
while(cmd_aux[0]==' ')
cmd_aux++;
Q_strcat( remaining, sizeof(remaining), cmd_aux);
if (sv_logRconArgs->integer > 0) {
Com_Printf("Rcon from %s: %s\n", NET_AdrToString(from), remaining);
}
else {
Com_Printf("Rcon from %s:\n%s\n", NET_AdrToString(from), Cmd_Argv(2));
}
}
lasttime = time;
// start redirecting all print outputs to the packet
svs.redirectAddress = from;
Com_BeginRedirect (sv_outputbuf, SV_OUTPUTBUF_LENGTH, SV_FlushRedirect);
if ( !strlen( sv_rconPassword->string ) ) {
Com_Printf ("No rconpassword set on the server.\n");
} else if ( !valid ) {
Com_Printf ("Bad rconpassword.\n");
} else {
Cmd_ExecuteString (remaining);
}
Com_EndRedirect ();
}
示例12: SV_SendMessageToClient
/*
=======================
SV_SendMessageToClient
Called by SV_SendClientSnapshot and SV_SendClientGameState
=======================
*/
__cdecl void SV_SendMessageToClient( msg_t *msg, client_t *client ) {
int rateMsec;
int len;
*(int32_t*)0x13f39080 = *(int32_t*)msg->data;
len = MSG_WriteBitsCompress( 0, msg->data + 4 ,(byte*)0x13f39084 , msg->cursize - 4);
// SV_TrackHuffmanCompression(len, msg->cursize - 4);
len += 4;
if(client->delayDropMsg){
SV_DropClient(client, client->delayDropMsg);
}
if(client->demorecording && !client->demowaiting)
SV_WriteDemoMessageForClient((byte*)0x13f39080, len, client);
// record information about the message
client->frames[client->netchan.outgoingSequence & PACKET_MASK].messageSize = len;
client->frames[client->netchan.outgoingSequence & PACKET_MASK].messageSent = Sys_Milliseconds();
client->frames[client->netchan.outgoingSequence & PACKET_MASK].messageAcked = 0xFFFFFFFF;
// send the datagram
SV_Netchan_Transmit( client, (byte*)0x13f39080, len );
// set nextSnapshotTime based on rate and requested number of updates
// local clients get snapshots every frame
// TTimo - show_bug.cgi?id=491
// added sv_lanForceRate check
if(client->state == CS_ACTIVE && client->deltaMessage >= 0 && client->netchan.outgoingSequence - client->deltaMessage > 28){
client->nextSnapshotTime = svs.time + client->snapshotMsec * irand();
if(client->unknown6 +1 > 8)
{
client->unknown6 = 8;
}
}
client->unknown6 = 0;
if ( client->netchan.remoteAddress.type == NA_LOOPBACK || Sys_IsLANAddress( &client->netchan.remoteAddress )) {
client->nextSnapshotTime = svs.time - 1;
return;
}
// normal rate / snapshotMsec calculation
rateMsec = SV_RateMsec( client, msg->cursize );
// TTimo - during a download, ignore the snapshotMsec
// the update server on steroids, with this disabled and sv_fps 60, the download can reach 30 kb/s
// on a regular server, we will still top at 20 kb/s because of sv_fps 20
if ( !*client->downloadName && rateMsec < client->snapshotMsec ) {
// never send more packets than this, no matter what the rate is at
rateMsec = client->snapshotMsec;
client->rateDelayed = qfalse;
} else {
client->rateDelayed = qtrue;
}
client->nextSnapshotTime = svs.time + rateMsec;
// don't pile up empty snapshots while connecting
if ( client->state != CS_ACTIVE && !*client->downloadName) {
// a gigantic connection message may have already put the nextSnapshotTime
// more than a second away, so don't shorten it
// do shorten if client is downloading
if ( client->nextSnapshotTime < svs.time + 1000 ) {
client->nextSnapshotTime = svs.time + 1000;
}
}
sv.bpsTotalBytes += len ;
}
示例13: SV_SendMessageToClient
/*
=======================
SV_SendMessageToClient
Called by SV_SendClientSnapshot and SV_SendClientGameState
=======================
*/
void SV_SendMessageToClient( msg_t *msg, client_t *client ) {
int rateMsec;
// MW - my attempt to fix illegible server message errors caused by
// packet fragmentation of initial snapshot.
while(client->state&&client->netchan.unsentFragments)
{
// send additional message fragments if the last message
// was too large to send at once
Com_Printf ("[ISM]SV_SendClientGameState() [1] for %s, writing out old fragments\n", client->name);
SV_Netchan_TransmitNextFragment(&client->netchan);
}
// record information about the message
client->frames[client->netchan.outgoingSequence & PACKET_MASK].messageSize = msg->cursize;
client->frames[client->netchan.outgoingSequence & PACKET_MASK].messageSent = svs.time;
client->frames[client->netchan.outgoingSequence & PACKET_MASK].messageAcked = -1;
// send the datagram
SV_Netchan_Transmit( client, msg ); //msg->cursize, msg->data );
// set nextSnapshotTime based on rate and requested number of updates
// local clients get snapshots every frame
if ( client->netchan.remoteAddress.type == NA_LOOPBACK || Sys_IsLANAddress (client->netchan.remoteAddress) ) {
client->nextSnapshotTime = svs.time - 1;
return;
}
// normal rate / snapshotMsec calculation
rateMsec = SV_RateMsec( client, msg->cursize );
if ( rateMsec < client->snapshotMsec ) {
// never send more packets than this, no matter what the rate is at
rateMsec = client->snapshotMsec;
client->rateDelayed = qfalse;
} else {
client->rateDelayed = qtrue;
}
client->nextSnapshotTime = svs.time + rateMsec;
// don't pile up empty snapshots while connecting
if ( client->state != CS_ACTIVE ) {
// a gigantic connection message may have already put the nextSnapshotTime
// more than a second away, so don't shorten it
// do shorten if client is downloading
#ifdef _XBOX // No downloads on Xbox
if ( client->nextSnapshotTime < svs.time + 1000 ) {
#else
if ( !*client->downloadName && client->nextSnapshotTime < svs.time + 1000 ) {
#endif
client->nextSnapshotTime = svs.time + 1000;
}
}
}
/*
=======================
SV_SendClientSnapshot
Also called by SV_FinalMessage
=======================
*/
extern cvar_t *fs_gamedirvar;
void SV_SendClientSnapshot( client_t *client ) {
byte msg_buf[MAX_MSGLEN];
msg_t msg;
if (!client->sentGamedir)
{ //rww - if this is the case then make sure there is an svc_setgame sent before this snap
int i = 0;
MSG_Init (&msg, msg_buf, sizeof(msg_buf));
//have to include this for each message.
MSG_WriteLong( &msg, client->lastClientCommand );
MSG_WriteByte (&msg, svc_setgame);
while (fs_gamedirvar->string[i])
{
MSG_WriteByte(&msg, fs_gamedirvar->string[i]);
i++;
}
MSG_WriteByte(&msg, 0);
// MW - my attempt to fix illegible server message errors caused by
// packet fragmentation of initial snapshot.
//rww - reusing this code here
while(client->state&&client->netchan.unsentFragments)
//.........这里部分代码省略.........
示例14: SV_UserinfoChanged
/*
=================
SV_UserinfoChanged
Pull specific info from a newly changed userinfo string
into a more C friendly form.
=================
*/
void SV_UserinfoChanged( client_t *cl ) {
const char *ip;
char *val;
int i;
// name for C code
Q_strncpyz( cl->name, Info_ValueForKey (cl->userinfo, "name"), sizeof(cl->name) );
// rate command
// if the client is on the same subnet as the server and we aren't running an
// internet public server, assume they don't need a rate choke
if ( Sys_IsLANAddress( cl->netchan.remoteAddress ) && com_dedicated->integer != 2 ) {
cl->rate = 99999; // lans should not rate limit
} else {
val = Info_ValueForKey (cl->userinfo, "rate");
if (strlen(val)) {
i = atoi(val);
cl->rate = i;
if (cl->rate < 1000) {
cl->rate = 1000;
} else if (cl->rate > 90000) {
cl->rate = 90000;
}
} else {
cl->rate = 3000;
}
}
val = Info_ValueForKey (cl->userinfo, "handicap");
if (strlen(val)) {
i = atoi(val);
if (i<=0 || i>100 || strlen(val) > 4) {
Info_SetValueForKey( cl->userinfo, "handicap", "100" );
}
}
// snaps command
val = Info_ValueForKey (cl->userinfo, "snaps");
if (strlen(val)) {
i = atoi(val);
if ( i < 1 ) {
i = 1;
} else if ( i > 30 ) {
i = 30;
}
cl->snapshotMsec = 1000/i;
} else {
cl->snapshotMsec = 50;
}
if (mv_fixnamecrash->integer && !(sv.fixes & MVFIX_NAMECRASH)) {
char name[61], cleanedName[61]; // 60 because some mods increased this
Q_strncpyz(name, Info_ValueForKey(cl->userinfo, "name"), sizeof(name));
int count = 0;
for (int i = 0; i < (int)strlen(name); i++) {
char ch = name[i];
if (isascii(ch) ||
ch == '\x0A' || // underscore cursor (console only)
ch == '\x0B' || // block cursor (console only)
ch == '\xB7' || // section sign (§)
ch == '\xB4' || // accute accent (´)
ch == '\xC4' || // A umlaut (Ä)
ch == '\xD6' || // O umlaut (Ö)
ch == '\xDC' || // U umlaut (Ü)
ch == '\xDF' || // sharp S (ß)
ch == '\xE4' || // a umlaut (ä)
ch == '\xF6' || // o umlaut (ö)
ch == '\xFC') // u umlaut (ü)
{
cleanedName[count++] = ch;
}
}
cleanedName[count] = 0;
Info_SetValueForKey(cl->userinfo, "name", cleanedName);
}
// forcecrash fix
if (mv_fixforcecrash->integer && !(sv.fixes & MVFIX_FORCECRASH)) {
char forcePowers[30];
Q_strncpyz(forcePowers, Info_ValueForKey(cl->userinfo, "forcepowers"), sizeof(forcePowers));
int len = (int)strlen(forcePowers);
bool badForce = false;
if (len >= 22 && len <= 24) {
byte seps = 0;
for (int i = 0; i < len; i++) {
if (forcePowers[i] != '-' && (forcePowers[i] < '0' || forcePowers[i] > '9')) {
badForce = true;
//.........这里部分代码省略.........
示例15: SV_GetChallenge
//.........这里部分代码省略.........
// 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;
break;
}
if ( challenge->time < oldestTime )
{
oldestTime = challenge->time;
oldest = i;
}
}
if (i == MAX_CHALLENGES)
{
// this is the first time this client has asked for a challenge
challenge = &svs.challenges[oldest];
challenge->clientChallenge = clientChallenge;
challenge->adr = from;
challenge->firstTime = 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;
#if !defined(STANDALONE) && defined (USE_AUTHORIZE)
// Drop the authorize stuff if this client is coming in via v6 as the auth server does not support ipv6.
// Drop also for addresses coming in on local LAN and for stand-alone games independent from id's assets.
if(challenge->adr.type == NA_IP && !Cvar_VariableIntegerValue("com_standalone") && !Sys_IsLANAddress(from))
{
// look up the authorize server's IP
if (svs.authorizeAddress.type == NA_BAD)
{
Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME );
if (NET_StringToAdr(AUTHORIZE_SERVER_NAME, &svs.authorizeAddress, NA_IP))
{
svs.authorizeAddress.port = BigShort( PORT_AUTHORIZE );
Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", AUTHORIZE_SERVER_NAME,
svs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1],
svs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3],
BigShort( svs.authorizeAddress.port ) );
}
}
// we couldn't contact the auth server, let them in.
if(svs.authorizeAddress.type == NA_BAD)
Com_Printf("Couldn't resolve auth server address\n");
// 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)
Com_DPrintf( "authorize server timed out\n" );
else
{
// otherwise send their ip to the authorize server
cvar_t *fs;
char game[1024];
Com_DPrintf( "sending getIpAuthorize for %s\n", NET_AdrToString( from ));
strcpy(game, IDBASEGAME);
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO );
if (fs && fs->string[0] != 0) {
strcpy(game, fs->string);
}
// the 0 is for backwards compatibility with obsolete sv_allowanonymous flags
// getIpAuthorize <challenge> <IP> <game> 0 <auth-flag>
NET_OutOfBandPrint( NS_SERVER, svs.authorizeAddress,
"getIpAuthorize %i %i.%i.%i.%i %s 0 %s", challenge->challenge,
from.ip[0], from.ip[1], from.ip[2], from.ip[3], game, sv_strictAuth->string );
return;
}
}
#endif
challenge->pingTime = svs.time;
NET_OutOfBandPrint(NS_SERVER, challenge->adr, "challengeResponse %d %d",
challenge->challenge, clientChallenge);
}