1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 /* $ModDesc: Provides support for unreal-style channel mode +z */
23 /** Handle channel mode +z
25 class SSLMode : public ModeHandler
28 SSLMode(InspIRCd* Instance) : ModeHandler(Instance, 'z', 0, 0, false, MODETYPE_CHANNEL, false) { }
30 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
34 if (!channel->IsModeSet('z'))
38 CUList* userlist = channel->GetUsers();
39 for(CUList::iterator i = userlist->begin(); i != userlist->end(); i++)
41 if(!i->second->GetExt("ssl", dummy))
43 source->WriteServ("490 %s %s :all members of the channel must be connected via SSL", source->nick, channel->name);
44 return MODEACTION_DENY;
48 channel->SetMode('z',true);
49 return MODEACTION_ALLOW;
53 return MODEACTION_DENY;
58 if (channel->IsModeSet('z'))
60 channel->SetMode('z',false);
61 return MODEACTION_ALLOW;
64 return MODEACTION_DENY;
69 class ModuleSSLModes : public Module
75 ModuleSSLModes(InspIRCd* Me)
80 sslm = new SSLMode(ServerInstance);
81 if (!ServerInstance->AddMode(sslm, 'z'))
82 throw ModuleException("Could not add new modes!");
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, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
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;