mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-24 09:59:02 -04:00
Fixed sslmodes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4216 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
2326b99e36
commit
7aaae3c842
@ -5,21 +5,58 @@
|
|||||||
|
|
||||||
/* $ModDesc: Provides support for unreal-style channel mode +z */
|
/* $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 ¶meter, 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
|
class ModuleSSLModes : public Module
|
||||||
{
|
{
|
||||||
Server *Srv;
|
Server *Srv;
|
||||||
|
SSLMode* sslm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModuleSSLModes(Server* Me)
|
ModuleSSLModes(Server* Me)
|
||||||
: Module::Module(Me)
|
: Module::Module(Me)
|
||||||
{
|
{
|
||||||
Srv = Me;
|
Srv = Me;
|
||||||
Srv->AddExtendedMode('z', MT_CHANNEL, false, 0, 0);
|
|
||||||
|
sslm = new SSLMode();
|
||||||
|
Srv->AddMode(sslm, 'z');
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implements(char* List)
|
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)
|
virtual void On005Numeric(std::string &output)
|
||||||
@ -47,34 +84,9 @@ class ModuleSSLModes : public Module
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
|
|
||||||
{
|
|
||||||
// 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()
|
virtual ~ModuleSSLModes()
|
||||||
{
|
{
|
||||||
|
DELETE(sslm);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Version GetVersion()
|
virtual Version GetVersion()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user