================== SV_DirectConnect A "connect" OOB command has been received ================== */
| 35 | ================== |
| 36 | */ |
| 37 | void SV_DirectConnect( netadr_t from ) { |
| 38 | char userinfo[MAX_INFO_STRING]; |
| 39 | int i; |
| 40 | client_t *cl, *newcl; |
| 41 | client_t temp; |
| 42 | gentity_t *ent; |
| 43 | int clientNum; |
| 44 | int version; |
| 45 | int qport; |
| 46 | //int challenge; |
| 47 | char *denied; |
| 48 | |
| 49 | Com_DPrintf ("SVC_DirectConnect ()\n"); |
| 50 | |
| 51 | Q_strncpyz( userinfo, Cmd_Argv(1), sizeof(userinfo) ); |
| 52 | |
| 53 | version = atoi( Info_ValueForKey( userinfo, "protocol" ) ); |
| 54 | if ( version != PROTOCOL_VERSION ) { |
| 55 | NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i.\n", PROTOCOL_VERSION ); |
| 56 | Com_DPrintf (" rejected connect from version %i\n", version); |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | qport = atoi( Info_ValueForKey( userinfo, "qport" ) ); |
| 61 | |
| 62 | //challenge = atoi( Info_ValueForKey( userinfo, "challenge" ) ); |
| 63 | |
| 64 | // see if the challenge is valid (local clients don't need to challenge) |
| 65 | if ( !NET_IsLocalAddress (from) ) { |
| 66 | NET_OutOfBandPrint( NS_SERVER, from, "print\nNo challenge for address.\n" ); |
| 67 | return; |
| 68 | } else { |
| 69 | // force the "ip" info key to "localhost" |
| 70 | Info_SetValueForKey( userinfo, "ip", "localhost" ); |
| 71 | } |
| 72 | |
| 73 | newcl = &temp; |
| 74 | memset (newcl, 0, sizeof(client_t)); |
| 75 | |
| 76 | // if there is already a slot for this ip, reuse it |
| 77 | for (i=0,cl=svs.clients ; i < 1 ; i++,cl++) |
| 78 | { |
| 79 | if ( cl->state == CS_FREE ) { |
| 80 | continue; |
| 81 | } |
| 82 | if ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) |
| 83 | && ( cl->netchan.qport == qport |
| 84 | || from.port == cl->netchan.remoteAddress.port ) ) |
| 85 | { |
| 86 | if (( sv.time - cl->lastConnectTime) |
| 87 | < (sv_reconnectlimit->integer * 1000)) |
| 88 | { |
| 89 | Com_DPrintf ("%s:reconnect rejected : too soon\n", NET_AdrToString (from)); |
| 90 | return; |
| 91 | } |
| 92 | Com_Printf ("%s:reconnect\n", NET_AdrToString (from)); |
| 93 | newcl = cl; |
| 94 | goto gotnewcl; |
no test coverage detected