summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-08-22 04:27:44 +0200
committerest31 <MTest31@outlook.com>2016-08-22 20:23:28 +0200
commitd767f025cb0d5cca29c1f2147d2a0931a088b717 (patch)
treeeddc886ed5e6f09e43fa6c4224e4e14d5a840608
parent0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42 (diff)
downloadminetest-d767f025cb0d5cca29c1f2147d2a0931a088b717.tar.gz
minetest-d767f025cb0d5cca29c1f2147d2a0931a088b717.tar.bz2
minetest-d767f025cb0d5cca29c1f2147d2a0931a088b717.zip
Client: disable pre v25 init sending by default
Disable the ability to connect to old servers by default to improve password security. If people still want to connect to old (0.4.12 and earlier) servers, they can flip the send_pre_v25_init setting. Add the ability to detect if we've tried to connect to a server which only supports the pre v25 init protocol, and show an apropriate error message. Most times the error will already be catched at the serverlist level, the detection mechanism only acts as last resort, because the "Connection timed out" error message that would be shown otherwise would be very confusing. Automatic "fixing" of this condition is not desired, as it would allow for downgrade attacks. As already 161 of the 167 servers on the serverlist support the new srp based auth protocol (> 96%), the breakage should be minimal. Follow up of commit af30183124d40a969040d7de4b3a487feec466e4 "Add option to not send pre v25 init packet" Also change the pessimistic assumption of masterlist server versions to optimistic, in order to avoid buggy behaviour (favourites not in the serverlist would be denied to connect to, etc).
-rw-r--r--builtin/mainmenu/common.lua10
-rw-r--r--builtin/settingtypes.txt2
-rw-r--r--minetest.conf.example4
-rw-r--r--src/client.h3
-rw-r--r--src/defaultsettings.cpp2
-rw-r--r--src/game.cpp21
6 files changed, 34 insertions, 8 deletions
diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua
index 1fd89ff77..da3667828 100644
--- a/builtin/mainmenu/common.lua
+++ b/builtin/mainmenu/common.lua
@@ -248,14 +248,18 @@ end
--------------------------------------------------------------------------------
function is_server_protocol_compat(server_proto_min, server_proto_max)
- return min_supp_proto <= (server_proto_max or 24) and max_supp_proto >= (server_proto_min or 13)
+ if (not server_proto_min) or (not server_proto_max) then
+ -- There is no info. Assume the best and act as if we would be compatible.
+ return true
+ end
+ return min_supp_proto <= server_proto_max and max_supp_proto >= server_proto_min
end
--------------------------------------------------------------------------------
function is_server_protocol_compat_or_error(server_proto_min, server_proto_max)
if not is_server_protocol_compat(server_proto_min, server_proto_max) then
local server_prot_ver_info, client_prot_ver_info
- local s_p_min = server_proto_min or 13
- local s_p_max = server_proto_max or 24
+ local s_p_min = server_proto_min
+ local s_p_max = server_proto_max
if s_p_min ~= s_p_max then
server_prot_ver_info = fgettext_ne("Server supports protocol versions between $1 and $2. ",
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 864485cce..4d354a7ef 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -247,7 +247,7 @@ remote_port (Remote port) int 30000 1 65535
# Enable if you want to connect to 0.4.12 servers and before.
# Servers starting with 0.4.13 will work, 0.4.12-dev servers may work.
# Disabling this option will protect your password better.
-send_pre_v25_init (Support older servers) bool true
+send_pre_v25_init (Support older servers) bool false
# Save the map received by the client on disk.
enable_local_map_saving (Saving map received from server) bool false
diff --git a/minetest.conf.example b/minetest.conf.example
index 03a917a39..48c54c320 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -261,7 +261,7 @@
# Servers starting with 0.4.13 will work, 0.4.12-dev servers may work.
# Disabling this option will protect your password better.
# type: bool
-# send_pre_v25_init = true
+# send_pre_v25_init = false
# Save the map received by the client on disk.
# type: bool
@@ -1485,7 +1485,7 @@
# profiler.default_report_format = txt
# The file path relative to your worldpath in which profiles will be saved to.
-#
+#
# type: string
# profiler.report_path = ""
diff --git a/src/client.h b/src/client.h
index a7eb22ad9..b479062a0 100644
--- a/src/client.h
+++ b/src/client.h
@@ -499,6 +499,9 @@ public:
u8 getProtoVersion()
{ return m_proto_ver; }
+ bool connectedToServer()
+ { return m_con.Connected(); }
+
float mediaReceiveProgress();
void afterContentReceived(IrrlichtDevice *device);
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 42b232afc..7c6f7ef3d 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -190,7 +190,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("minimap_shape_round", "true");
settings->setDefault("minimap_double_scan_height", "true");
- settings->setDefault("send_pre_v25_init", "true");
+ settings->setDefault("send_pre_v25_init", "false");
settings->setDefault("curl_timeout", "5000");
settings->setDefault("curl_parallel_limit", "8");
diff --git a/src/game.cpp b/src/game.cpp
index 1a036d03a..5a3b10879 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2403,7 +2403,26 @@ bool Game::connectToServer(const std::string &playername,
wait_time += dtime;
// Only time out if we aren't waiting for the server we started
if ((*address != "") && (wait_time > 10)) {
- *error_message = "Connection timed out.";
+ bool sent_old_init = g_settings->getFlag("send_pre_v25_init");
+ // If no pre v25 init was sent, and no answer was received,
+ // but the low level connection could be established
+ // (meaning that we have a peer id), then we probably wanted
+ // to connect to a legacy server. In this case, tell the user
+ // to enable the option to be able to connect.
+ if (!sent_old_init &&
+ (client->getProtoVersion() == 0) &&
+ client->connectedToServer()) {
+ *error_message = "Connection failure: init packet not "
+ "recognized by server.\n"
+ "Most likely the server uses an old protocol version (<v25).\n"
+ "Please ask the server owner to update to 0.4.13 or later.\n"
+ "To still connect to the server in the meantime,\n"
+ "you can enable the 'send_pre_v25_init' setting by editing minetest.conf,\n"
+ "or by enabling the 'Client -> Network -> Support older Servers'\n"
+ "entry in the advanced settings menu.";
+ } else {
+ *error_message = "Connection timed out.";
+ }
errorstream << *error_message << std::endl;
break;
}