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 /** Handle channel mode +z
28 class SSLMode : public ModeHandler
31 SSLMode(InspIRCd* Instance) : ModeHandler(Instance, 'z', 0, 0, false, MODETYPE_CHANNEL, false) { }
33 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 if (!channel->IsModeSet('z'))
41 CUList* userlist = channel->GetUsers();
42 for(CUList::iterator i = userlist->begin(); i != userlist->end(); i++)
44 if(!i->second->GetExt("ssl", dummy))
46 source->WriteServ("490 %s %s :all members of the channel must be connected via SSL", source->nick, channel->name);
47 return MODEACTION_DENY;
51 channel->SetMode('z',true);
52 return MODEACTION_ALLOW;
56 return MODEACTION_DENY;
61 if (channel->IsModeSet('z'))
63 channel->SetMode('z',false);
64 return MODEACTION_ALLOW;
67 return MODEACTION_DENY;
72 class ModuleSSLModes : public Module
78 ModuleSSLModes(InspIRCd* Me)
83 sslm = new SSLMode(ServerInstance);
84 ServerInstance->AddMode(sslm, 'z');
87 void Implements(char* List)
89 List[I_OnUserPreJoin] = 1;
92 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
94 if(chan && chan->IsModeSet('z'))
96 if(user->GetExt("ssl", dummy))
104 user->WriteServ( "489 %s %s :Cannot join channel (+z)", user->nick, cname);
112 virtual ~ModuleSSLModes()
114 ServerInstance->Modes->DelMode(sslm);
118 virtual Version GetVersion()
120 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
125 class ModuleSSLModesFactory : public ModuleFactory
128 ModuleSSLModesFactory()
132 ~ModuleSSLModesFactory()
136 virtual Module* CreateModule(InspIRCd* Me)
138 return new ModuleSSLModes(Me);
144 extern "C" void * init_module( void )
146 return new ModuleSSLModesFactory;