summaryrefslogtreecommitdiff
path: root/src/modules/m_sslmodes.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 14:04:07 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 14:04:07 +0000
commit7aaae3c8425cbe963947f12092742d9044a36dac (patch)
tree3ebcc06731851f45bb2b346f750a496d3b9ae168 /src/modules/m_sslmodes.cpp
parent2326b99e3610bd22fb7079ae43fda9b84c1498d7 (diff)
Fixed sslmodes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4216 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_sslmodes.cpp')
-rw-r--r--src/modules/m_sslmodes.cpp68
1 files changed, 40 insertions, 28 deletions
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp
index ed9d55671..b97f099b9 100644
--- a/src/modules/m_sslmodes.cpp
+++ b/src/modules/m_sslmodes.cpp
@@ -5,21 +5,58 @@
/* $ModDesc: Provides support for unreal-style channel mode +z */
+class SSLMode : public ModeHandler
+{
+ public:
+ SSLMode() : ModeHandler('z', 0, 0, false, MODETYPE_CHANNEL, false) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+ {
+ if (adding)
+ {
+ if (!channel->IsModeSet('z'))
+ {
+ chanuserlist userlist = Srv->GetUsers(channel);
+ for(unsigned int i = 0; i < userlist.size(); i++)
+ {
+ if(!userlist[i]->GetExt("ssl"))
+ {
+ WriteServ(source->fd, "490 %s %s :all members of the channel must be connected via SSL", source->nick, channel->name);
+ return MODEACTION_DENY;
+ }
+ }
+ return MODEACTION_ALLOW;
+ }
+ else
+ {
+ return MODEACTION_DENY;
+ }
+ }
+ else
+ {
+ (channel->IsModeSet('z')) ? return MODEACTION_DENY : return MODEACTION_ALLOW;
+ }
+ }
+};
+
class ModuleSSLModes : public Module
{
Server *Srv;
+ SSLMode* sslm;
public:
ModuleSSLModes(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddExtendedMode('z', MT_CHANNEL, false, 0, 0);
+
+ sslm = new SSLMode();
+ Srv->AddMode(sslm, 'z');
}
void Implements(char* List)
{
- List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
+ List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
}
virtual void On005Numeric(std::string &output)
@@ -46,35 +83,10 @@ class ModuleSSLModes : public Module
return 0;
}
-
- virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
- {
- // check if this is our mode character...
- if ((modechar == 'z') && (type == MT_CHANNEL))
- {
- chanrec* chan = (chanrec*)target;
-
- chanuserlist userlist = Srv->GetUsers(chan);
-
- for(unsigned int i = 0; i < userlist.size(); i++)
- {
- if(!userlist[i]->GetExt("ssl"))
- {
- WriteServ(user->fd, "490 %s %s :all members of the channel must be connected via SSL", user->nick, chan->name);
- return 0;
- }
- }
-
- return 1;
- }
- else
- {
- return 0;
- }
- }
virtual ~ModuleSSLModes()
{
+ DELETE(sslm);
}
virtual Version GetVersion()