From a2e64f0a16188f455bb55a771ca82672a4ce8c42 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Tue, 7 Jun 2016 15:52:57 +0200 Subject: [PATCH 1/2] Don't send token to harmless vanilla clients --- src/engine/shared/network_server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 850dece93..4b9275785 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -283,7 +283,7 @@ void CNetServer::SendMsgs(NETADDR &Addr, const CMsgPacker *Msgs[], int num) // m_Construct.m_DataSize = (int)(pChunkData-m_Construct.m_aChunkData); - CNetBase::SendPacket(m_Socket, &Addr, &m_Construct, GetToken(Addr)); + CNetBase::SendPacket(m_Socket, &Addr, &m_Construct, NET_SECURITY_TOKEN_UNSUPPORTED); } // connection-less msg packet without token-support From 0244640aca06ce3170c89bf74ef48c7d2243a05e Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Wed, 8 Jun 2016 09:57:17 +0200 Subject: [PATCH 2/2] Also don't send the token magic to unsupported clients Since only the client can initiate the secure session, there's basically no reason to send this magic to clients which didn't advertise the feature. --- src/engine/shared/network_server.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index b224c4676..7d800e38d 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -339,8 +339,7 @@ void CNetServer::OnPreConnMsg(NETADDR &Addr, CNetPacketConstruct &Packet) } // simulate accept - SendControl(Addr, NET_CTRLMSG_CONNECTACCEPT, SECURITY_TOKEN_MAGIC, - sizeof(SECURITY_TOKEN_MAGIC), NET_SECURITY_TOKEN_UNSUPPORTED); + SendControl(Addr, NET_CTRLMSG_CONNECTACCEPT, NULL, 0, NET_SECURITY_TOKEN_UNSUPPORTED); // Begin vanilla compatible token handshake // The idea is to pack a security token in the gametick @@ -410,8 +409,7 @@ void CNetServer::OnPreConnMsg(NETADDR &Addr, CNetPacketConstruct &Packet) else { // accept client directy - SendControl(Addr, NET_CTRLMSG_CONNECTACCEPT, SECURITY_TOKEN_MAGIC, - sizeof(SECURITY_TOKEN_MAGIC), NET_SECURITY_TOKEN_UNSUPPORTED); + SendControl(Addr, NET_CTRLMSG_CONNECTACCEPT, NULL, 0, NET_SECURITY_TOKEN_UNSUPPORTED); TryAcceptClient(Addr, NET_SECURITY_TOKEN_UNSUPPORTED); }