15 #ifndef SERVER_HPP_INCLUDED
16 #define SERVER_HPP_INCLUDED
26 #include <boost/scoped_ptr.hpp>
27 #include <boost/shared_array.hpp>
28 #include <boost/ptr_container/ptr_vector.hpp>
30 #include <boost/asio/signal_set.hpp>
38 server(
int port,
bool keep_alive,
const std::string& config_file,
size_t min_threads,
size_t max_threads);
60 const std::string& user,
const char* error_code =
"",
bool force_confirmation =
false);
121 std::deque<boost::shared_ptr<game>>
games() {
122 std::deque<boost::shared_ptr<game>>
result;
123 for(
const auto& iter : player_connections_.get<
game_t>())
124 if(result.empty() || iter.get_game() != result.back())
125 result.push_back(iter.get_game());
126 if(!result.empty() && result.front() == 0)
133 boost::asio::posix::stream_descriptor
input_;
205 typedef std::function<void(server*, const std::string&, const std::string&, std::string&, std::ostringstream *)>
cmd_handler;
config read_config() const
Read the server config from file 'config_file_'.
std::deque< boost::shared_ptr< game > > games()
void handle_nickserv(socket_ptr socket, simple_wml::node &nickserv)
void handle_whisper(socket_ptr socket, simple_wml::node &whisper)
void shut_down_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void serverside_handshake(socket_ptr socket)
simple_wml::document games_and_users_list_
std::deque< login_log >::size_type failed_login_buffer_size_
void handle_read_from_player(socket_ptr socket, boost::shared_ptr< simple_wml::document > doc)
void handle_version(socket_ptr socket)
void status_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
boost::asio::posix::stream_descriptor input_
server socket/fifo.
void games_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void handle_login(socket_ptr socket, boost::shared_ptr< simple_wml::document > doc)
static l_noret error(LoadState *S, const char *why)
bool operator==(const connection_log &c) const
void accept_connection(const boost::system::error_code &error, socket_ptr socket)
void kickban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void handle_query(socket_ptr socket, simple_wml::node &query)
void help_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void login(socket_ptr socket)
void wml_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
server(int port, bool keep_alive, const std::string &config_file, size_t min_threads, size_t max_threads)
boost::asio::signal_set sighup_
void stats_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
size_t default_max_messages_
void handle_read_from_fifo(const boost::system::error_code &error, std::size_t bytes_transferred)
void update_game_in_lobby(const wesnothd::game &g, const socket_ptr &exclude=socket_ptr())
void requests_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::vector< std::string > accepted_versions_
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
void ban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
Definitions for the interface to Wesnoth Markup Language (WML).
void handle_sighup(const boost::system::error_code &error, int signal_number)
boost::scoped_ptr< user_handler > user_handler_
void handle_create_game(socket_ptr socket, simple_wml::node &create_game)
void handle_termination(const boost::system::error_code &error, int signal_number)
bool ip_exceeds_connection_limit(const std::string &ip) const
bool deny_unregistered_login_
void handle_graceful_timeout(const boost::system::error_code &error)
void gban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
boost::asio::signal_set sigs_
simple_wml::document login_response_
bool allow_remote_shutdown_
std::map< std::string, config > proxy_versions_
login_log(std::string _ip, int _attempts, time_t _first_attempt)
void msg_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void add_player(socket_ptr socket, const wesnothd::player &)
void remove_player(socket_ptr socket)
void handle_handshake(const boost::system::error_code &error, socket_ptr socket, boost::shared_array< char > buf)
std::string restart_command
void clones_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void handle_player_in_lobby(socket_ptr socket, boost::shared_ptr< simple_wml::document > doc)
void read_version(socket_ptr socket, boost::shared_ptr< simple_wml::document > doc)
void handle_player_in_game(socket_ptr socket, boost::shared_ptr< simple_wml::document > doc)
boost::asio::deadline_timer timer_
void motd_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
GLenum GLuint GLsizei const char * buf
std::vector< std::string > tor_ip_list_
void bans_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void searchlog_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void request_version(const boost::system::error_code &error, socket_ptr socket)
union wesnothd::server::@25 handshake_response_
void send_password_request(socket_ptr socket, const std::string &msg, const std::string &user, const char *error_code="", bool force_confirmation=false)
std::string is_ip_banned(const std::string &ip) const
simple_wml::document version_query_response_
std::string replay_save_path_
void kick_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void clean_user_handler(const time_t &now)
size_t concurrent_connections_
void netstats_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
boost::uint32_t connection_num
size_t default_time_period_
bool player_is_in_game(socket_ptr socket) const
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
void send_server_message_to_all(const std::string &message, socket_ptr exclude=socket_ptr()) const
boost::asio::ip::tcp::acceptor acceptor_
void cleanup_game(game *)
void sample_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void dump_stats(const time_t &now)
connection_log(std::string _nick, std::string _ip, time_t _log_off)
void read_from_player(socket_ptr socket)
void unban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
const std::string config_file_
multi_index_container< player_record, indexed_by< ordered_unique< tag< socket_t >, BOOST_MULTI_INDEX_CONST_MEM_FUN(player_record, const socket_ptr, socket)>, hashed_unique< tag< name_t >, BOOST_MULTI_INDEX_CONST_MEM_FUN(player_record, const std::string &, name)>, ordered_non_unique< tag< game_t >, BOOST_MULTI_INDEX_CONST_MEM_FUN(player_record, int, game_id)> >> player_connections
bool operator==(const login_log &l) const
std::function< void(server *, const std::string &, const std::string &, std::string &, std::ostringstream *)> cmd_handler
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::string admin_passwd_
wesnothd::ban_manager ban_manager_
std::deque< login_log > failed_logins_
void adminmsg_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
std::map< std::string, config > redirected_versions_
void handle_message(socket_ptr socket, simple_wml::node &message)
void restart_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
boost::asio::io_service io_service_
std::map< long int, std::string > seeds_
void handle_join_game(socket_ptr socket, simple_wml::node &join)
void send_to_lobby(simple_wml::document &data, socket_ptr exclude=socket_ptr()) const
std::map< std::string, cmd_handler > cmd_handlers_
void dul_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
player_connections player_connections_
GLsizei GLenum GLuint GLuint GLsizei char * message
void load_config()
Parse the server config into local variables.
simple_wml::document join_lobby_response_
std::deque< connection_log > ip_log_
void ungban_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
boost::shared_ptr< boost::asio::ip::tcp::socket > socket_ptr
std::string process_command(std::string cmd, std::string issuer_name)
Process commands from admins and users.
void metrics_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
A config object defines a single node in a WML file, with access to child nodes.
void lobbymsg_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void pm_handler(const std::string &, const std::string &, std::string &, std::ostringstream *)
void create_game(player_record &host, simple_wml::node &create_game)
void send_server_message_to_lobby(const std::string &message, socket_ptr exclude=socket_ptr()) const
GLsizei const GLcharARB ** string
time_t last_user_seen_time_
boost::asio::streambuf admin_cmd_
std::vector< std::string > disallowed_names_