Mercurial > irccd
changeset 535:7e9bf74e0fd5
Irccd: fix invalid greetings
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 17 Nov 2017 21:01:23 +0100 |
parents | 2326a4dc39e6 |
children | 623cb5d831d2 |
files | libirccd/irccd/transport_client.hpp libirccd/irccd/transport_server.cpp libirccd/irccd/transport_server.hpp |
diffstat | 3 files changed, 25 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libirccd/irccd/transport_client.hpp Fri Nov 17 20:56:10 2017 +0100 +++ b/libirccd/irccd/transport_client.hpp Fri Nov 17 21:01:23 2017 +0100 @@ -62,6 +62,15 @@ */ using send_t = std::function<void (const boost::system::error_code&)>; + /** + * Client state. + */ + enum class state_t { + authenticating, //!< client is authenticating + ready, //!< client is ready + closing //!< client is closing + }; + protected: /** * Handler for do_recv. @@ -85,12 +94,7 @@ private: using output_t = std::deque<std::pair<std::string, send_t>>; - enum class state_t { - authenticating, - ready, - closing - } state_{state_t::authenticating}; - + state_t state_{state_t::authenticating}; input_t input_; output_t output_; transport_server& parent_;
--- a/libirccd/irccd/transport_server.cpp Fri Nov 17 20:56:10 2017 +0100 +++ b/libirccd/irccd/transport_server.cpp Fri Nov 17 21:01:23 2017 +0100 @@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "sysconfig.hpp" + #include <cassert> #include "transport_server.hpp" @@ -26,11 +28,8 @@ * transport_server::do_auth_check * ------------------------------------------------------------------ */ -bool transport_server::do_auth_check(std::shared_ptr<transport_client> client, - nlohmann::json message, - accept_t handler) +bool transport_server::do_auth_check(nlohmann::json message, accept_t handler) { - assert(client); assert(handler); auto command = message["command"]; @@ -61,7 +60,7 @@ client->recv([this, client, handler] (auto message, auto code) { if (code) handler(client, code); - if (do_auth_check(client, message, handler)) { + if (do_auth_check(message, handler)) { clients_.insert(client); client->set_state(transport_client::state_t::ready); handler(client, code); @@ -80,7 +79,16 @@ // TODO: update this in irccd. auto greetings = nlohmann::json({ - { "irccd", "3.0.0" } + { "program", "irccd" }, + { "major", IRCCD_VERSION_MAJOR }, + { "minor", IRCCD_VERSION_MINOR }, + { "patch", IRCCD_VERSION_PATCH }, +#if defined(HAVE_JS) + { "javascript", true }, +#endif +#if defined(HAVE_SSL) + { "ssl", true }, +#endif }); client->send(greetings, [this, client, handler] (auto code) {
--- a/libirccd/irccd/transport_server.hpp Fri Nov 17 20:56:10 2017 +0100 +++ b/libirccd/irccd/transport_server.hpp Fri Nov 17 21:01:23 2017 +0100 @@ -53,7 +53,7 @@ client_set_t clients_; std::string password_; - bool do_auth_check(std::shared_ptr<transport_client>, nlohmann::json, accept_t); + bool do_auth_check(nlohmann::json, accept_t); void do_auth(std::shared_ptr<transport_client>, accept_t); void do_greetings(std::shared_ptr<transport_client>, accept_t);