Skip to content

Commit

Permalink
add server notifications about outdated wesnoth versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed Jul 31, 2018
1 parent f84d79e commit 610e4f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/server/server.cpp
Expand Up @@ -31,6 +31,7 @@
#include "serialization/unicode.hpp"
#include "utils/functional.hpp"
#include "utils/iterable_pair.hpp"
#include "version.hpp"

#include "server/ban.hpp"
#include "server/game.hpp"
Expand Down Expand Up @@ -84,6 +85,7 @@ namespace wesnothd
{
// we take profiling info on every n requests
int request_sample_frequency = 1;
version_info secure_version = version_info("1.14.4");

static void make_add_diff(
const simple_wml::node& src, const char* gamelist, const char* type, simple_wml::document& out, int index = -1)
Expand Down Expand Up @@ -489,6 +491,7 @@ void server::load_config()
// remember to make new one as a daemon or it will block old one
restart_command = cfg_["restart_command"].str();

recommended_version_ = cfg_["recommended_version"].str();
accepted_versions_.clear();
const std::string& versions = cfg_["versions_accepted"];
if(versions.empty() == false) {
Expand Down Expand Up @@ -985,6 +988,12 @@ void server::add_player(socket_ptr socket, const wesnothd::player& player)
if(!motd_.empty()) {
send_server_message(socket, motd_);
}
if(version_info(player.version()) < secure_version ){
send_server_message(socket, "you are using version " + player.version() + " which has known security issues that can be used to invade your computer. We strongly reccomend to update to a newer wesnoth version");
}
if(version_info(player.version()) < version_info(recommended_version_)) {
send_server_message(socket, "A new version wesnoth " + recommended_version_ + " is out!");
}

read_from_player(socket);

Expand Down
1 change: 1 addition & 0 deletions src/server/server.hpp
Expand Up @@ -132,6 +132,7 @@ class server : public server_base

// settings from the server config
std::vector<std::string> accepted_versions_;
std::string recommended_version_;
std::map<std::string,config> redirected_versions_;
std::map<std::string,config> proxy_versions_;
std::vector<std::string> disallowed_names_;
Expand Down

0 comments on commit 610e4f2

Please sign in to comment.