From 5b2afce715d7177b0981d3d60f87b6ce6a5a7ee5 Mon Sep 17 00:00:00 2001 From: om Date: Sun, 22 Jan 2006 23:33:40 +0000 Subject: Initial commit of m_sslmodes, supplying chanmode +z git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2846 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_sslmodes.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/modules/m_sslmodes.cpp (limited to 'src/modules') diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp new file mode 100644 index 000000000..3d5074c70 --- /dev/null +++ b/src/modules/m_sslmodes.cpp @@ -0,0 +1,109 @@ +#include "users.h" +#include "channels.h" +#include "modules.h" +#include "helperfuncs.h" + +/* $ModDesc: Provides support for unreal-style channel mode +z */ + +class ModuleSSLModes : public Module +{ + Server *Srv; + + public: + ModuleSSLModes(Server* Me) + : Module::Module(Me) + { + Srv = Me; + Srv->AddExtendedMode('z', MT_CHANNEL, false, 0, 0); + } + + void Implements(char* List) + { + List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreJoin] = 1; + } + + virtual void On005Numeric(std::string &output) + { + output.insert(output.find(" ", output.find("CHANMODES=", 0)), "z"); + } + + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) + { + if(chan && chan->IsCustomModeSet('z')) + { + if(user->GetExt("ssl")) + { + // Let them in + return 0; + } + else + { + // Deny + WriteServ(user->fd, "489 %s %s :Cannot join channel (+z)", user->nick, cname); + return 1; + } + } + + return 0; + } + + virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) + { + // check if this is our mode character... + if ((modechar == 'z') && (type == MT_CHANNEL)) + { + chanrec* chan = (chanrec*)target; + + chanuserlist userlist = Srv->GetUsers(chan); + + for(unsigned int i = 0; i < userlist.size(); i++) + { + if(!userlist[i]->GetExt("ssl")) + { + WriteServ(user->fd, "974 %s z :all members must be connected via SSL", user->nick); + return 0; + } + } + + return 1; + } + else + { + return 0; + } + } + + virtual ~ModuleSSLModes() + { + } + + virtual Version GetVersion() + { + return Version(1, 0, 0, 0, VF_STATIC | VF_VENDOR); + } +}; + + +class ModuleSSLModesFactory : public ModuleFactory +{ + public: + ModuleSSLModesFactory() + { + } + + ~ModuleSSLModesFactory() + { + } + + virtual Module* CreateModule(Server* Me) + { + return new ModuleSSLModes(Me); + } + +}; + + +extern "C" void * init_module( void ) +{ + return new ModuleSSLModesFactory; +} -- cgit v1.2.3