Permalink
Browse files

Updated core from 1.2 to 1.2-1.3, fixed logic on addind/removing mode…

…. Removed duplicate code.
  • Loading branch information...
Shawn-Smith committed Jun 8, 2012
1 parent b213f18 commit ce2e12ef7bb7b7cd4841640ccd9504f23310a979
Showing with 10 additions and 29 deletions.
  1. +10 −29 1.2/m_sslumode.cpp
View
@@ -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;
@@ -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;
@@ -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);
}
@@ -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()

0 comments on commit ce2e12e

Please sign in to comment.