28 #include <boost/asio/steady_timer.hpp>
39 server(
int port,
bool keep_alive,
const std::string& config_file);
52 template<
class SocketPtr>
void login_client(boost::asio::yield_context yield, SocketPtr socket);
53 template<
class SocketPtr>
bool is_login_allowed(boost::asio::yield_context yield, SocketPtr socket,
const simple_wml::node*
const login,
const std::string& username,
bool& registered,
bool& is_moderator);
54 template<
class SocketPtr>
bool authenticate(SocketPtr socket,
const std::string& username,
const std::string& password,
bool name_taken,
bool& registered);
55 template<
class SocketPtr>
void send_password_request(SocketPtr socket,
const std::string&
msg,
const char* error_code =
"",
bool force_confirmation =
false);
72 template<
class SocketPtr>
void send_server_message(SocketPtr socket,
const std::string& message,
const std::string&
type);
90 return player->get_game() !=
nullptr;
99 std::chrono::system_clock::time_point
log_off;
104 return c.nick ==
nick &&
c.ip ==
ip;
185 std::deque<std::shared_ptr<game>>
games()
const
187 std::deque<std::shared_ptr<game>> result;
190 if(result.empty() || iter.get_game() != result.back()) {
191 result.push_back(iter.get_game());
195 if(!result.empty() && result.front() ==
nullptr) {
204 void dump_stats(
const boost::system::error_code& ec);
213 void delete_game(
int,
const std::string& reason=
"");
225 typedef std::function<void(
const std::string&,
const std::string&, std::string&, std::ostringstream *)>
cmd_handler;
228 void shut_down_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
229 void restart_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
230 void sample_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
231 void help_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
232 void stats_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
233 void metrics_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
234 void requests_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
235 void roll_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
236 void games_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
237 void wml_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
238 void adminmsg_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
239 void pm_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
240 void version_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
241 void msg_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
242 void lobbymsg_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
243 void status_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
244 void clones_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
245 void bans_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
246 void ban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
247 void unban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
248 void ungban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
249 void kick_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
250 void kickban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
251 void gban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
252 void motd_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
253 void searchlog_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
254 void dul_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
255 void stopgame(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
258 void handle_sighup(
const boost::system::error_code& error,
int signal_number);
A config object defines a single node in a WML file, with access to child nodes.
Base class for implementing servers that use gzipped-WML network protocol.
void async_send_doc_queued(SocketPtr socket, simple_wml::document &doc)
High level wrapper for sending a WML document.
void send_to_lobby(simple_wml::document &data, utils::optional< player_iterator > exclude={})
std::unique_ptr< user_handler > user_handler_
const std::string config_file_
boost::asio::steady_timer dummy_player_timer_
void handle_message(player_iterator player, simple_wml::node &message)
void searchlog_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::vector< std::string > disallowed_names_
void clones_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void ban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void start_dummy_player_updates()
std::string input_path_
server socket/fifo.
void unban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::map< std::string, config > proxy_versions_
void handle_new_client(tls_socket_ptr socket)
void handle_sighup(const boost::system::error_code &error, int signal_number)
int dummy_player_timer_interval_
void stats_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void delete_game(int, const std::string &reason="")
void refresh_tournaments(const boost::system::error_code &ec)
std::string recommended_version_
void gban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void pm_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::function< void(const std::string &, const std::string &, std::string &, std::ostringstream *)> cmd_handler
void adminmsg_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void start_tournaments_timer()
std::string replay_save_path_
void handle_query(player_iterator player, simple_wml::node &query)
void handle_player_in_game(player_iterator player, simple_wml::document &doc)
std::string restart_command
void lobbymsg_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
bool ip_exceeds_connection_limit(const std::string &ip) const
std::chrono::seconds failed_login_ban_
void handle_graceful_timeout(const boost::system::error_code &error)
void cleanup_game(game *)
void handle_whisper(player_iterator player, simple_wml::node &whisper)
bool is_login_allowed(boost::asio::yield_context yield, SocketPtr socket, const simple_wml::node *const login, const std::string &username, bool ®istered, bool &is_moderator)
void handle_new_client(socket_ptr socket)
void status_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::string announcements_
std::deque< connection_log > ip_log_
void bans_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void kick_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void dul_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void handle_join_game(player_iterator player, simple_wml::node &join)
std::deque< login_log >::size_type failed_login_buffer_size_
void wml_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void send_server_message(SocketPtr socket, const std::string &message, const std::string &type)
void handle_player(boost::asio::yield_context yield, SocketPtr socket, player_iterator player)
player_connections player_connections_
simple_wml::document games_and_users_list_
void help_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void requests_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void dump_stats(const boost::system::error_code &ec)
void remove_player(player_iterator player)
boost::asio::steady_timer timer_
void handle_read_from_fifo(const boost::system::error_code &error, std::size_t bytes_transferred)
server(int port, bool keep_alive, const std::string &config_file)
simple_wml::document login_response_
boost::asio::steady_timer tournaments_timer_
std::string is_ip_banned(const std::string &ip)
std::set< std::string > client_sources_
bool player_is_in_game(player_iterator player) const
void abort_lan_server_timer()
void send_server_message(player_iterator player, const std::string &message, const std::string &type)
void handle_lan_server_shutdown(const boost::system::error_code &error)
bool authenticate(SocketPtr socket, const std::string &username, const std::string &password, bool name_taken, bool ®istered)
std::string admin_passwd_
void motd_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void load_config()
Parse the server config into local variables.
bool deny_unregistered_login_
std::vector< std::string > accepted_versions_
std::chrono::seconds lan_server_
void dummy_player_updates(const boost::system::error_code &ec)
void handle_create_game(player_iterator player, simple_wml::node &create_game)
void send_server_message_to_lobby(const std::string &message, utils::optional< player_iterator > exclude={})
void kickban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void send_server_message_to_all(const std::string &message, utils::optional< player_iterator > exclude={})
void handle_nickserv(player_iterator player, simple_wml::node &nickserv)
std::string process_command(std::string cmd, std::string issuer_name)
Process commands from admins and users.
void login_client(boost::asio::yield_context yield, SocketPtr socket)
void stopgame(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::deque< login_log > failed_logins_
std::size_t default_max_messages_
std::size_t max_ip_log_size_
void restart_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void msg_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
boost::asio::steady_timer lan_server_timer_
void shut_down_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::map< std::string, config > redirected_versions_
void metrics_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::map< std::string, cmd_handler > cmd_handlers_
void send_to_player(player_iterator player, simple_wml::document &data)
void update_game_in_lobby(const game &g, utils::optional< player_iterator > exclude={})
wesnothd::ban_manager ban_manager_
config read_config() const
Read the server config from file 'config_file_'.
bool accepting_connections() const
boost::asio::steady_timer dump_stats_timer_
void handle_player_in_lobby(player_iterator player, simple_wml::document &doc)
std::vector< std::string > tor_ip_list_
void roll_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void games_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::deque< std::shared_ptr< game > > games() const
simple_wml::document version_query_response_
void version_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::size_t concurrent_connections_
void send_password_request(SocketPtr socket, const std::string &msg, const char *error_code="", bool force_confirmation=false)
void sample_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void start_lan_server_timer()
void disconnect_player(player_iterator player)
bool allow_remote_shutdown_
void ungban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::chrono::seconds default_time_period_
Definitions for the interface to Wesnoth Markup Language (WML).
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
player_connections::const_iterator player_iterator
bmi::multi_index_container< player_record, bmi::indexed_by< bmi::ordered_unique< bmi::tag< socket_t >, bmi::const_mem_fun< player_record, const any_socket_ptr, &player_record::socket > >, bmi::hashed_unique< bmi::tag< name_t >, bmi::const_mem_fun< player_record, const std::string &, &player_record::name > >, bmi::ordered_non_unique< bmi::tag< game_t >, bmi::const_mem_fun< player_record, int, &player_record::game_id > > > > player_connections
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Base class for servers using Wesnoth's WML over TCP protocol.
std::shared_ptr< boost::asio::ssl::stream< socket_ptr::element_type > > tls_socket_ptr
std::shared_ptr< boost::asio::ip::tcp::socket > socket_ptr
bool operator==(const connection_log &c) const
std::chrono::system_clock::time_point log_off
bool operator==(const login_log &l) const
std::chrono::steady_clock::time_point first_attempt