/*
* InspIRCd -- Internet Relay Chat Daemon
*
+ * Copyright (C) 2012 Shawn Smith <shawn@inspircd.org>
* Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
* Copyright (C) 2006-2008 Robin Burchell <robin+git@viroteck.net>
* Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
*/
+/* $ModDesc: Provides support for ircu-style services accounts, including chmode +R, etc. */
+
#include "inspircd.h"
#include "account.h"
-/* $ModDesc: Povides support for ircu-style services accounts, including chmode +R, etc. */
-
/** Channel mode +r - mark a channel as identified
*/
class Channel_r : public ModeHandler
if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
{
// Only change the mode if it's not redundant
- if ((adding && !channel->IsModeSet('r')) || (!adding && channel->IsModeSet('r')))
+ if ((adding != channel->IsModeSet('r')))
{
channel->SetMode('r',adding);
return MODEACTION_ALLOW;
}
-
- return MODEACTION_DENY;
}
else
{
source->WriteNumeric(500, "%s :Only a server may modify the +r channel mode", source->nick.c_str());
- return MODEACTION_DENY;
}
+ return MODEACTION_DENY;
}
};
{
if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server))
{
- if ((adding && !dest->IsModeSet('r')) || (!adding && dest->IsModeSet('r')))
+ if ((adding != dest->IsModeSet('r')))
{
dest->SetMode('r',adding);
return MODEACTION_ALLOW;
}
- return MODEACTION_DENY;
}
else
{
source->WriteNumeric(500, "%s :Only a server may modify the +r user mode", source->nick.c_str());
- return MODEACTION_DENY;
}
+ return MODEACTION_DENY;
}
};
void On005Numeric(std::string &t)
{
ServerInstance->AddExtBanChar('R');
+ ServerInstance->AddExtBanChar('U');
}
/* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
if (c->IsModeSet('M') && !is_registered && res != MOD_RES_ALLOW)
{
// user messaging a +M channel and is not registered
- user->WriteNumeric(477, ""+std::string(user->nick)+" "+std::string(c->name)+" :You need to be identified to a registered account to message this channel");
+ user->WriteNumeric(477, user->nick+" "+c->name+" :You need to be identified to a registered account to message this channel");
return MOD_RES_DENY;
}
}
ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask)
{
- if (mask[0] == 'R' && mask[1] == ':')
+ static bool checking = false;
+ if (checking)
+ return MOD_RES_PASSTHRU;
+
+ if ((mask.length() > 2) && (mask[1] == ':'))
{
- std::string *account = accountname.get(user);
- if (account && InspIRCd::Match(*account, mask.substr(2)))
- return MOD_RES_DENY;
+ if (mask[0] == 'R')
+ {
+ std::string *account = accountname.get(user);
+ if (account && InspIRCd::Match(*account, mask.substr(2)))
+ return MOD_RES_DENY;
+ }
+ else if (mask[0] == 'U')
+ {
+ std::string *account = accountname.get(user);
+ /* If the user is registered we don't care. */
+ if (account)
+ return MOD_RES_PASSTHRU;
+
+ /* If we made it this far we know the user isn't registered
+ so just deny if it matches */
+ checking = true;
+ bool result = chan->CheckBan(user, mask.substr(2));
+ checking = false;
+
+ if (result)
+ return MOD_RES_DENY;
+ }
}
+
+ /* If we made it this far then the ban wasn't an ExtBan
+ or the user we were checking for didn't match either ExtBan */
return MOD_RES_PASSTHRU;
}
AccountEvent(this, dest, *account).Send();
}
+ else
+ {
+ AccountEvent(this, dest, "").Send();
+ }
}
}
Version GetVersion()
{
- return Version("Povides support for ircu-style services accounts, including chmode +R, etc.",VF_OPTCOMMON|VF_VENDOR);
+ return Version("Provides support for ircu-style services accounts, including chmode +R, etc.",VF_OPTCOMMON|VF_VENDOR);
}
};