A connection request that did not come from the master.
(List<String> args, netadr_t adr)
| 220 | * A connection request that did not come from the master. |
| 221 | */ |
| 222 | private void SVC_DirectConnect(List<String> args, netadr_t adr) { |
| 223 | |
| 224 | Com.DPrintf("SVC_DirectConnect ()\n"); |
| 225 | |
| 226 | int version = args.size() >= 2 ? Lib.atoi(args.get(1)) : 0; |
| 227 | |
| 228 | if (version != Defines.PROTOCOL_VERSION) { |
| 229 | Netchan.sendConnectionlessPacket(Defines.NS_SERVER, adr, ConnectionlessCommand.print, |
| 230 | "\nServer is version " + Globals.VERSION + "\n"); |
| 231 | Com.DPrintf(" rejected connect from version " + version + "\n"); |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | int qport = args.size() >= 3 ? Lib.atoi(args.get(2)) : 0; |
| 236 | int challenge = args.size() >= 4 ? Lib.atoi(args.get(3)) : 0; |
| 237 | String userinfo = args.size() >= 5 ? args.get(4) : ""; |
| 238 | |
| 239 | // force the IP key/value pair so the game can filter based on ip |
| 240 | userinfo = Info.Info_SetValueForKey(userinfo, "ip", adr.toString()); |
| 241 | |
| 242 | |
| 243 | /* |
| 244 | if (gameImports.sv.isDemo) { |
| 245 | if (!adr.IsLocalAddress()) { |
| 246 | Com.Printf("Remote connect in attract loop. Ignored.\n"); |
| 247 | Netchan.sendConnectionlessPacket(Defines.NS_SERVER, adr, ConnectionlessCommand.print, "\nConnection refused.\n"); |
| 248 | return; |
| 249 | } |
| 250 | } |
| 251 | */ |
| 252 | |
| 253 | |
| 254 | // see if the challenge is valid |
| 255 | int j; |
| 256 | if (!adr.IsLocalAddress()) { |
| 257 | for (j = 0; j < Defines.MAX_CHALLENGES; j++) { |
| 258 | if (adr.CompareBaseAdr(challenges[j].adr)) { |
| 259 | if (challenge == challenges[j].challenge) |
| 260 | break; // good |
| 261 | Netchan.sendConnectionlessPacket(Defines.NS_SERVER, adr, ConnectionlessCommand.print, "\nBad challenge.\n"); |
| 262 | return; |
| 263 | } |
| 264 | } |
| 265 | if (j == Defines.MAX_CHALLENGES) { |
| 266 | Netchan.sendConnectionlessPacket(Defines.NS_SERVER, adr, ConnectionlessCommand.print, "\nNo challenge for address.\n"); |
| 267 | return; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | // if there is already a slot for this ip, reuse it |
| 272 | int i = 0; |
| 273 | for (client_t cl: clients) { |
| 274 | if (cl.state == ClientStates.CS_FREE) |
| 275 | continue; |
| 276 | if (adr.CompareBaseAdr(cl.netchan.remote_address) |
| 277 | && (cl.netchan.qport == qport || adr.port == cl.netchan.remote_address.port)) { |
| 278 | if (!adr.IsLocalAddress() && (realtime - cl.lastconnect) < (SV_MAIN.sv_reconnect_limit.value * 1000)) { |
| 279 | Com.DPrintf(adr.toString() + ":reconnect rejected : too soon\n"); |
no test coverage detected