29 #include <boost/asio/steady_timer.hpp>
40 server(
int port,
bool keep_alive,
const std::string& config_file);
53 template<
class SocketPtr>
void login_client(boost::asio::yield_context yield, SocketPtr socket);
54 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);
55 template<
class SocketPtr>
bool authenticate(SocketPtr socket,
const std::string& username,
const std::string& password,
bool name_taken,
bool& registered);
56 template<
class SocketPtr>
void send_password_request(SocketPtr socket,
const std::string&
msg,
const char* error_code =
"",
bool force_confirmation =
false);
73 template<
class SocketPtr>
void send_server_message(SocketPtr socket,
const std::string& message,
const std::string&
type);
100 return player->get_game() !=
nullptr;
109 std::chrono::system_clock::time_point
log_off;
114 return c.nick ==
nick &&
c.ip ==
ip;
185 utils::optional<server_base::login_ban_info>
is_ip_banned(
const std::string& ip);
195 std::deque<std::shared_ptr<game>>
games()
const
197 std::deque<std::shared_ptr<game>> result;
200 if(result.empty() || iter.get_game() != result.back()) {
201 result.push_back(iter.get_game());
205 if(!result.empty() && result.front() ==
nullptr) {
214 void dump_stats(
const boost::system::error_code& ec);
223 void delete_game(
int,
const std::string& reason=
"");
235 typedef std::function<void(
const std::string&,
const std::string&, std::string&, std::ostringstream *)>
cmd_handler;
238 void shut_down_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
239 void restart_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
240 void sample_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
241 void help_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
242 void stats_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
243 void metrics_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
244 void requests_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
245 void roll_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
246 void games_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
247 void wml_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
248 void adminmsg_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
249 void pm_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
250 void version_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
251 void msg_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
252 void lobbymsg_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
253 void status_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
254 void clones_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
255 void bans_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
256 void ban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
257 void unban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
258 void ungban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
259 void kick_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
260 void kickban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
261 void gban_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
262 void motd_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
263 void searchlog_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
264 void dul_handler(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
265 void stopgame(
const std::string &,
const std::string &, std::string &, std::ostringstream *);
268 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_player(any_socket_ptr socket, simple_wml::document &data)
utils::optional< server_base::login_ban_info > is_ip_banned(const std::string &ip)
void update_game_in_lobby(game &g, utils::optional< player_iterator > exclude={})
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)
void stats_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::chrono::seconds dummy_player_timer_interval_
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::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)
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
utils::variant< socket_ptr, tls_socket_ptr > any_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