From 3eb205218a321e454d873ae14e2e717ce9d64142 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 16 Apr 2014 13:08:44 +0200 Subject: m_spanningtree Throw an exception on protocol violations instead of returning CMD_INVALID Catch CoreExceptions, log and close the link in OnDataReady() --- src/modules/m_spanningtree/servercommand.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/modules/m_spanningtree/servercommand.h') diff --git a/src/modules/m_spanningtree/servercommand.h b/src/modules/m_spanningtree/servercommand.h index 156b405e4..f99942079 100644 --- a/src/modules/m_spanningtree/servercommand.h +++ b/src/modules/m_spanningtree/servercommand.h @@ -22,6 +22,15 @@ #include "utils.h" #include "treeserver.h" +class ProtocolException : public ModuleException +{ + public: + ProtocolException(const std::string& msg) + : ModuleException("Protocol violation: " + msg) + { + } +}; + /** Base class for server-to-server commands that may have a (remote) user source or server source. */ class ServerCommand : public CommandBase @@ -47,7 +56,7 @@ class UserOnlyServerCommand : public ServerCommand { RemoteUser* remoteuser = IS_REMOTE(user); if (!remoteuser) - return CMD_INVALID; + throw ProtocolException("Invalid source"); return static_cast(this)->HandleRemote(remoteuser, parameters); } }; @@ -65,7 +74,7 @@ class ServerOnlyServerCommand : public ServerCommand CmdResult Handle(User* user, std::vector& parameters) { if (!IS_SERVER(user)) - return CMD_INVALID; + throw ProtocolException("Invalid source"); TreeServer* server = TreeServer::Get(user); return static_cast(this)->HandleServer(server, parameters); } -- cgit v1.3.1-10-gc9f91