From da68923ac3f1eda7a1d3e5170dc1f61c239b3ae6 Mon Sep 17 00:00:00 2001 From: Learath Date: Fri, 19 Jun 2020 22:08:16 +0300 Subject: [PATCH] Implement a switch for 0.7 compatibility --- src/engine/server/server.cpp | 8 +++++--- src/engine/shared/config_variables.h | 1 + src/engine/shared/network_server.cpp | 7 +++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index fb31b7efe..41e4a8020 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -2115,7 +2115,8 @@ void CServer::PumpNetwork() continue; } - if(ResponseToken != NET_SECURITY_TOKEN_UNKNOWN && m_RegSixup.RegisterProcessPacket(&Packet, ResponseToken)) + if(ResponseToken != NET_SECURITY_TOKEN_UNKNOWN && g_Config.m_SvSixup && + m_RegSixup.RegisterProcessPacket(&Packet, ResponseToken)) continue; if(ResponseToken == NET_SECURITY_TOKEN_UNKNOWN && m_Register.RegisterProcessPacket(&Packet)) continue; @@ -2139,7 +2140,7 @@ void CServer::PumpNetwork() { Type = SERVERINFO_64_LEGACY; } - if(Type == SERVERINFO_VANILLA && ResponseToken != NET_SECURITY_TOKEN_UNKNOWN) + if(Type == SERVERINFO_VANILLA && ResponseToken != NET_SECURITY_TOKEN_UNKNOWN && g_Config.m_SvSixup) { CUnpacker Unpacker; Unpacker.Reset((unsigned char*)Packet.m_pData+sizeof(SERVERBROWSE_GETINFO), Packet.m_DataSize-sizeof(SERVERBROWSE_GETINFO)); @@ -2480,7 +2481,8 @@ int CServer::Run() // master server stuff m_Register.RegisterUpdate(m_NetServer.NetType()); - m_RegSixup.RegisterUpdate(m_NetServer.NetType()); + if(g_Config.m_SvSixup) + m_RegSixup.RegisterUpdate(m_NetServer.NetType()); if(m_ServerInfoNeedsUpdate) UpdateServerInfo(); diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index e7f9513fc..dd9a64305 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -145,6 +145,7 @@ MACRO_CONFIG_INT(SvPlayerDemoRecord, sv_player_demo_record, 0, 0, 1, CFGFLAG_SER MACRO_CONFIG_INT(SvDemoChat, sv_demo_chat, 0, 0, 1, CFGFLAG_SERVER, "Record chat for demos") MACRO_CONFIG_INT(SvServerInfoPerSecond, sv_server_info_per_second, 50, 0, 10000, CFGFLAG_SERVER, "Maximum number of complete server info responses that are sent out per second (0 for no limit)") MACRO_CONFIG_INT(SvVanConnPerSecond, sv_van_conn_per_second, 10, 0, 10000, CFGFLAG_SERVER, "Antispoof specific ratelimit (0 for no limit)") +MACRO_CONFIG_INT(SvSixup, sv_sixup, 1, 0, 1, CFGFLAG_SERVER, "Enable sixup connections") MACRO_CONFIG_STR(EcBindaddr, ec_bindaddr, 128, "localhost", CFGFLAG_ECON, "Address to bind the external console to. Anything but 'localhost' is dangerous") MACRO_CONFIG_INT(EcPort, ec_port, 0, 0, 0, CFGFLAG_ECON, "Port to use for the external console") diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 2ba3fa220..fd5752de5 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -216,6 +216,13 @@ bool CNetServer::Connlimit(NETADDR Addr) int CNetServer::TryAcceptClient(NETADDR &Addr, SECURITY_TOKEN SecurityToken, bool VanillaAuth, bool Sixup, SECURITY_TOKEN Token) { + if(Sixup && !g_Config.m_SvSixup) + { + const char Msg[] = "0.7 connections are not accepted at this time"; + CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, Msg, sizeof(Msg), SecurityToken, Sixup); + return -1; // failed to add client? + } + if (Connlimit(Addr)) { const char Msg[] = "Too many connections in a short time";