Skip to content

Commit

Permalink
Updated core from 1.2 to 1.2-1.3, fixed logic on addind/removing mode…
Browse files Browse the repository at this point in the history
…. Removed duplicate code.
  • Loading branch information
HelixSpiral committed Jun 12, 2012
1 parent b213f18 commit ce2e12e
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions 1.2/m_sslumode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "inspircd.h"

/* $ModAuthor: Shawn Smith */
/* $ModAuthorMail: Shawn AT CriticalSecurity.net, Put [IRC] in subject line. */
/* $ModDepends: core 1.2 */
/* $ModAuthorMail: Shawn@inspircd.org */
/* $ModDepends: core 1.2-1.3 */
/* $ModDesc: Provides support for ssl-only queries and notices. (umode: z) */

static char* dummy;
Expand All @@ -33,15 +33,16 @@ class SSLModeUser : public ModeHandler

if (adding)
{
if (isSet)
/* Make sure user is on an ssl connection when setting */
if (!isSet && dest->GetExt("ssl", dummy))
{
dest->SetMode('z', true);
return MODEACTION_ALLOW;
}
}
else
{
if (!isSet)
if (isSet)
{
dest->SetMode('z', false);
return MODEACTION_ALLOW;
Expand All @@ -55,15 +56,15 @@ class SSLModeUser : public ModeHandler
class ModuleSSLModes : public Module
{

SSLModeUser* sslpm;
SSLModeUser* sslquery;

public:
ModuleSSLModes(InspIRCd* Me)
: Module(Me)
{


sslpm = new SSLModeUser(ServerInstance);
sslquery = new SSLModeUser(ServerInstance);
Implementation eventlist[] = { I_OnUserPreNotice, I_OnUserPreMessage };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
Expand Down Expand Up @@ -96,33 +97,13 @@ class ModuleSSLModes : public Module

virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if (target_type == TYPE_USER)
{
User* t = (User*)dest;
if (t->IsModeSet('z') && !ServerInstance->ULine(user->server))
{
if (!user->GetExt("ssl", dummy))
{
user->WriteNumeric(ERR_CANTSENDTOUSER, "%s %s :You are not permitted to send private messages to this user (+z set)", user->nick.c_str(), t->nick.c_str());
return 1;
}
}
else if (user->IsModeSet('z') && !ServerInstance->ULine(t->server))
{
if (t->GetExt("ssl", dummy))
{
user->WriteNumeric(ERR_CANTSENDTOUSER, "%s %s :You must remove usermode 'z' before you are able to send privates messages to a non-ssl user.", user->nick.c_str(), t->nick.c_str());
return 1;
}
}
}
return 0;
return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
}

virtual ~ModuleSSLModes()
{
ServerInstance->Modes->DelMode(sslpm);
delete sslpm;
ServerInstance->Modes->DelMode(sslquery);
delete sslquery;
}

virtual Version GetVersion()
Expand Down

0 comments on commit ce2e12e

Please sign in to comment.