| 444 | } |
| 445 | |
| 446 | void CNetServer::OnConnCtrlMsg(NETADDR &Addr, int ClientId, int ControlMsg, const CNetPacketConstruct &Packet) |
| 447 | { |
| 448 | if(ControlMsg == NET_CTRLMSG_CONNECT) |
| 449 | { |
| 450 | // got connection attempt inside of valid session |
| 451 | // the client probably wants to reconnect |
| 452 | bool SupportsToken = Packet.m_DataSize >= |
| 453 | (int)(1 + sizeof(SECURITY_TOKEN_MAGIC) + sizeof(SECURITY_TOKEN)) && |
| 454 | !mem_comp(&Packet.m_aChunkData[1], SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC)); |
| 455 | |
| 456 | if(SupportsToken) |
| 457 | { |
| 458 | // response connection request with token |
| 459 | SECURITY_TOKEN Token = GetToken(Addr); |
| 460 | SendControl(Addr, NET_CTRLMSG_CONNECTACCEPT, SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC), Token); |
| 461 | } |
| 462 | |
| 463 | if(g_Config.m_Debug) |
| 464 | dbg_msg("security", "client %d wants to reconnect", ClientId); |
| 465 | } |
| 466 | else if(ControlMsg == NET_CTRLMSG_ACCEPT && Packet.m_DataSize == 1 + sizeof(SECURITY_TOKEN)) |
| 467 | { |
| 468 | SECURITY_TOKEN Token = ToSecurityToken(&Packet.m_aChunkData[1]); |
| 469 | if(Token == GetToken(Addr)) |
| 470 | { |
| 471 | // correct token |
| 472 | // try to accept client |
| 473 | if(g_Config.m_Debug) |
| 474 | dbg_msg("security", "client %d reconnect", ClientId); |
| 475 | |
| 476 | // reset netconn and process rejoin |
| 477 | m_aSlots[ClientId].m_Connection.Reset(true); |
| 478 | m_pfnClientRejoin(ClientId, m_pUser); |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | void CNetServer::OnTokenCtrlMsg(NETADDR &Addr, int ControlMsg, const CNetPacketConstruct &Packet) |
| 484 | { |
nothing calls this directly
no test coverage detected