From 96a286dcf501e1a749767e20327613c02bb1ff63 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 27 Nov 2012 00:26:19 +0200 Subject: [PATCH] Make strict and non-strict protocol version checking to work more like expected --- minetest.conf.example | 4 ++-- src/defaultsettings.cpp | 2 +- src/server.cpp | 32 +++++++++++++++++++------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/minetest.conf.example b/minetest.conf.example index aebab825c..64cb87727 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -139,8 +139,8 @@ #motd = Welcome to this awesome Minetest server! # Maximum number of players connected simultaneously #max_users = 100 -# Set to false to allow old clients to connect -#strict_protocol_version_checking = true +# Set to true to disallow old clients from connecting +#strict_protocol_version_checking = false # Set to true to enable creative mode (unlimited inventory) #creative_mode = false # Enable players getting damage and dying diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index e9c2ba3b8..8ce9cb1fb 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -111,7 +111,7 @@ void set_default_settings(Settings *settings) settings->setDefault("default_game", "minetest"); settings->setDefault("motd", ""); settings->setDefault("max_users", "100"); - settings->setDefault("strict_protocol_version_checking", "true"); + settings->setDefault("strict_protocol_version_checking", "false"); settings->setDefault("creative_mode", "false"); settings->setDefault("enable_damage", "true"); settings->setDefault("only_peaceful_mobs", "false"); diff --git a/src/server.cpp b/src/server.cpp index 41765ed19..684e3bb08 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2069,33 +2069,39 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) getClient(peer_id)->net_proto_version = net_proto_version; - if(net_proto_version == 0) + if(net_proto_version < SERVER_PROTOCOL_VERSION_MIN || + net_proto_version > SERVER_PROTOCOL_VERSION_MAX) { - actionstream<<"Server: An old tried to connect from "<getBool("strict_protocol_version_checking")) { - if(net_proto_version < SERVER_PROTOCOL_VERSION_MIN || - net_proto_version > SERVER_PROTOCOL_VERSION_MAX) + if(net_proto_version != LATEST_PROTOCOL_VERSION) { - actionstream<<"Server: A mismatched client tried to connect" - <<" from "<net_proto_version < LATEST_PROTOCOL_VERSION) { - SendChatMessage(peer_id, L"# Server: WARNING: YOUR CLIENT IS OLD " - L"AND MAY NOT FULLY WORK WITH THIS SERVER!"); + SendChatMessage(peer_id, L"# Server: WARNING: YOUR CLIENT'S " + L"VERSION MAY NOT BE FULLY COMPATIBLE WITH THIS SERVER!"); } /* -- 2.25.1