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 * ---------------------------------------------------
16 /* $ModDesc: Provides support for unreal-style channel mode +z */
20 /** Handle channel mode +z
22 class SSLMode : public ModeHandler
25 SSLMode(InspIRCd* Instance) : ModeHandler(Instance, 'z', 0, 0, false, MODETYPE_CHANNEL, false) { }
27 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
31 if (!channel->IsModeSet('z'))
35 CUList* userlist = channel->GetUsers();
36 for(CUList::iterator i = userlist->begin(); i != userlist->end(); i++)
38 if(!i->first->GetExt("ssl", dummy))
40 source->WriteServ("490 %s %s :all members of the channel must be connected via SSL", source->nick, channel->name);
41 return MODEACTION_DENY;
45 channel->SetMode('z',true);
46 return MODEACTION_ALLOW;
50 return MODEACTION_DENY;
55 if (channel->IsModeSet('z'))
57 channel->SetMode('z',false);
58 return MODEACTION_ALLOW;
61 return MODEACTION_DENY;
66 class ModuleSSLModes : public Module
72 ModuleSSLModes(InspIRCd* Me)
77 sslm = new SSLMode(ServerInstance);
78 if (!ServerInstance->AddMode(sslm, 'z'))
79 throw ModuleException("Could not add new modes!");
82 void Implements(char* List)
84 List[I_OnUserPreJoin] = 1;
87 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
89 if(chan && chan->IsModeSet('z'))
91 if(user->GetExt("ssl", dummy))
99 user->WriteServ( "489 %s %s :Cannot join channel; SSL users only (+z)", user->nick, cname);
107 virtual ~ModuleSSLModes()
109 ServerInstance->Modes->DelMode(sslm);
113 virtual Version GetVersion()
115 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
120 class ModuleSSLModesFactory : public ModuleFactory
123 ModuleSSLModesFactory()
127 ~ModuleSSLModesFactory()
131 virtual Module* CreateModule(InspIRCd* Me)
133 return new ModuleSSLModes(Me);
139 extern "C" DllExport void * init_module( void )
141 return new ModuleSSLModesFactory;