4 #include "helperfuncs.h"
6 /* $ModDesc: Provides support for unreal-style channel mode +z */
8 class SSLMode : public ModeHandler
11 SSLMode() : ModeHandler('z', 0, 0, false, MODETYPE_CHANNEL, false) { }
13 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
17 if (!channel->IsModeSet('z'))
19 chanuserlist userlist = Srv->GetUsers(channel);
20 for(unsigned int i = 0; i < userlist.size(); i++)
22 if(!userlist[i]->GetExt("ssl"))
24 WriteServ(source->fd, "490 %s %s :all members of the channel must be connected via SSL", source->nick, channel->name);
25 return MODEACTION_DENY;
28 return MODEACTION_ALLOW;
32 return MODEACTION_DENY;
37 (channel->IsModeSet('z')) ? return MODEACTION_DENY : return MODEACTION_ALLOW;
42 class ModuleSSLModes : public Module
48 ModuleSSLModes(Server* Me)
54 Srv->AddMode(sslm, 'z');
57 void Implements(char* List)
59 List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
62 virtual void On005Numeric(std::string &output)
64 InsertMode(output, "z", 4);
67 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
69 if(chan && chan->IsModeSet('z'))
71 if(user->GetExt("ssl"))
79 WriteServ(user->fd, "489 %s %s :Cannot join channel (+z)", user->nick, cname);
87 virtual ~ModuleSSLModes()
92 virtual Version GetVersion()
94 return Version(1, 0, 0, 0, VF_STATIC | VF_VENDOR);
99 class ModuleSSLModesFactory : public ModuleFactory
102 ModuleSSLModesFactory()
106 ~ModuleSSLModesFactory()
110 virtual Module* CreateModule(Server* Me)
112 return new ModuleSSLModes(Me);
118 extern "C" void * init_module( void )
120 return new ModuleSSLModesFactory;