1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
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) && !ServerInstance->ULine(i->first->server))
40 source->WriteNumeric(ERR_ALLMUSTSSL, "%s %s :all members of the channel must be connected via SSL", source->nick.c_str(), channel->name.c_str());
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->Modes->AddMode(sslm))
79 throw ModuleException("Could not add new modes!");
80 Implementation eventlist[] = { I_OnUserPreJoin };
81 ServerInstance->Modules->Attach(eventlist, this, 1);
85 virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
87 if(chan && chan->IsModeSet('z'))
89 if(user->GetExt("ssl", dummy))
97 user->WriteServ( "489 %s %s :Cannot join channel; SSL users only (+z)", user->nick.c_str(), cname);
105 virtual ~ModuleSSLModes()
107 ServerInstance->Modes->DelMode(sslm);
111 virtual Version GetVersion()
113 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
118 MODULE_INIT(ModuleSSLModes)