master #6

Merged
BRNSystems merged 85 commits from Mirrorlandia_minetest/minetest:master into master 2024-01-09 17:53:52 +01:00
7 changed files with 43 additions and 7 deletions
Showing only changes of commit 7e143cb33d - Show all commits

@ -810,6 +810,14 @@ bind_address (Bind address) string
# to new servers, but they may not support all new features that you are expecting. # to new servers, but they may not support all new features that you are expecting.
strict_protocol_version_checking (Strict protocol checking) bool false strict_protocol_version_checking (Strict protocol checking) bool false
# Define the oldest clients allowed to connect.
# Older clients are compatible in the sense that they will not crash when connecting
# to new servers, but they may not support all new features that you are expecting.
# This allows for more fine-grained control than strict_protocol_version_checking.
# Minetest still enforces its own internal minimum, and enabling
# strict_protocol_version_checking will effectively override this.
protocol_version_min (Protocol version minimum) int 1 1 65535
# Specifies URL from which client fetches media instead of using UDP. # Specifies URL from which client fetches media instead of using UDP.
# $filename should be accessible from $remote_media$filename via cURL # $filename should be accessible from $remote_media$filename via cURL
# (obviously, remote_media should end with a slash). # (obviously, remote_media should end with a slash).

@ -760,6 +760,15 @@
# type: bool # type: bool
# strict_protocol_version_checking = false # strict_protocol_version_checking = false
# Define the oldest clients allowed to connect.
# Older clients are compatible in the sense that they will not crash when connecting
# to new servers, but they may not support all new features that you are expecting.
# This allows more fine-grained control than strict_protocol_version_checking.
# Minetest may still enforce its own internal minimum, and enabling
# strict_protocol_version_checking will effectively override this.
# type: int min: 1 max: 65535
# protocol_version_min = 1
# Specifies URL from which client fetches media instead of using UDP. # Specifies URL from which client fetches media instead of using UDP.
# $filename should be accessible from $remote_media$filename via cURL # $filename should be accessible from $remote_media$filename via cURL
# (obviously, remote_media should end with a slash). # (obviously, remote_media should end with a slash).

@ -365,6 +365,7 @@ void set_default_settings()
settings->setDefault("max_packets_per_iteration", "1024"); settings->setDefault("max_packets_per_iteration", "1024");
settings->setDefault("port", "30000"); settings->setDefault("port", "30000");
settings->setDefault("strict_protocol_version_checking", "false"); settings->setDefault("strict_protocol_version_checking", "false");
settings->setDefault("protocol_version_min", "1");
settings->setDefault("player_transfer_distance", "0"); settings->setDefault("player_transfer_distance", "0");
settings->setDefault("max_simultaneous_block_sends_per_client", "40"); settings->setDefault("max_simultaneous_block_sends_per_client", "40");
settings->setDefault("time_send_interval", "5"); settings->setDefault("time_send_interval", "5");

@ -147,10 +147,8 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
client->net_proto_version = net_proto_version; client->net_proto_version = net_proto_version;
if ((g_settings->getBool("strict_protocol_version_checking") && if (net_proto_version < Server::getProtocolVersionMin() ||
net_proto_version != LATEST_PROTOCOL_VERSION) || net_proto_version > Server::getProtocolVersionMax()) {
net_proto_version < SERVER_PROTOCOL_VERSION_MIN ||
net_proto_version > SERVER_PROTOCOL_VERSION_MAX) {
actionstream << "Server: A mismatched client tried to connect from " << actionstream << "Server: A mismatched client tried to connect from " <<
addr_s << " proto_max=" << (int)max_net_proto_version << std::endl; addr_s << " proto_max=" << (int)max_net_proto_version << std::endl;
DenyAccess(peer_id, SERVER_ACCESSDENIED_WRONG_VERSION); DenyAccess(peer_id, SERVER_ACCESSDENIED_WRONG_VERSION);

@ -4191,3 +4191,20 @@ bool Server::migrateModStorageDatabase(const GameParams &game_params, const Sett
return succeeded; return succeeded;
} }
u16 Server::getProtocolVersionMin()
{
u16 min_proto = g_settings->getU16("protocol_version_min");
if (g_settings->getBool("strict_protocol_version_checking"))
min_proto = LATEST_PROTOCOL_VERSION;
return rangelim(min_proto,
SERVER_PROTOCOL_VERSION_MIN,
SERVER_PROTOCOL_VERSION_MAX);
}
u16 Server::getProtocolVersionMax()
{
return g_settings->getBool("strict_protocol_version_checking")
? LATEST_PROTOCOL_VERSION
: SERVER_PROTOCOL_VERSION_MAX;
}

@ -383,6 +383,9 @@ public:
static bool migrateModStorageDatabase(const GameParams &game_params, static bool migrateModStorageDatabase(const GameParams &game_params,
const Settings &cmd_args); const Settings &cmd_args);
static u16 getProtocolVersionMin();
static u16 getProtocolVersionMax();
// Lua files registered for init of async env, pair of modname + path // Lua files registered for init of async env, pair of modname + path
std::vector<std::pair<std::string, std::string>> m_async_init_files; std::vector<std::pair<std::string, std::string>> m_async_init_files;

@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <json/json.h> #include <json/json.h>
#include "convert_json.h" #include "convert_json.h"
#include "httpfetch.h" #include "httpfetch.h"
#include "server.h"
namespace ServerList namespace ServerList
{ {
@ -50,12 +51,11 @@ void sendAnnounce(AnnounceAction action,
server["address"] = g_settings->get("server_address"); server["address"] = g_settings->get("server_address");
} }
if (action != AA_DELETE) { if (action != AA_DELETE) {
bool strict_checking = g_settings->getBool("strict_protocol_version_checking");
server["name"] = g_settings->get("server_name"); server["name"] = g_settings->get("server_name");
server["description"] = g_settings->get("server_description"); server["description"] = g_settings->get("server_description");
server["version"] = g_version_string; server["version"] = g_version_string;
server["proto_min"] = strict_checking ? LATEST_PROTOCOL_VERSION : SERVER_PROTOCOL_VERSION_MIN; server["proto_min"] = Server::getProtocolVersionMin();
server["proto_max"] = strict_checking ? LATEST_PROTOCOL_VERSION : SERVER_PROTOCOL_VERSION_MAX; server["proto_max"] = Server::getProtocolVersionMax();
server["url"] = g_settings->get("server_url"); server["url"] = g_settings->get("server_url");
server["creative"] = g_settings->getBool("creative_mode"); server["creative"] = g_settings->getBool("creative_mode");
server["damage"] = g_settings->getBool("enable_damage"); server["damage"] = g_settings->getBool("enable_damage");