/* ================= 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(void) { const char * s; const char * c; MSG_BeginReading(&net_message); MSG_ReadLong(&net_message); // skip the -1 marker s = MSG_ReadStringLine(&net_message); Cmd_TokenizeString(s, false); c = Cmd_Argv(0); Com_DPrintf("Packet %s : %s\n", NET_AdrToString(net_from), c); if (!strcmp(c, "ping")) SVC_Ping(); else if (!strcmp(c, "ack")) SVC_Ack(); else if (!strcmp(c, "status")) SVC_Status(); else if (!strcmp(c, "info")) SVC_Info(); else if (!strcmp(c, "getchallenge")) SVC_GetChallenge(); else if (!strcmp(c, "connect")) SVC_DirectConnect(); else if (!strcmp(c, "rcon")) SVC_RemoteCommand(); else Com_Printf("bad connectionless packet from %s:\n%s\n", NET_AdrToString(net_from), s); }
/* * ================= * 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(void) { char *s; char *c; // r1ch fix: make sure we never talk to ourselves // if (NET_IsLocalAddress (net_from.ip[0] == 127) && !NET_IsLocalHost(net_from) && ShortSwap(net_from.port) == server_port) /* if ( (net_from.ip[0] == 127) && (net_from.type != NA_LOOPBACK) && (ShortSwap(net_from.port) == server_port) ) * { * Com_DPrintf ("dropped %d byte connectionless packet from self! (spoofing attack?)\n", net_message.cursize); * return; * }*/ MSG_BeginReading(&net_message); MSG_ReadLong(&net_message); // skip the -1 marker s = MSG_ReadStringLine(&net_message); Cmd_TokenizeString(s, false); c = Cmd_Argv(0); Com_DPrintf("Packet %s : %s\n", NET_AdrToString(net_from), c); if (!strcmp(c, "ping")) { SVC_Ping(); } else if (!strcmp(c, "ack")) { SVC_Ack(); } else if (!strcmp(c, "status")) { SVC_Status(); } else if (!strcmp(c, "info")) { SVC_Info(); } else if (!strcmp(c, "getchallenge")) { SVC_GetChallenge(); } else if (!strcmp(c, "connect")) { SVC_DirectConnect(); } else if (!strcmp(c, "rcon")) { SVC_RemoteCommand(); } else { Com_Printf("bad connectionless packet from %s:\n%s\n" , NET_AdrToString(net_from), s); } }
/* ================= 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. ================= */ static void SV_ConnectionlessPacket (void) { const char *s; const char *c; MSG_BeginReading (); MSG_ReadLong (); // skip the -1 marker s = MSG_ReadStringLine (); Cmd_TokenizeString (s); c = Cmd_Argv(0); if (!strcmp(c, "ping") || ( c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n')) ) { SVC_Ping (); return; } if (c[0] == A2A_ACK && (c[1] == 0 || c[1] == '\n') ) { Con_Printf ("A2A_ACK from %s\n", NET_AdrToString (net_from)); return; } else if (c[0] == A2S_ECHO) { NET_SendPacket (net_message.cursize, net_message.data, net_from); return; } else if (!strcmp(c,"status")) { SVC_Status (); return; } else if (!strcmp(c,"log")) { SVC_Log (); return; } else if (!strcmp(c,"connect")) { SVC_DirectConnect (); return; } else if (!strcmp(c, "rcon")) SVC_RemoteCommand (); else Con_Printf ("bad connectionless packet from %s:\n%s\n", NET_AdrToString (net_from), s); }
/* ================= 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 (void) { char *s; char *c; int s_token = 0; // r1ch fix: make sure we never talk to ourselves // if (NET_IsLocalAddress (net_from.ip[0] == 127) && !NET_IsLocalHost(net_from) && ShortSwap(net_from.port) == server_port) /* if ( (net_from.ip[0] == 127) && (net_from.type != NA_LOOPBACK) && (ShortSwap(net_from.port) == server_port) ) { Com_DPrintf ("dropped %d byte connectionless packet from self! (spoofing attack?)\n", net_message.cursize); return; }*/ MSG_BeginReading (&net_message); MSG_ReadLong (&net_message); // skip the -1 marker s = MSG_ReadStringLine (&net_message); Cmd_TokenizeString (s, false); c = Cmd_Argv(0); Com_DPrintf ("Packet %s : %s\n", NET_AdrToString(net_from), c); if ((s_token = Q_STLookup(&packet_stable, c)) != -1) { if (s_token == s_ping) SVC_Ping (); else if (s_token == s_ack) SVC_Ack (); else if (s_token == s_status) SVC_Status (); else if (s_token == s_info) SVC_Info (); else if (s_token == s_getchallenge) SVC_GetChallenge (); else if (s_token == s_connect) SVC_DirectConnect (); else if (s_token == s_rcon) SVC_RemoteCommand (); } else Com_Printf ("bad connectionless packet from %s:\n%s\n" , NET_AdrToString (net_from), s); }
/* ================= 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 (void) { char *s; char *c; MSG_BeginReading (); MSG_ReadLong (); // skip the -1 marker s = MSG_ReadStringLine (); s[1023] = 0; Cmd_TokenizeString (s); c = Cmd_Argv(0); if (!strcmp(c, "ping") || ( c[0] == A2A_PING && (c[1] == 0 || c[1] == '\n')) ) { SVC_Ping (); return; } if (c[0] == A2A_ACK && (c[1] == 0 || c[1] == '\n') ) { Com_Printf ("A2A_ACK from %s\n", NET_AdrToString (net_from)); return; } else if (!strcmp(c,"status")) { SVC_Status (); return; } else if (!strcmp(c,"log")) { SVC_Log (); return; } else if (!strcmp(c,"connect")) { SVC_DirectConnect (); return; } #ifdef MAUTH else if (c[0] == M2S_AUTH_TOK && (c[1] == 0 || c[1] == '\n') ) { Com_Printf("MAUTH: Adding token from %s to auth queue\n", NET_AdrToString(net_from)); // Provisionally add auth record... if (SV_AuthListAdd(&authtokq)) { //SV_AuthListPrint(&authtokq); //SV_AuthListPrint(&authclientq); // Send S2M_AUTH_TOK_CHK as a spoofing check... Master_AuthTokChk(authtokq.start->name, authtokq.start->hash); } else { Com_Printf("MAUTH: Failure to add token from %s -- already added?\n", NET_AdrToString(net_from)); // FIXME Send S2M_AUTH_TOK_NACK } return; } else if (c[0] == M2S_AUTH_TOK_ACK && (c[1] == 0 || c[1] == '\n') ) { // The master is sending us the correct name and hash; // check that what we've got agrees with this. // FIXME do we trust this packet? char tok_ack = S2C_AUTH_TOK_ACK; authclient_t *newclient = NULL; qbool result; result = SV_AuthListValidate(&authtokq, &newclient); //SV_AuthListPrint(&authtokq); //SV_AuthListPrint(&authclientq); // Check the client is valid... if( !result ) { Com_Printf("MAUTH: Client is not valid!\n"); return; } // Tell client they can connect... Com_Printf("MAUTH: Telling client %s on %s to connect...\n", newclient->name, NET_AdrToString(newclient->client_addr)); NET_SendPacket (NS_SERVER, 1, &tok_ack, newclient->client_addr); return; } /*else if (c[0] == M2S_AUTH_TOK_NACK && (c[1] == 0 || c[1] == '\n') ) { // Master said this token not valid -- FIXME how can we trust this? // FIXME remove player details from auth queue. Com_Printf("MAUTH: Player invalid!\n"); }*/ #endif else if (!strcmp(c,"getchallenge")) { SVC_GetChallenge (); return; } else if (!strcmp(c, "rcon")) SVC_RemoteCommand (); else Com_Printf ("bad connectionless packet from %s:\n%s\n" , NET_AdrToString (net_from), s); }