MCPcopy Create free account
hub / github.com/ddnet/ddnet / OnTokenCtrlMsg

Method OnTokenCtrlMsg

src/engine/shared/network_server.cpp:483–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483void CNetServer::OnTokenCtrlMsg(NETADDR &Addr, int ControlMsg, const CNetPacketConstruct &Packet)
484{
485 if(ClientExists(Addr))
486 return; // silently ignore
487
488 if(ControlMsg == NET_CTRLMSG_CONNECT)
489 {
490 // response connection request with token
491 SECURITY_TOKEN Token = GetToken(Addr);
492 SendControl(Addr, NET_CTRLMSG_CONNECTACCEPT, SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC), Token);
493 }
494 else if(ControlMsg == NET_CTRLMSG_ACCEPT)
495 {
496 SECURITY_TOKEN Token = ToSecurityToken(&Packet.m_aChunkData[1]);
497 if(Token == GetToken(Addr))
498 {
499 // correct token
500 // try to accept client
501 if(g_Config.m_Debug)
502 dbg_msg("security", "new client (ddnet token)");
503 TryAcceptClient(Addr, Token);
504 }
505 else
506 {
507 // invalid token
508 if(g_Config.m_Debug)
509 dbg_msg("security", "invalid token");
510 }
511 }
512}
513
514int CNetServer::OnSixupCtrlMsg(NETADDR &Addr, CNetChunk *pChunk, int ControlMsg, const CNetPacketConstruct &Packet, SECURITY_TOKEN &ResponseToken, SECURITY_TOKEN Token)
515{

Callers

nothing calls this directly

Calls 2

ToSecurityTokenFunction · 0.85
dbg_msgFunction · 0.85

Tested by

no test coverage detected