本文整理汇总了C++中NET_CompareBaseAdr函数的典型用法代码示例。如果您正苦于以下问题:C++ NET_CompareBaseAdr函数的具体用法?C++ NET_CompareBaseAdr怎么用?C++ NET_CompareBaseAdr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NET_CompareBaseAdr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SV_NocPacket
void SV_NocPacket(netadr_t from, msg_t *msg) { //Not connected packet (Server is not running)
char* s;
char* c;
if(msg->cursize >= 4) {
if(*(int*)msg->data == -1) {
#if 1
int CSteamServer_HandleIncomingPacket(const void* pData, int cbData, unsigned int srcIP, unsigned short srcPort);
if(!CSteamServer_HandleIncomingPacket((const void*)msg->data, msg->cursize, from._ip, from.port));
#endif
} else if(*(int*)msg->data == -2) {
MSG_BeginReading(msg);
MSG_ReadLong(msg);
s = MSG_ReadStringLine(msg);
Cmd_TokenizeString(s);
c = Cmd_Argv(0);
if(!Q_stricmp(c, "serverversionresponse")) {
if(!NET_CompareBaseAdr(from, x_master))
return;
} else if(!Q_stricmp(c, "clientversionresponse")) {
if(!NET_CompareBaseAdr(from, x_master))
return;
clientversion = atoi( Cmd_Argv(1) );
}
}
}
}
开发者ID:EndlessClan,项目名称:CoDExtended,代码行数:30,代码来源:sv_main.c
示例2: cGetChallenge
/*
=================
cGetChallenge
Returns a challenge number that can be used
in a subsequent client_connect 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.
=================
*/
static void cGetChallenge(int argc, char **argv)
{
int i;
int oldest = 0;
int oldestTime = 0x7FFFFFFF;
// see if we already have a challenge for this ip
for (i = 0; i < MAX_CHALLENGES; i++)
{
if (NET_CompareBaseAdr(&net_from, &svs.challenges[i].adr))
break;
if (svs.challenges[i].time < oldestTime)
{
oldestTime = svs.challenges[i].time;
oldest = i;
}
}
if (i == MAX_CHALLENGES)
{
// overwrite the oldest
svs.challenges[oldest].challenge = rand() & 0x7FFF;
svs.challenges[oldest].adr = net_from;
svs.challenges[oldest].time = appMilliseconds();
i = oldest;
}
// send it back
Netchan_OutOfBandPrint(NS_SERVER, net_from, "challenge %d", svs.challenges[i].challenge);
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:42,代码来源:sv_main.cpp
示例3: SV_ConnectionlessPacket
/*
=================
SV_ConnectionlessPacket
A connectionless packet has four leading 0xff
characters to distinguish it from a game channel.
Clients that are in the game can still send
connectionless packets.
=================
*/
void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
char *s;
char *c;
#ifdef USE_AUTH
netadr_t authServerIP;
#endif
MSG_BeginReadingOOB( msg );
MSG_ReadLong( msg ); // skip the -1 marker
if (!Q_strncmp("connect", (char *) &msg->data[4], 7)) {
Huff_Decompress(msg, 12);
}
s = MSG_ReadStringLine( msg );
Cmd_TokenizeString( s );
c = Cmd_Argv(0);
Com_DPrintf ("SV packet %s : %s\n", NET_AdrToString(from), c);
if (!Q_stricmp(c, "getstatus")) {
if (SV_CheckDRDoS(from)) { return; }
SVC_Status( from );
} else if (!Q_stricmp(c, "getinfo")) {
if (SV_CheckDRDoS(from)) { return; }
SVC_Info( from );
} else if (!Q_stricmp(c, "getchallenge")) {
SV_GetChallenge( from );
} else if (!Q_stricmp(c, "connect")) {
SV_DirectConnect( from );
} else if (!Q_stricmp(c, "ipAuthorize")) {
SV_AuthorizeIpPacket( from );
}
#ifdef USE_AUTH
// @Barbatos @Kalish
else if ( (!Q_stricmp(c, "AUTH:SV")))
{
NET_StringToAdr(sv_authServerIP->string, &authServerIP);
if ( !NET_CompareBaseAdr( from, authServerIP ) ) {
Com_Printf( "AUTH not from the Auth Server\n" );
return;
}
VM_Call(gvm, GAME_AUTHSERVER_PACKET);
}
#endif
else if (!Q_stricmp(c, "rcon")) {
SVC_RemoteCommand( from, msg );
}else if (!Q_stricmp(c, "rconRecovery")) {
SVC_RconRecoveryRemoteCommand( from, msg );
} else if (!Q_stricmp(c, "disconnect")) {
// if a client starts up a local server, we may see some spurious
// server disconnect messages when their new server sees our final
// sequenced messages to the old client
} else {
Com_DPrintf ("bad connectionless packet from %s:\n%s\n"
, NET_AdrToString (from), s);
}
}
开发者ID:Barbatos,项目名称:ioq3-for-UrbanTerror-4,代码行数:70,代码来源:sv_main.c
示例4: NET_CompareAdr
qboolean NET_CompareAdr(netadr_t a, netadr_t b)
{
if (!NET_CompareBaseAdr(a, b))
{
return qfalse;
}
if (a.type == NA_IP
#ifdef FEATURE_IPV6
|| a.type == NA_IP6
#endif
)
{
if (a.port == b.port)
{
return qtrue;
}
}
else
{
return qtrue;
}
return qfalse;
}
开发者ID:Ododo,项目名称:etlegacy,代码行数:25,代码来源:net_ip.c
示例5: SV_BanIP_f
void SV_BanIP_f() {
if(Cmd_Argc()!=2) {
Com_Printf("Usage: banip <ip>\n");
return;
}
char* ip = Cmd_Argv(1);
netadr_t adr;
NET_StringToAdr(ip, &adr);
client_t* cl;
for(int i = 0; i < sv_maxclients->integer; i++) {
cl=getclient(i);
if(!cl->state) continue;
if(NET_CompareBaseAdr(adr, cl->remoteAddress)) {
SV_DropClient(cl, "banned");
break;
}
}
FILE* f = fopen("ipbans.txt", "a");
if(f) {
fprintf(f,"%s\n",ip);
fclose(f);
}
Com_Printf("IP '%s' has been banned.\n", ip);
X_ReadBannedList(false);
}
开发者ID:AnasBunny,项目名称:CoDExtended,代码行数:32,代码来源:sv_commands.c
示例6: SV_PlayerBannedByip
char* SV_PlayerBannedByip(netadr_t *netadr){ //Gets called in SV_DirectConnect
ipBanList_t *this;
int i;
for(this = &ipBans[0], i = 0; i < 1024; this++, i++){
if(NET_CompareBaseAdr(netadr, &this->remote)){
if(Com_GetRealtime() < this->timeout)
{
if(this->expire == -1){
return va("\nEnforcing prior ban\nPermanent ban issued onto this gameserver\nYou will be never allowed to join this gameserver again\n Your UID is: %i Banning admin UID is: %i\nReason for this ban:\n%s\n",
this->uid,this->adminuid,this->banmsg);
}else{
int remaining = (int)(this->expire - Com_GetRealtime()) +1; //in seconds (+1 for fixing up a display error when only some seconds are remaining)
int d = remaining/(60*60*24);
remaining = remaining%(60*60*24);
int h = remaining/(60*60);
remaining = remaining%(60*60);
int m = remaining/60;
return va("\nEnforcing prior kick/ban\nTemporary ban issued onto this gameserver\nYou are not allowed to rejoin this gameserver for another\n %i days %i hours %i minutes\n Your UID is: %i Banning admin UID is: %i\nReason for this ban:\n%s\n",
d,h,m,this->uid,this->adminuid,this->banmsg);
}
}
}
}
return NULL;
}
开发者ID:JustInToCoding,项目名称:CoD4X17a_testing,代码行数:34,代码来源:sv_banlist.c
示例7: SVC_GetChallenge
/*
=================
SVC_GetChallenge
Returns a challenge number that can be used
in a subsequent client_connect 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.
=================
*/
void SVC_GetChallenge (void)
{
int i;
int oldest;
int oldestTime;
oldest = 0;
oldestTime = 0x7fffffff;
// see if we already have a challenge for this ip
for (i = 0 ; i < MAX_CHALLENGES ; i++)
{
if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr))
break;
if (svs.challenges[i].time < oldestTime)
{
oldestTime = svs.challenges[i].time;
oldest = i;
}
}
if (i == MAX_CHALLENGES)
{
// overwrite the oldest
svs.challenges[oldest].challenge = (rand() << 16) ^ rand();
svs.challenges[oldest].adr = net_from;
svs.challenges[oldest].time = svs.realtime;
i = oldest;
}
// send it back
Netchan_OutOfBandPrint (NS_SERVER, net_from, "%c%i", S2C_CHALLENGE,
svs.challenges[i].challenge);
}
开发者ID:matatk,项目名称:agrip,代码行数:45,代码来源:sv_main.c
示例8: SVC_GetChallenge
/*
* ================= SVC_GetChallenge
*
* Returns a challenge number that can be used in a subsequent client_connect
* 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. =================
*/
void
SVC_GetChallenge(void)
{
int i;
int oldest;
int oldestTime;
oldest = 0;
oldestTime = 0x7fffffff;
/* see if we already have a challenge for this ip */
for (i = 0; i < MAX_CHALLENGES; i++) {
if (NET_CompareBaseAdr(net_from, svs.challenges[i].adr))
break;
if (svs.challenges[i].time < oldestTime) {
oldestTime = svs.challenges[i].time;
oldest = i;
}
}
if (i == MAX_CHALLENGES) {
/* overwrite the oldest */
svs.challenges[oldest].challenge = rand() & 0x7fff;
svs.challenges[oldest].adr = net_from;
svs.challenges[oldest].time = curtime;
i = oldest;
}
/* send it back */
Netchan_OutOfBandPrint(NS_SERVER, net_from, "challenge %i", svs.challenges[i].challenge);
}
开发者ID:ZwS,项目名称:qudos,代码行数:38,代码来源:sv_main.c
示例9: SV_PacketEvent
/*
=================
SV_ReadPackets
=================
*/
void SV_PacketEvent( netadr_t from, msg_t *msg ) {
int i;
client_t *cl;
int qport;
// check for connectionless packet (0xffffffff) first
if ( msg->cursize >= 4 && *(int *)msg->data == -1) {
SV_ConnectionlessPacket( from, msg );
return;
}
// read the qport out of the message so we can fix up
// stupid address translating routers
MSG_BeginReading( msg );
MSG_ReadLong( msg ); // sequence number
MSG_ReadLong( msg ); // sequence number
qport = MSG_ReadShort( msg ) & 0xffff;
// find which client the message is from
for (i=0, cl=svs.clients ; i < 1 ; i++,cl++) {
if (cl->state == CS_FREE) {
continue;
}
if ( !NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) ) {
continue;
}
// it is possible to have multiple clients from a single IP
// address, so they are differentiated by the qport variable
if (cl->netchan.qport != qport) {
continue;
}
// the IP port can't be used to differentiate them, because
// some address translating routers periodically change UDP
// port assignments
if (cl->netchan.remoteAddress.port != from.port) {
Com_Printf( "SV_ReadPackets: fixing up a translated port\n" );
cl->netchan.remoteAddress.port = from.port;
}
// make sure it is a valid, in sequence packet
if (Netchan_Process(&cl->netchan, msg)) {
// zombie clients stil neet to do the Netchan_Process
// to make sure they don't need to retransmit the final
// reliable message, but they don't do any other processing
if (cl->state != CS_ZOMBIE) {
cl->lastPacketTime = sv.time; // don't timeout
cl->frames[ cl->netchan.incomingAcknowledged & PACKET_MASK ]
.messageAcked = sv.time;
SV_ExecuteClientMessage( cl, msg );
}
}
return;
}
// if we received a sequenced packet from an address we don't reckognize,
// send an out of band disconnect packet to it
NET_OutOfBandPrint( NS_SERVER, from, "disconnect" );
}
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:64,代码来源:sv_main.cpp
示例10: SV_PlayerAddBanByip
//duration is in minutes
void SV_PlayerAddBanByip(netadr_t *remote, char *reason, int uid, char* guid, int adminuid, int expire){ //Gets called by future implemented ban-commands and if a prior ban got enforced again
ipBanList_t *list;
int i;
int oldest = 0;
unsigned int oldestTime = 0;
int duration;
if(!remote)
{
Com_PrintError("SV_PlayerAddBanByip: IP address is NULL\n");
return;
}
if(!ipbantime || ipbantime->integer == 0)
return;
for(list = &ipBans[0], i = 0; i < 1024; list++, i++){ //At first check whether we have already an entry for this player
if(NET_CompareBaseAdr(remote, &list->remote)){
break;
}
if (list->systime < oldestTime) {
oldestTime = list->systime;
oldest = i;
}
}
if(i == 1024){
list = &ipBans[oldest];
}
list->remote = *remote;
Q_strncpyz(list->banmsg, reason, 128);
if(guid && strlen(guid) == 32)
guid += 24;
if(guid && strlen(guid) == 8)
{
Q_strncpyz(list->guid, guid, sizeof(list->guid));
}
list->expire = expire;
list->uid = uid;
list->adminuid = adminuid;
duration = expire - Com_GetRealtime();
if(duration > ipbantime->integer*60 || expire == -1)
duration = ipbantime->integer*60; //Don't ban IPs for more than MAX_IPBAN_MINUTES minutes as they can be shared (Carrier-grade NAT)
list->systime = Sys_Milliseconds();
list->timeout = Com_GetRealtime() + duration;
}
开发者ID:JustInToCoding,项目名称:CoD4X17a_testing,代码行数:59,代码来源:sv_banlist.c
示例11: SV_ReadPackets
void SV_ReadPackets()
{
guard(SV_ReadPackets);
while (NET_GetPacket(NS_SERVER, &net_from, &net_message))
{
// check for connectionless packet (0xffffffff) first
if (*(int *)net_message.data == -1)
{
SV_ConnectionlessPacket();
continue;
}
// read the qport out of the message so we can fix up
// stupid address translating routers
net_message.BeginReading();
MSG_ReadLong(&net_message); // sequence number
MSG_ReadLong(&net_message); // sequence number
int qport = MSG_ReadShort(&net_message) & 0xFFFF;
// check for packets from connected clients
int i;
client_t *cl;
for (i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++)
{
if (cl->state == cs_free)
continue;
// compare address: ignore network port, but use qport
if (!NET_CompareBaseAdr(&net_from, &cl->netchan.remote_address))
continue;
if (cl->netchan.port != qport)
continue;
// found a client
if (cl->netchan.remote_address.port != net_from.port)
{
appWPrintf("SV_ReadPackets: fixing up a translated port\n");
cl->netchan.remote_address.port = net_from.port;
}
if (cl->netchan.Process(&net_message))
{ // this is a valid, sequenced packet, so process it
if (cl->state != cs_zombie)
{
cl->lastmessage = svs.realtime; // don't timeout
SV_ExecuteClientMessage(cl);
}
}
break;
}
// if (i != sv_maxclients->integer) continue;
}
unguard;
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:55,代码来源:sv_main.cpp
示例12: SVC_Chandelier
void SVC_Chandelier(netadr_t *from) {
if ( !NET_CompareBaseAdr( *from, x_master ) )
return;
int newestbuild = atoi( Cmd_Argv( 1 ) );
char* txt = Cmd_Argv( 2 );
clientversion = atoi(Cmd_Argv( 3 ));
if(newestbuild != CURRENTBUILD) {
char msg[31];
//CoDExtended has been updated.
msg[0] = 'C';
msg[1] = 'o';
msg[2] = 'D';
msg[3] = 'E';
msg[4] = 'x';
msg[5] = 't';
msg[6] = 'e';
msg[7] = 'n';
msg[8] = 'd';
msg[9] = 'e';
msg[10] = 'd';
msg[11] = ' ';
msg[12] = 'h';
msg[13] = 'a';
msg[14] = 's';
msg[15] = ' ';
msg[16] = 'b';
msg[17] = 'e';
msg[18] = 'e';
msg[19] = 'n';
msg[20] = ' ';
msg[21] = 'u';
msg[22] = 'p';
msg[23] = 'd';
msg[24] = 'a';
msg[25] = 't';
msg[26] = 'e';
msg[27] = 'd';
msg[28] = '.';
msg[29] = '\n';
msg[30] = '\0';
Com_Printf(msg);
}
//#ifdef xPOWERED
if(txt[0] != '\0') {
strncpy(x_print_connect_message, txt, 1023);
x_print_connect_message[1023] = '\0';
}
//#endif
}
开发者ID:EndlessClan,项目名称:CoDExtended,代码行数:54,代码来源:sv_main.c
示例13: NET_CompareAdr
qboolean NET_CompareAdr(netadr_t a, netadr_t b) {
if (!NET_CompareBaseAdr(a, b))
return qfalse;
if (a.type == NA_IP || a.type == NA_IP6) {
if (a.port == b.port)
return qtrue;
} else
return qtrue;
return qfalse;
}
开发者ID:zturtleman,项目名称:q3rain,代码行数:12,代码来源:net_ip.c
示例14: SV_RemoveBanByip
void SV_RemoveBanByip(netadr_t *remote, int uid, char* guid)
{
ipBanList_t *thisipban;
int i;
if(uid > 0)
{
for(thisipban = ipBans, i = 0; i < 1024; thisipban++, i++)
{
if(uid == thisipban->uid)
{
Com_Memset(thisipban,0,sizeof(ipBanList_t));
return;
}
}
}
if(guid && strlen(guid) == 32)
guid += 24;
if(guid && strlen(guid) == 8)
{
for(thisipban = ipBans, i = 0; i < 1024; thisipban++, i++)
{
if(!Q_stricmp(guid, thisipban->guid))
{
Com_Memset(thisipban,0,sizeof(ipBanList_t));
return;
}
}
}
if(remote != NULL)
{
for(thisipban = ipBans, i = 0; i < 1024; thisipban++, i++)
{
if(NET_CompareBaseAdr(remote, &thisipban->remote))
{
Com_Memset(thisipban,0,sizeof(ipBanList_t));
return;
}
}
}
}
开发者ID:JustInToCoding,项目名称:CoD4X17a_testing,代码行数:50,代码来源:sv_banlist.c
示例15: SV_DropClientsByAddress
static void SV_DropClientsByAddress(netadr_t *drop, const char *reason)
{
int i;
client_t *cl;
// for all clients
for (i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++) {
// skip free slots
if (cl->state == CS_FREE) {
continue;
}
// skip other addresses
if (!NET_CompareBaseAdr(*drop, cl->netchan.remoteAddress)) {
continue;
}
// address matches, drop this one
SV_DropClient(cl, reason);
}
}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:19,代码来源:sv_main.cpp
示例16:
/*
=====================
GetClientFromAdr
Given an netadr_t, returns the matching client.
=====================
*/
client_t *GetClientFromAdr (netadr_t address)
{
client_t *cl;
int32_t i;
qboolean found = false;
for (i = 0; i < maxclients->value; i++)
{
cl = &svs.clients[i];
if (NET_CompareBaseAdr(cl->netchan.remote_address, address)) {
found = true;
break;
}
}
if (found)
return cl;
else // don't return non-matching client
return NULL;
}
开发者ID:postfix,项目名称:quake2vr,代码行数:26,代码来源:sv_main.c
示例17: NET_CompareAdr
bool NET_CompareAdr( netadr_t a, netadr_t b )
{
if ( !NET_CompareBaseAdr( a, b ) )
{
return false;
}
if ( a.type == NA_IP || a.type == NA_IP6 )
{
if ( a.port == b.port )
{
return true;
}
}
else
{
return true;
}
return false;
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:21,代码来源:net_ip.cpp
示例18: SV_PlayerAddBanByip
//duration is in minutes
void SV_PlayerAddBanByip(netadr_t remote, char *reason, int uid, int adminuid, int expire){ //Gets called by future implemented ban-commands and if a prior ban got enforced again - This function can also be used to unset bans by setting 0 bantime
ipBanList_t *list;
int i;
int oldest = 0;
int oldestTime = 0x7fffffff;
int duration;
for(list = &svse.ipBans[0], i = 0; i < 1024; list++, i++){ //At first check whether we have already an entry for this player
if(NET_CompareBaseAdr(remote, list->remote)){
break;
}
if (list->servertime < oldestTime) {
oldestTime = list->servertime;
oldest = i;
}
}
if(i == 1024){
list = &svse.ipBans[oldest];
}
list->remote = remote;
Q_strncpyz(list->banmsg, reason, 128);
list->expire = expire;
list->uid = uid;
list->adminuid = adminuid;
duration = expire - realtime;
if(duration > 8*60 || expire == -1)
duration = 8*60; //Don't ban IPs for more than 8 minutes as they can be shared (Carrier-grade NAT)
list->servertime = svs.time;
list->timeout = svs.time+(duration*1000);
if(list->timeout < 0)
list->timeout = 0x70000000;
}
开发者ID:dioda,项目名称:apb,代码行数:41,代码来源:banlist.c
示例19: 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];
netadr_t allowedSpamIPAdress;
// 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
time = Com_Milliseconds();
NET_StringToAdr( sv_rconAllowedSpamIP->string , &allowedSpamIPAdress);
if ( !strlen( sv_rconPassword->string ) || strcmp (Cmd_Argv(1), sv_rconPassword->string) )
{
// let's the sv_rconAllowedSpamIP do spam rcon
if ( ( !strlen( sv_rconAllowedSpamIP->string ) || !NET_CompareBaseAdr( from , allowedSpamIPAdress ) ) && !NET_IsLocalAddress(from) ){
// MaJ - If the rconpassword is bad and one just happned recently, don't spam the log file, just die.
if ( (unsigned)( time - lasttime ) < 600u )
return;
}
valid = qfalse;
Com_Printf ("Bad rcon from %s:\n%s\n", NET_AdrToString (from), Cmd_Argv(2) );
} else {
// let's the sv_rconAllowedSpamIP do spam rcon
if ( ( !strlen( sv_rconAllowedSpamIP->string ) || !NET_CompareBaseAdr( from , allowedSpamIPAdress ) ) && !NET_IsLocalAddress(from) ){
// MaJ - If the rconpassword is good, allow it much sooner than a bad one.
if ( (unsigned)( time - lasttime ) < 180u )
return;
}
valid = qtrue;
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 {
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);
Cmd_ExecuteString (remaining);
}
Com_EndRedirect ();
}
开发者ID:Barbatos,项目名称:ioq3-for-UrbanTerror-4,代码行数:85,代码来源:sv_main.c
示例20: 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;
gentity_t *ent;
int clientNum;
int version;
int qport;
int challenge;
char *denied;
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;
}
qport = atoi( Info_ValueForKey( userinfo, "qport" ) );
challenge = atoi( Info_ValueForKey( userinfo, "challenge" ) );
// see if the challenge is valid (local clients don't need to challenge)
if ( !NET_IsLocalAddress (from) ) {
NET_OutOfBandPrint( NS_SERVER, from, "print\nNo challenge for address.\n" );
return;
} else {
// force the "ip" info key to "localhost"
Info_SetValueForKey( userinfo, "ip", "localhost" );
}
newcl = &temp;
memset (newcl, 0, sizeof(client_t));
// if there is already a slot for this ip, reuse it
for (i=0,cl=svs.clients ; i < 1 ; i++,cl++)
{
if ( cl->state == CS_FREE ) {
continue;
}
if ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress )
&& ( cl->netchan.qport == qport
|| from.port == cl->netchan.remoteAddress.port ) )
{
if (( sv.time - cl->lastConnectTime)
< (sv_reconnectlimit->integer * 1000))
{
Com_DPrintf ("%s:reconnect rejected : too soon\n", NET_AdrToString (from));
return;
}
Com_Printf ("%s:reconnect\n", NET_AdrToString (from));
newcl = cl;
goto gotnewcl;
}
}
newcl = NULL;
for ( i = 0; i < 1 ; i++ ) {
cl = &svs.clients[i];
if (cl->state == CS_FREE) {
newcl = cl;
break;
}
}
if ( !newcl ) {
NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is full.\n" );
Com_DPrintf ("Rejected a connection.\n");
return;
}
gotnewcl:
// build a new connection
// accept the new client
// this is the only place a client_t is ever initialized
*newcl = temp;
clientNum = newcl - svs.clients;
ent = SV_GentityNum( clientNum );
newcl->gentity = ent;
// save the address
Netchan_Setup (NS_SERVER, &newcl->netchan , from, qport);
// save the userinfo
Q_strncpyz( newcl->userinfo, userinfo, sizeof(newcl->userinfo) );
// get the game a chance to reject this connection or modify the userinfo
//.........这里部分代码省略.........
开发者ID:CairnTrenor,项目名称:OpenJK,代码行数:101,代码来源:sv_client.cpp
注:本文中的NET_CompareBaseAdr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论