summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-22 23:33:40 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-22 23:33:40 +0000
commit5b2afce715d7177b0981d3d60f87b6ce6a5a7ee5 (patch)
tree840fc9dcccb568f8fbc511ef32aafb5f3a039ccf
parent6a558db9a8a53bf1384365e475a7d6bab1078019 (diff)
Initial commit of m_sslmodes, supplying chanmode +z
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2846 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_sslmodes.cpp109
1 files changed, 109 insertions, 0 deletions
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 &params)
+ {
+ // 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;
+}