4 #include "helperfuncs.h"
7 /* $ModDesc: Provides support for unreal-style channel mode +z */
13 class SSLMode : public ModeHandler
16 SSLMode(InspIRCd* Instance) : ModeHandler(Instance, 'z', 0, 0, false, MODETYPE_CHANNEL, false) { }
18 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
22 if (!channel->IsModeSet('z'))
26 CUList* userlist = channel->GetUsers();
27 for(CUList::iterator i = userlist->begin(); i != userlist->end(); i++)
29 if(!i->second->GetExt("ssl", dummy))
31 source->WriteServ("490 %s %s :all members of the channel must be connected via SSL", source->nick, channel->name);
32 return MODEACTION_DENY;
36 channel->SetMode('z',true);
37 return MODEACTION_ALLOW;
41 return MODEACTION_DENY;
46 if (channel->IsModeSet('z'))
48 channel->SetMode('z',false);
49 return MODEACTION_ALLOW;
52 return MODEACTION_DENY;
57 class ModuleSSLModes : public Module
63 ModuleSSLModes(InspIRCd* Me)
68 sslm = new SSLMode(ServerInstance);
69 ServerInstance->AddMode(sslm, 'z');
72 void Implements(char* List)
74 List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
77 virtual void On005Numeric(std::string &output)
79 ServerInstance->Modes->InsertMode(output, "z", 4);
82 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
84 if(chan && chan->IsModeSet('z'))
86 if(user->GetExt("ssl", dummy))
94 user->WriteServ( "489 %s %s :Cannot join channel (+z)", user->nick, cname);
102 virtual ~ModuleSSLModes()
107 virtual Version GetVersion()
109 return Version(1, 0, 0, 0, VF_STATIC | VF_VENDOR);
114 class ModuleSSLModesFactory : public ModuleFactory
117 ModuleSSLModesFactory()
121 ~ModuleSSLModesFactory()
125 virtual Module* CreateModule(InspIRCd* Me)
127 return new ModuleSSLModes(Me);
133 extern "C" void * init_module( void )
135 return new ModuleSSLModesFactory;