1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
22 /* $ModDesc: Provides support for unreal-style channel mode +z */
26 class SSLMode : public ModeHandler
29 SSLMode(InspIRCd* Instance) : ModeHandler(Instance, 'z', 0, 0, false, MODETYPE_CHANNEL, false) { }
31 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
35 if (!channel->IsModeSet('z'))
39 CUList* userlist = channel->GetUsers();
40 for(CUList::iterator i = userlist->begin(); i != userlist->end(); i++)
42 if(!i->second->GetExt("ssl", dummy))
44 source->WriteServ("490 %s %s :all members of the channel must be connected via SSL", source->nick, channel->name);
45 return MODEACTION_DENY;
49 channel->SetMode('z',true);
50 return MODEACTION_ALLOW;
54 return MODEACTION_DENY;
59 if (channel->IsModeSet('z'))
61 channel->SetMode('z',false);
62 return MODEACTION_ALLOW;
65 return MODEACTION_DENY;
70 class ModuleSSLModes : public Module
76 ModuleSSLModes(InspIRCd* Me)
81 sslm = new SSLMode(ServerInstance);
82 ServerInstance->AddMode(sslm, 'z');
85 void Implements(char* List)
87 List[I_OnUserPreJoin] = 1;
90 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
92 if(chan && chan->IsModeSet('z'))
94 if(user->GetExt("ssl", dummy))
102 user->WriteServ( "489 %s %s :Cannot join channel (+z)", user->nick, cname);
110 virtual ~ModuleSSLModes()
112 ServerInstance->Modes->DelMode(sslm);
116 virtual Version GetVersion()
118 return Version(1, 0, 0, 0, VF_COMMON | VF_VENDOR);
123 class ModuleSSLModesFactory : public ModuleFactory
126 ModuleSSLModesFactory()
130 ~ModuleSSLModesFactory()
134 virtual Module* CreateModule(InspIRCd* Me)
136 return new ModuleSSLModes(Me);
142 extern "C" void * init_module( void )
144 return new ModuleSSLModesFactory;