From f36915790674275627cf8eb68024e17539ee04fa Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 11 Apr 2014 16:10:30 -0400 Subject: Use OnChanRegistered instead of OnCreateChan to set default mlocks. Because OnCreateChan is called from ChannelInfo's constructor, during DB loading it could cause mode locks to be unserialized without having all channels loaded, which breaks things. --- modules/commands/cs_mode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index a13610d23..941a6d183 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -951,7 +951,7 @@ class CSMode : public Module } } - void OnCreateChan(ChannelInfo *ci) anope_override + void OnChanRegistered(ChannelInfo *ci) anope_override { ModeLocks *ml = modelocks.Require(ci); Anope::string mlock; -- cgit From 72b26043b2f1729a2d183b01310747303fe385fd Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 18 Apr 2014 02:21:06 -0400 Subject: Remove unused event. Mark some oper only usermodes as oper only. Fix reading SID in TS6_SID_Retrieve --- modules/protocol/hybrid.cpp | 2 +- modules/protocol/plexus.cpp | 4 ++-- modules/protocol/ratbox.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 9d928a106..84f7db001 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -610,7 +610,7 @@ class ProtoHybrid : public Module ModeManager::AddUserMode(new UserModeOperOnly("CALLERID", 'g')); ModeManager::AddUserMode(new UserMode("INVIS", 'i')); ModeManager::AddUserMode(new UserModeOperOnly("LOCOPS", 'l')); - ModeManager::AddUserMode(new UserMode("OPER", 'o')); + ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o')); ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r')); ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); ModeManager::AddUserMode(new UserMode("WALLOPS", 'w')); diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 0770d20a4..04d90be7e 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -333,10 +333,10 @@ class ProtoPlexus : public Module ModeManager::AddUserMode(new UserMode("CALLERID", 'g')); ModeManager::AddUserMode(new UserMode("INVIS", 'i')); ModeManager::AddUserMode(new UserModeOperOnly("LOCOPS", 'l')); - ModeManager::AddUserMode(new UserMode("OPER", 'o')); + ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o')); ModeManager::AddUserMode(new UserModeOperOnly("NETADMIN", 'N')); ModeManager::AddUserMode(new UserMode("PRIV", 'p')); - ModeManager::AddUserMode(new UserMode("ROUTING", 'q')); + ModeManager::AddUserMode(new UserModeOperOnly("ROUTING", 'q')); ModeManager::AddUserMode(new UserModeNoone("REGISTERED", 'r')); ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 89e0f0176..8fd9a30cf 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -253,7 +253,7 @@ class ProtoRatbox : public Module // k = skill? ModeManager::AddUserMode(new UserModeOperOnly("LOCOPS", 'l')); // n = nchange - ModeManager::AddUserMode(new UserMode("OPER", 'o')); + ModeManager::AddUserMode(new UserModeOperOnly("OPER", 'o')); // r = rej ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'S')); -- cgit From d52cc7bcbcf9b99a58eedc823418a91f85e8cab9 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 24 Apr 2014 01:24:05 -0400 Subject: Bug #1587 - fix bot change not properly reintroducing clients --- modules/commands/bs_bot.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index e25ba8ff0..69fa7f8fe 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -189,7 +189,10 @@ class CommandBSBot : public Command } if (!user.empty()) + { IRCD->SendQuit(bi, "Quit: Be right back"); + bi->introduced = false; + } else IRCD->SendNickChange(bi, nick); @@ -204,18 +207,7 @@ class CommandBSBot : public Command bi->realname = real; if (!user.empty()) - { - IRCD->SendClientIntroduction(bi); - unsigned minusers = Config->GetBlock("botserv")->Get("minusers"); - const std::set &channels = bi->GetChannels(); - for (std::set::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it) - { - const ChannelInfo *ci = *it; - - if (ci->c && ci->c->users.size() >= minusers) - bi->Join(ci->c); - } - } + bi->OnKill(); source.Reply(_("Bot \002%s\002 has been changed to %s!%s@%s (%s)."), oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; -- cgit From 00b2cc9ce6b9e4d4869d986ada1cf64d22b95455 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 24 Apr 2014 01:38:45 -0400 Subject: Require at least user@host format for akills. Fix XLine::GetHost() not returning anything if an xline only has a host --- modules/commands/os_akill.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules') diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index c81a6b515..af8573752 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -160,6 +160,11 @@ class CommandOSAKill : public Command source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str()); return; } + else if (mask.find('@') == Anope::string::npos) + { + source.Reply(BAD_USERHOST_MASK); + return; + } if (Config->GetModule("operserv")->Get("addakiller", "yes") && !source.GetNick().empty()) reason = "[" + source.GetNick() + "] " + reason; -- cgit From f010ab7dbf020ae218dbd7390af4bcff4bac6fbe Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 24 Apr 2014 01:40:56 -0400 Subject: Resend ircd login name on /ns set display --- modules/commands/ns_set.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 063b7c4dd..e8abf762f 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -330,7 +330,7 @@ class CommandNSSetDisplay : public Command return; } - const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); + NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); if (Config->GetModule("nickserv")->Get("nonicknameownership")) { @@ -356,6 +356,8 @@ class CommandNSSetDisplay : public Command Log(user_na->nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the display of " << user_na->nc->display << " to " << na->nick; user_na->nc->SetDisplay(na); + if (source.GetUser()) + IRCD->SendLogin(source.GetUser(), na); source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str()); } -- cgit From 75ed5a9b59dd29b2e63d502eb3425696d93765fd Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 24 Apr 2014 01:50:50 -0400 Subject: Fix os_stats counters not saving with db_sql_live. Bleh. --- modules/commands/os_stats.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules') diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 85088f385..bd868b903 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -258,6 +258,12 @@ class OSStats : public Module { } + + void OnUserConnect(User *u, bool &exempt) anope_override + { + if (UserListByNick.size() == MaxUserCount && Anope::CurTime == MaxUserTime) + stats_saver.QueueUpdate(); + } }; MODULE_INIT(OSStats) -- cgit From c9473bcc67e0259b0aa79c95424e6fc044777ccc Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 24 Apr 2014 17:10:06 -0400 Subject: Fix botserv/kick/bolds desc --- modules/commands/bs_kick.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index c08376e3c..f3f000474 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -325,7 +325,7 @@ class CommandBSKickBolds : public CommandBSKickBase public: CommandBSKickBolds(Module *creator) : CommandBSKickBase(creator, "botserv/kick/bolds", 2, 3) { - this->SetDesc(_("Configures badwords kicker")); + this->SetDesc(_("Configures bolds kicker")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } -- cgit From 82008d507cccbf24c73502bc97bc492d21305549 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 25 Apr 2014 16:46:37 -0400 Subject: Fix Stas::Unserialize to return the instance --- modules/commands/os_stats.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index bd868b903..baa349db4 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -14,7 +14,12 @@ struct Stats : Serializable { - Stats() : Serializable("Stats") { } + static Stats *me; + + Stats() : Serializable("Stats") + { + me = this; + } void Serialize(Serialize::Data &data) const anope_override { @@ -26,7 +31,7 @@ struct Stats : Serializable { data["maxusercnt"] >> MaxUserCount; data["maxusertime"] >> MaxUserTime; - return NULL; + return me; } }; -- cgit From 4fa2a00bd595eb120e6acde5eb167759c2018e33 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 25 Apr 2014 16:47:10 -0400 Subject: Close timed out proxyscan sockets better --- modules/m_proxyscan.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/m_proxyscan.cpp b/modules/m_proxyscan.cpp index 98178260c..0fe4ade27 100644 --- a/modules/m_proxyscan.cpp +++ b/modules/m_proxyscan.cpp @@ -206,12 +206,13 @@ class ModuleProxyScan : public Module void Tick(time_t) anope_override { - for (std::set::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end; ++it) + for (std::set::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;) { ProxyConnect *p = *it; + ++it; if (p->created + this->GetSecs() < Anope::CurTime) - p->flags[SF_DEAD] = true; + delete p; } } } connectionTimeout; -- cgit From 6a03eb69ebbe773f1d4139ff88d74ecdb2b0af4b Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 25 Apr 2014 16:51:06 -0400 Subject: Add "virtual mode" support This allows fully tracking extbans and other modes set by a different underlying mode, such as InspIRCd's namedmodes Add two configuration options to cs_ban to configure which mode is set and whether or not to kick banned users. Add default "mute" fantasy command to botserv.example.conf --- modules/commands/cs_ban.cpp | 47 ++++--- modules/commands/cs_mode.cpp | 3 +- modules/commands/cs_unban.cpp | 15 ++- modules/protocol/inspircd20.cpp | 195 +++++++++++++++++++++++------ modules/protocol/unreal.cpp | 124 ++++++++++++++---- modules/webcpanel/pages/chanserv/modes.cpp | 2 +- 6 files changed, 299 insertions(+), 87 deletions(-) (limited to 'modules') diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 0395ddd92..648e379e3 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -19,15 +19,16 @@ class TempBan : public Timer private: Anope::string channel; Anope::string mask; + Anope::string mode; public: - TempBan(time_t seconds, Channel *c, const Anope::string &banmask) : Timer(me, seconds), channel(c->name), mask(banmask) { } + TempBan(time_t seconds, Channel *c, const Anope::string &banmask, const Anope::string &mod) : Timer(me, seconds), channel(c->name), mask(banmask), mode(mod) { } void Tick(time_t ctime) anope_override { Channel *c = Channel::Find(this->channel); if (c) - c->RemoveMode(NULL, "BAN", this->mask); + c->RemoveMode(NULL, mode, this->mask); } }; @@ -43,6 +44,8 @@ class CommandCSBan : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { const Anope::string &chan = params[0]; + Configuration::Block *block = Config->GetCommand(source); + const Anope::string &mode = block->Get("mode", "BAN"); ChannelInfo *ci = ChannelInfo::Find(chan); if (ci == NULL) @@ -57,9 +60,9 @@ class CommandCSBan : public Command source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); return; } - else if (IRCD->GetMaxListFor(c) && c->HasMode("BAN") >= IRCD->GetMaxListFor(c)) + else if (IRCD->GetMaxListFor(c) && c->HasMode(mode) >= IRCD->GetMaxListFor(c)) { - source.Reply(_("The ban list for %s is full."), c->name.c_str()); + source.Reply(_("The %s list for %s is full."), mode.lower().c_str(), c->name.c_str()); return; } @@ -126,12 +129,12 @@ class CommandCSBan : public Command bool override = !u_access.HasPriv("BAN") || (u != u2 && ci->HasExt("PEACE") && u2_access >= u_access); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << mask; - if (!c->HasMode("BAN", mask)) + if (!c->HasMode(mode, mask)) { - c->SetMode(NULL, "BAN", mask); + c->SetMode(NULL, mode, mask); if (ban_time) { - new TempBan(ban_time, c, mask); + new TempBan(ban_time, c, mask, mode); source.Reply(_("Ban on \002%s\002 expires in %s."), mask.c_str(), Anope::Duration(ban_time, source.GetAccount()).c_str()); } } @@ -140,10 +143,13 @@ class CommandCSBan : public Command if (!c->FindUser(u2)) return; - if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !source.AccessFor(ci).HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str()); - else - c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); + if (block->Get("kick", "yes")) + { + if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !source.AccessFor(ci).HasPriv("SIGNKICK"))) + c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str()); + else + c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); + } } } else @@ -152,12 +158,12 @@ class CommandCSBan : public Command bool override = !founder && !u_access.HasPriv("BAN"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << target; - if (!c->HasMode("BAN", target)) + if (!c->HasMode(mode, target)) { - c->SetMode(NULL, "BAN", target); + c->SetMode(NULL, mode, target); if (ban_time) { - new TempBan(ban_time, c, target); + new TempBan(ban_time, c, target, mode); source.Reply(_("Ban on \002%s\002 expires in %s."), target.c_str(), Anope::Duration(ban_time, source.GetAccount()).c_str()); } } @@ -183,11 +189,14 @@ class CommandCSBan : public Command else if (uc->user->IsProtected()) continue; - ++kicked; - if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str()); - else - c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str()); + if (block->Get("kick", "yes")) + { + ++kicked; + if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) + c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str()); + else + c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str()); + } } } diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 941a6d183..2943c64a3 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -488,8 +488,7 @@ class CommandCSMode : public Command for (unsigned j = 0; j < ModeManager::GetChannelModes().size(); ++j) { ChannelMode *cm = ModeManager::GetChannelModes()[j]; - if (!cm) - continue; + if (!u || cm->CanSet(u) || can_override) { if (cm->type == MODE_REGULAR || (!adding && cm->type == MODE_PARAM)) diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index 56a482985..9fd6400a8 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -22,6 +22,13 @@ class CommandCSUnban : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { + ChannelMode *cm = ModeManager::FindChannelModeByName("BAN"); + if (!cm) + return; + + std::vector modes = cm->listeners; + modes.push_back(cm); + if (params.empty()) { if (!source.GetUser()) @@ -38,8 +45,9 @@ class CommandCSUnban : public Command if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN")) continue; - if (ci->c->Unban(source.GetUser(), true)) - ++count; + for (unsigned j = 0; j < modes.size(); ++j) + if (ci->c->Unban(source.GetUser(), modes[j]->name, true)) + ++count; } Log(LOG_COMMAND, source, this, NULL) << "on all channels"; @@ -80,7 +88,8 @@ class CommandCSUnban : public Command bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick; - ci->c->Unban(u2, source.GetUser() == u2); + for (unsigned i = 0; i < modes.size(); ++i) + ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2); if (u2 == source.GetUser()) source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str()); else diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 4e88d01a8..1e439da30 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -77,25 +77,61 @@ class InspIRCd20Proto : public IRCDProto bool IsIdentValid(const Anope::string &ident) anope_override { return insp12->IsIdentValid(ident); } }; -class InspIRCdExtBan : public ChannelModeList +class InspIRCdExtBan : public ChannelModeVirtual { + char ext; + public: - InspIRCdExtBan(const Anope::string &mname, char modeChar) : ChannelModeList(mname, modeChar) { } + InspIRCdExtBan(const Anope::string &mname, const Anope::string &basename, char extban) : ChannelModeVirtual(mname, basename) + , ext(extban) + { + } + + ChannelMode *Wrap(Anope::string ¶m) anope_override + { + param = Anope::string(ext) + ":" + param; + return ChannelModeVirtual::Wrap(param); + } - bool Matches(User *u, const Entry *e) anope_override + ChannelMode *Unwrap(ChannelMode *cm, Anope::string ¶m) anope_override { - const Anope::string &mask = e->GetMask(); + if (cm->type != MODE_LIST || param.length() < 3 || param[0] != ext || param[1] != ':') + return cm; - if (mask.find("m:") == 0 || mask.find("N:") == 0) + param = param.substr(2); + return this; + } +}; + +namespace InspIRCdExtban +{ + class EntryMatcher : public InspIRCdExtBan + { + public: + EntryMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c) { + } + + bool Matches(User *u, const Entry *e) anope_override + { + const Anope::string &mask = e->GetMask(); Anope::string real_mask = mask.substr(3); - Entry en(this->name, real_mask); - if (en.Matches(u)) - return true; + return Entry(this->name, real_mask).Matches(u); + } + }; + + class ChannelMatcher : public InspIRCdExtBan + { + public: + ChannelMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c) + { } - else if (mask.find("j:") == 0) + + bool Matches(User *u, const Entry *e) anope_override { + const Anope::string &mask = e->GetMask(); + Anope::string channel = mask.substr(3); ChannelMode *cm = NULL; @@ -116,39 +152,87 @@ class InspIRCdExtBan : public ChannelModeList if (cm == NULL || uc->status.HasMode(cm->mchar)) return true; } - } - else if (mask.find("R:") == 0) - { - Anope::string real_mask = mask.substr(2); - if (u->IsIdentified() && real_mask.equals_ci(u->Account()->display)) - return true; + return false; } - else if (mask.find("r:") == 0) - { - Anope::string real_mask = mask.substr(2); + }; - if (Anope::Match(u->realname, real_mask)) - return true; - } - else if (mask.find("s:") == 0) + class AccountMatcher : public InspIRCdExtBan + { + public: + AccountMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override { + const Anope::string &mask = e->GetMask(); Anope::string real_mask = mask.substr(2); - if (Anope::Match(u->server->GetName(), real_mask)) - return true; + return u->IsIdentified() && real_mask.equals_ci(u->Account()->display); } - else if (mask.find("z:") == 0) - { - Anope::string real_mask = mask.substr(2); + }; - if (!u->fingerprint.empty() && Anope::Match(u->fingerprint, real_mask)) - return true; + class RealnameMatcher : public InspIRCdExtBan + { + public: + RealnameMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override + { + const Anope::string &mask = e->GetMask(); + Anope::string real_mask = mask.substr(2); + return Anope::Match(u->realname, real_mask); + } + }; + + class ServerMatcher : public InspIRCdExtBan + { + public: + ServerMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override + { + const Anope::string &mask = e->GetMask(); + Anope::string real_mask = mask.substr(2); + return Anope::Match(u->server->GetName(), real_mask); + } + }; + + class FinerprintMatcher : public InspIRCdExtBan + { + public: + FinerprintMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override + { + const Anope::string &mask = e->GetMask(); + Anope::string real_mask = mask.substr(2); + return !u->fingerprint.empty() && Anope::Match(u->fingerprint, real_mask); + } + }; + + class UnidentifiedMatcher : public InspIRCdExtBan + { + public: + UnidentifiedMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : InspIRCdExtBan(mname, mbase, c) + { } - return false; - } -}; + bool Matches(User *u, const Entry *e) anope_override + { + const Anope::string &mask = e->GetMask(); + Anope::string real_mask = mask.substr(2); + return !u->Account() && Entry("BAN", real_mask).Matches(u); + } + }; +} class ColonDelimitedParamMode : public ChannelModeParam { @@ -304,17 +388,26 @@ struct IRCDMessageCapab : Message::Capab if (modename.equals_cs("admin")) cm = new ChannelModeStatus("PROTECT", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 3); else if (modename.equals_cs("allowinvite")) + { cm = new ChannelMode("ALLINVITE", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("INVITEBAN", "BAN", 'A')); + } else if (modename.equals_cs("auditorium")) cm = new ChannelMode("AUDITORIUM", modechar[0]); else if (modename.equals_cs("ban")) - cm = new InspIRCdExtBan("BAN", modechar[0]); + cm = new ChannelModeList("BAN", modechar[0]); else if (modename.equals_cs("banexception")) - cm = new InspIRCdExtBan("EXCEPT", 'e'); + cm = new ChannelModeList("EXCEPT", modechar[0]); else if (modename.equals_cs("blockcaps")) + { cm = new ChannelMode("BLOCKCAPS", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("BLOCKCAPSBAN", "BAN", 'B')); + } else if (modename.equals_cs("blockcolor")) + { cm = new ChannelMode("BLOCKCOLOR", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("BLOCKCOLORBAN", "BAN", 'c')); + } else if (modename.equals_cs("c_registered")) cm = new ChannelModeNoone("REGISTERED", modechar[0]); else if (modename.equals_cs("censor")) @@ -334,7 +427,7 @@ struct IRCDMessageCapab : Message::Capab else if (modename.equals_cs("history")) cm = new ChannelModeHistory(modechar[0]); else if (modename.equals_cs("invex")) - cm = new InspIRCdExtBan("INVITEOVERRIDE", 'I'); + cm = new ChannelModeList("INVITEOVERRIDE", modechar[0]); else if (modename.equals_cs("inviteonly")) cm = new ChannelMode("INVITE", modechar[0]); else if (modename.equals_cs("joinflood")) @@ -350,17 +443,29 @@ struct IRCDMessageCapab : Message::Capab else if (modename.equals_cs("nickflood")) cm = new ColonDelimitedParamMode("NICKFLOOD", modechar[0]); else if (modename.equals_cs("noctcp")) + { cm = new ChannelMode("NOCTCP", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NOCTCPBAN", "BAN", 'C')); + } else if (modename.equals_cs("noextmsg")) cm = new ChannelMode("NOEXTERNAL", modechar[0]); else if (modename.equals_cs("nokick")) + { cm = new ChannelMode("NOKICK", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NOKICKBAN", "BAN", 'Q')); + } else if (modename.equals_cs("noknock")) cm = new ChannelMode("NOKNOCK", modechar[0]); else if (modename.equals_cs("nonick")) + { cm = new ChannelMode("NONICK", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NONICKBAN", "BAN", 'N')); + } else if (modename.equals_cs("nonotice")) + { cm = new ChannelMode("NONOTICE", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("NONOTICEBAN", "BAN", 'T')); + } else if (modename.equals_cs("op")) cm = new ChannelModeStatus("OP", modechar.length() > 1 ? modechar[1] : modechar[0], modechar.length() > 1 ? modechar[0] : 0, 2); else if (modename.equals_cs("operonly")) @@ -378,9 +483,15 @@ struct IRCDMessageCapab : Message::Capab else if (modename.equals_cs("secret")) cm = new ChannelMode("SECRET", modechar[0]); else if (modename.equals_cs("sslonly")) + { cm = new ChannelMode("SSL", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::FinerprintMatcher("SSLBAN", "BAN", 'z')); + } else if (modename.equals_cs("stripcolor")) + { cm = new ChannelMode("STRIPCOLOR", modechar[0]); + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("STRIPCOLORBAN", "BAN", 'S')); + } else if (modename.equals_cs("topiclock")) cm = new ChannelMode("TOPIC", modechar[0]); else if (modename.equals_cs("voice")) @@ -481,11 +592,25 @@ struct IRCDMessageCapab : Message::Capab while (ssep.GetToken(module)) { if (module.equals_cs("m_services_account.so")) + { Servers::Capab.insert("SERVICES"); + ModeManager::AddChannelMode(new InspIRCdExtban::AccountMatcher("ACCOUNTBAN", "BAN", 'R')); + ModeManager::AddChannelMode(new InspIRCdExtban::UnidentifiedMatcher("UNREGISTEREDBAN", "BAN", 'U')); + } else if (module.equals_cs("m_chghost.so")) Servers::Capab.insert("CHGHOST"); else if (module.equals_cs("m_chgident.so")) Servers::Capab.insert("CHGIDENT"); + else if (module == "m_channelban.so") + ModeManager::AddChannelMode(new InspIRCdExtban::ChannelMatcher("CHANNELBAN", "BAN", 'j')); + else if (module == "m_gecosban.so") + ModeManager::AddChannelMode(new InspIRCdExtban::RealnameMatcher("REALNAMEBAN", "BAN", 'r')); + else if (module == "m_nopartmessage.so") + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("PARTMESSAGEBAN", "BAN", 'p')); + else if (module == "m_serverban.so") + ModeManager::AddChannelMode(new InspIRCdExtban::ServerMatcher("SERVERBAN", "BAN", 's')); + else if (module == "m_muteban.so") + ModeManager::AddChannelMode(new InspIRCdExtban::EntryMatcher("QUIET", "BAN", 'm')); } } else if (params[0].equals_cs("CAPABILITIES") && params.size() > 1) diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index d7bc8fa14..f444947f6 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -415,17 +415,44 @@ class UnrealIRCdProto : public IRCDProto } }; -class UnrealExtBan : public ChannelModeList +class UnrealExtBan : public ChannelModeVirtual { + char ext; + public: - UnrealExtBan(const Anope::string &mname, char modeChar) : ChannelModeList(mname, modeChar) { } + UnrealExtBan(const Anope::string &mname, const Anope::string &basename, char extban) : ChannelModeVirtual(mname, basename) + , ext(extban) + { + } + + ChannelMode *Wrap(Anope::string ¶m) anope_override + { + param = "~" + Anope::string(ext) + ":" + param; + return ChannelModeVirtual::Wrap(param); + } - bool Matches(User *u, const Entry *e) anope_override + ChannelMode *Unwrap(ChannelMode *cm, Anope::string ¶m) anope_override { - const Anope::string &mask = e->GetMask(); + if (cm->type != MODE_LIST || param.length() < 4 || param[0] != '~' || param[1] != ext || param[2] != ':') + return cm; - if (mask.find("~c:") == 0) + param = param.substr(3); + return this; + } +}; + +namespace UnrealExtban +{ + class ChannelMatcher : public UnrealExtBan + { + public: + ChannelMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c) { + } + + bool Matches(User *u, const Entry *e) anope_override + { + const Anope::string &mask = e->GetMask(); Anope::string channel = mask.substr(3); ChannelMode *cm = NULL; @@ -446,38 +473,73 @@ class UnrealExtBan : public ChannelModeList if (cm == NULL || uc->status.HasMode(cm->mchar)) return true; } + + return false; } - else if (mask.find("~j:") == 0 || mask.find("~n:") == 0 || mask.find("~q:") == 0) + }; + + class EntryMatcher : public UnrealExtBan + { + public: + EntryMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override { + const Anope::string &mask = e->GetMask(); Anope::string real_mask = mask.substr(3); - Entry en(this->name, real_mask); - if (en.Matches(u)) - return true; + return Entry(this->name, real_mask).Matches(u); } - else if (mask.find("~r:") == 0) + }; + + class RealnameMatcher : public UnrealExtBan + { + public: + RealnameMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override { + const Anope::string &mask = e->GetMask(); Anope::string real_mask = mask.substr(3); - if (Anope::Match(u->realname, real_mask)) - return true; + return Anope::Match(u->realname, real_mask); } - else if (mask.find("~R:") == 0) + }; + + class RegisteredMatcher : public UnrealExtBan + { + public: + RegisteredMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override { - if (u->HasMode("REGISTERED") && mask.equals_ci(u->nick)) - return true; + const Anope::string &mask = e->GetMask(); + return u->HasMode("REGISTERED") && mask.equals_ci(u->nick); } - else if (mask.find("~a:") == 0) - { + }; + + class AccountMatcher : public UnrealExtBan + { + public: + AccountMatcher(const Anope::string &mname, const Anope::string &mbase, char c) : UnrealExtBan(mname, mbase, c) + { + } + + bool Matches(User *u, const Entry *e) anope_override + { + const Anope::string &mask = e->GetMask(); Anope::string real_mask = mask.substr(3); - if (u->Account() && Anope::Match(u->Account()->display, real_mask)) - return true; - } - - return false; - } -}; + return u->Account() && Anope::Match(u->Account()->display, real_mask); + } + }; +} class ChannelModeFlood : public ChannelModeParam { @@ -565,13 +627,21 @@ struct IRCDMessageCapab : Message::Capab switch (modebuf[t]) { case 'b': - ModeManager::AddChannelMode(new UnrealExtBan("BAN", 'b')); + ModeManager::AddChannelMode(new ChannelModeList("BAN", 'b')); + + ModeManager::AddChannelMode(new UnrealExtban::ChannelMatcher("CHANNELBAN", "BAN", 'c')); + ModeManager::AddChannelMode(new UnrealExtban::EntryMatcher("JOINBAN", "BAN", 'j')); + ModeManager::AddChannelMode(new UnrealExtban::EntryMatcher("NONICKBAN", "BAN", 'n')); + ModeManager::AddChannelMode(new UnrealExtban::EntryMatcher("QUIET", "BAN", 'q')); + ModeManager::AddChannelMode(new UnrealExtban::RealnameMatcher("REALNAMEBAN", "BAN", 'r')); + ModeManager::AddChannelMode(new UnrealExtban::RegisteredMatcher("REGISTEREDBAN", "BAN", 'R')); + ModeManager::AddChannelMode(new UnrealExtban::AccountMatcher("ACCOUNTBAN", "BAN", 'a')); continue; case 'e': - ModeManager::AddChannelMode(new UnrealExtBan("EXCEPT", 'e')); + ModeManager::AddChannelMode(new ChannelModeList("EXCEPT", 'e')); continue; case 'I': - ModeManager::AddChannelMode(new UnrealExtBan("INVITEOVERRIDE", 'I')); + ModeManager::AddChannelMode(new ChannelModeList("INVITEOVERRIDE", 'I')); continue; default: ModeManager::AddChannelMode(new ChannelModeList("", modebuf[t])); diff --git a/modules/webcpanel/pages/chanserv/modes.cpp b/modules/webcpanel/pages/chanserv/modes.cpp index f087b86a9..a11d42fd9 100644 --- a/modules/webcpanel/pages/chanserv/modes.cpp +++ b/modules/webcpanel/pages/chanserv/modes.cpp @@ -61,7 +61,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st { ChannelMode *cm = ModeManager::GetChannelModes()[i]; - if (cm && cm->type == MODE_LIST) + if (cm->type == MODE_LIST) replacements["LISTMODES"] = cm->mchar; } -- cgit From 2ee496b8ac2aff980103237331514f31b7fdc039 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 26 Apr 2014 17:30:58 -0400 Subject: Change the "does not expire" string in ns_group to NO_EXPIRE which is translatable --- modules/commands/ns_group.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index 04842b3e3..9b3f425e9 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -321,7 +321,7 @@ class CommandNSGList : public Command Anope::string expires; if (na2->HasExt("NS_NO_EXPIRE")) - expires = "Does not expire"; + expires = NO_EXPIRE; else if (!nickserv_expire || Anope::NoExpire) ; else if (na2->nc->HasExt("UNCONFIRMED") && unconfirmed_expire) -- cgit From 8021a53ac47d95f874cc50bd2a0a73715164fae3 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 26 Apr 2014 18:30:54 -0400 Subject: Fix misc help output to not be case sensitive --- modules/commands/cs_set_misc.cpp | 2 +- modules/commands/ns_set_misc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 481b54cb9..81b8c72fa 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -13,7 +13,7 @@ static Module *me; -static std::map descriptions; +static Anope::map descriptions; struct CSMiscData; static Anope::map *> items; diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 496e3a4e2..455a651fb 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -14,7 +14,7 @@ static Module *me; -static std::map descriptions; +static Anope::map descriptions; struct NSMiscData; static Anope::map *> items; -- cgit From 0afd666f22f1f6a593c2cb9b63de60e4ce4e7113 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 29 Apr 2014 22:55:10 +0200 Subject: InspIRCd 2.0: Recognize GLOBOPS in CAPAB CAPABILITIES --- modules/protocol/inspircd20.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules') diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 1e439da30..07c25972c 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -702,6 +702,8 @@ struct IRCDMessageCapab : Message::Capab ModeManager::RebuildStatusModes(); } + else if (capab == "GLOBOPS=1") + Servers::Capab.insert("GLOBOPS"); } } else if (params[0].equals_cs("END")) -- cgit From 3049916ade0c31c2edf2fca98456bccc14d06270 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 30 Apr 2014 01:15:10 +0200 Subject: Fix undefined symbol error when loading os_stats, caused by 82008d507cccbf24c73502bc97bc492d21305549 --- modules/commands/os_stats.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules') diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index baa349db4..e5cae1dcc 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -35,6 +35,8 @@ struct Stats : Serializable } }; +Stats *Stats::me; + /** * Count servers connected to server s * @param s The server to start counting from -- cgit From d79dd0b7d705e8f18ae0d6494a8bc65c2b0c2819 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 1 May 2014 18:38:17 -0400 Subject: Pass password to nick register event so modules like m_ldap_authentication can create the respective account using the decrypted password which might not always be available --- modules/commands/ns_access.cpp | 2 +- modules/commands/ns_register.cpp | 2 +- modules/extra/m_ldap_authentication.cpp | 6 +++--- modules/extra/m_sql_authentication.cpp | 2 +- modules/extra/stats/m_chanstats.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index dfafdb37f..d01f6dc9b 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -196,7 +196,7 @@ class NSAccess : public Module { } - void OnNickRegister(User *u, NickAlias *na) anope_override + void OnNickRegister(User *u, NickAlias *na, const Anope::string &) anope_override { if (u && Config->GetModule(this)->Get("addaccessonreg")) na->nc->AddAccess(u->Mask()); diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index c3d678cf1..8e916c4d7 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -198,7 +198,7 @@ class CommandNSRegister : public Command Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; - FOREACH_MOD(OnNickRegister, (source.GetUser(), na)); + FOREACH_MOD(OnNickRegister, (source.GetUser(), na, pass)); if (na->nc->GetAccessCount()) source.Reply(_("Nickname \002%s\002 registered under your user@host-mask: %s"), u_nick.c_str(), na->nc->GetAccess(0).c_str()); diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index 7c9593dff..115faa73e 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -104,7 +104,7 @@ class IdentifyInterface : public LDAPInterface { na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount())); na->last_realname = ii->user ? ii->user->realname : ii->req->GetAccount(); - FOREACH_MOD(OnNickRegister, (ii->user, na)); + FOREACH_MOD(OnNickRegister, (ii->user, na, ii->req->GetPassword())); BotInfo *NickServ = Config->GetClient("NickServ"); if (ii->user && NickServ) ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); @@ -300,7 +300,7 @@ class NSIdentifyLDAP : public Module } } - void OnNickRegister(User *, NickAlias *na) anope_override + void OnNickRegister(User *, NickAlias *na, const Anope::string &pass) anope_override { if (!this->disable_register_reason.empty() || !this->ldap) return; @@ -326,7 +326,7 @@ class NSIdentifyLDAP : public Module } attributes[3].name = this->password_attribute; - attributes[3].values.push_back(na->nc->pass); + attributes[3].values.push_back(pass); Anope::string new_dn = username_attribute + "=" + na->nick + "," + basedn; this->ldap->Add(&this->orinterface, new_dn, attributes); diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index 2342ef89d..0710a6e20 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -42,7 +42,7 @@ class SQLAuthenticationResult : public SQL::Interface if (na == NULL) { na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount())); - FOREACH_MOD(OnNickRegister, (user, na)); + FOREACH_MOD(OnNickRegister, (user, na, "")); if (user && NickServ) user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp index 4151c4579..4557b816f 100644 --- a/modules/extra/stats/m_chanstats.cpp +++ b/modules/extra/stats/m_chanstats.cpp @@ -638,7 +638,7 @@ class MChanstats : public Module ci->Extend("CS_STATS"); } - void OnNickRegister(User *user, NickAlias *na) + void OnNickRegister(User *user, NickAlias *na, const Anope::string &) { if (NSDefChanstats) na->nc->Extend("NS_STATS"); -- cgit From 1f2c385bb9b7a78094024d226440a2ec4cfb6b80 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 1 May 2014 21:03:32 -0400 Subject: Add config options to ns_suspend and cs_suspend to configure which information is shown to non opers --- modules/commands/cs_suspend.cpp | 37 +++++++++++++++++++++++----------- modules/commands/ns_suspend.cpp | 44 ++++++++++++++++++++++++++++++----------- 2 files changed, 59 insertions(+), 22 deletions(-) (limited to 'modules') diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 4ebb6eecb..faec2a8c1 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -200,6 +200,20 @@ class CSSuspend : public Module CommandCSUnSuspend commandcsunsuspend; ExtensibleItem suspend; Serialize::Type suspend_type; + std::vector show; + + struct trim + { + Anope::string operator()(Anope::string s) const + { + return s.trim(); + } + }; + + bool Show(CommandSource &source, const Anope::string &what) const + { + return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end(); + } public: CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), @@ -211,18 +225,19 @@ class CSSuspend : public Module void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override { CSSuspendInfo *si = suspend.Get(ci); - if (si) - { + if (!si) + return; + + if (show_hidden || Show(source, "suspended")) info[_("Suspended")] = _("This channel is \002suspended\002."); - if (!si->by.empty()) - info[_("Suspended by")] = si->by; - if (!si->reason.empty()) - info[_("Suspend reason")] = si->reason; - if (si->when) - info[_("Suspended on")] = Anope::strftime(si->when, source.GetAccount(), true); - if (si->expires) - info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount(), true); - } + if (!si->by.empty() && (show_hidden || Show(source, "by"))) + info[_("Suspended by")] = si->by; + if (!si->reason.empty() && (show_hidden || Show(source, "reason"))) + info[_("Suspend reason")] = si->reason; + if (si->when && (show_hidden || Show(source, "on"))) + info[_("Suspended on")] = Anope::strftime(si->when, source.GetAccount(), true); + if (si->expires && (show_hidden || Show(source, "expires"))) + info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount(), true); } void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 241997d1c..72e82cadf 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -207,6 +207,20 @@ class NSSuspend : public Module CommandNSUnSuspend commandnsunsuspend; ExtensibleItem suspend; Serialize::Type suspend_type; + std::vector show; + + struct trim + { + Anope::string operator()(Anope::string s) const + { + return s.trim(); + } + }; + + bool Show(CommandSource &source, const Anope::string &what) const + { + return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end(); + } public: NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), @@ -215,21 +229,29 @@ class NSSuspend : public Module { } + void OnReload(Configuration::Conf *conf) anope_override + { + Anope::string s = conf->GetModule(this)->Get("show"); + commasepstream(s).GetTokens(show); + std::transform(show.begin(), show.end(), show.begin(), trim()); + } + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override { NSSuspendInfo *s = suspend.Get(na->nc); - if (s) - { + if (!s) + return; + + if (show_hidden || Show(source, "suspended")) info[_("Suspended")] = _("This nickname is \002suspended\002."); - if (!s->by.empty()) - info[_("Suspended by")] = s->by; - if (!s->reason.empty()) - info[_("Suspend reason")] = s->reason; - if (s->when) - info[_("Suspended on")] = Anope::strftime(s->when, source.GetAccount(), true); - if (s->expires) - info[_("Suspension expires")] = Anope::strftime(s->expires, source.GetAccount(), true); - } + if (!s->by.empty() && (show_hidden || Show(source, "by"))) + info[_("Suspended by")] = s->by; + if (!s->reason.empty() && (show_hidden || Show(source, "reason"))) + info[_("Suspend reason")] = s->reason; + if (s->when && (show_hidden || Show(source, "on"))) + info[_("Suspended on")] = Anope::strftime(s->when, source.GetAccount(), true); + if (s->expires && (show_hidden || Show(source, "expires"))) + info[_("Suspension expires")] = Anope::strftime(s->expires, source.GetAccount(), true); } void OnPreNickExpire(NickAlias *na, bool &expire) anope_override -- cgit From 6b6bc819998d137d2f53d7806f767a711a079a81 Mon Sep 17 00:00:00 2001 From: Michael Wobst Date: Tue, 13 May 2014 18:00:10 +0200 Subject: Update ircd-hybrid protocol module --- modules/protocol/hybrid.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 84f7db001..7c2c14098 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -1,7 +1,7 @@ /* ircd-hybrid-8 protocol module * * (C) 2003-2014 Anope Team - * (C) 2012-2013 by the Hybrid Development Team + * (C) 2012-2014 ircd-hybrid development team * * Please read COPYING and README for further details. * @@ -40,10 +40,11 @@ class HybridProto : public IRCDProto { DefaultPseudoclientModes = "+oi"; CanSVSNick = true; + CanSVSHold = true; + CanSVSJoin = true; CanSNLine = true; CanSQLine = true; CanSZLine = true; - CanSVSHold = true; CanCertFP = true; CanSetVHost = true; RequiresID = true; @@ -174,9 +175,9 @@ class HybridProto : public IRCDProto void SendServer(const Server *server) anope_override { if (server == Me) - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); + UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() + 1 << " :" << server->GetDescription(); else - UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription(); + UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " :" << server->GetDescription(); } void SendConnect() anope_override @@ -254,6 +255,19 @@ class HybridProto : public IRCDProto UplinkSocket::Message(Me) << "SVSNICK " << u->nick << " " << newnick << " " << when; } + void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) anope_override + { + UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan; + } + + void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string ¶m) anope_override + { + if (!param.empty()) + UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan << " :" << param; + else + UplinkSocket::Message(source) << "SVSPART " << u->GetUID() << " " << chan; + } + void SendSVSHold(const Anope::string &nick, time_t t) anope_override { XLine x(nick, Me->GetName(), Anope::CurTime + t, "Being held for registered user"); -- cgit From 91c7862579f5c5a9ad9d939fd7a7b8fbfa6213a4 Mon Sep 17 00:00:00 2001 From: Cronus89 Date: Tue, 13 May 2014 11:12:00 -0500 Subject: Update Paramater length for os_dns to fix DNS SET --- modules/commands/os_dns.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index 6a930980f..b8077b7e9 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -653,7 +653,7 @@ class CommandOSDNS : public Command } public: - CommandOSDNS(Module *creator) : Command(creator, "operserv/dns", 0, 3) + CommandOSDNS(Module *creator) : Command(creator, "operserv/dns", 0, 4) { this->SetDesc(_("Manage DNS zones for this network")); this->SetSyntax(_("ADDZONE \037zone.name\037")); -- cgit From 0c7d53f81ee87a3fb15145de985503d9dc429dae Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 May 2014 18:38:14 -0400 Subject: Don't show both online from's if they have the same mask in ns_info --- modules/commands/ns_info.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 5d9ff8c7a..443b6a9b7 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -62,9 +62,13 @@ class CommandNSInfo : public Command if (nick_online) { + bool shown = false; if (show_hidden && !na->last_realhost.empty()) + { info[_("Online from")] = na->last_realhost; - if (show_hidden || !na->nc->HasExt("HIDE_MASK")) + shown = true; + } + if ((show_hidden || !na->nc->HasExt("HIDE_MASK")) && (!shown || na->last_usermask != na->last_realhost)) info[_("Online from")] = na->last_usermask; else source.Reply(_("%s is currently online."), na->nick.c_str()); -- cgit From 1c8a77ab9f4adfd0afd8217bc462bb338925dcea Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 May 2014 19:52:01 -0400 Subject: Accept an optional reason for svspart --- modules/commands/os_svs.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/commands/os_svs.cpp b/modules/commands/os_svs.cpp index 35ad1aa1e..ee8c60114 100644 --- a/modules/commands/os_svs.cpp +++ b/modules/commands/os_svs.cpp @@ -117,10 +117,10 @@ class CommandOSSVSJoin : public Command class CommandOSSVSPart : public Command { public: - CommandOSSVSPart(Module *creator) : Command(creator, "operserv/svspart", 2, 2) + CommandOSSVSPart(Module *creator) : Command(creator, "operserv/svspart", 2, 3) { this->SetDesc(_("Forcefully part a user from a channel")); - this->SetSyntax(_("\037nick\037 \037channel\037")); + this->SetSyntax(_("\037nick\037 \037channel\037 [\037reason\037]")); } void Execute(CommandSource &source, const std::vector ¶ms) anope_override @@ -133,6 +133,7 @@ class CommandOSSVSPart : public Command User *target = User::Find(params[0], true); Channel *c = Channel::Find(params[1]); + const Anope::string &reason = params.size() > 2 ? params[2] : ""; if (target == NULL) source.Reply(NICK_X_NOT_IN_USE, params[0].c_str()); else if (source.GetUser() != target && (target->IsProtected() || target->server == Me)) @@ -143,8 +144,11 @@ class CommandOSSVSPart : public Command source.Reply(_("\002%s\002 is not in \002%s\002."), target->nick.c_str(), c->name.c_str()); else { - IRCD->SendSVSPart(*source.service, target, params[1], ""); - Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name; + IRCD->SendSVSPart(*source.service, target, params[1], reason); + if (!reason.empty()) + Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name << " with reason " << reason; + else + Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name; source.Reply(_("\002%s\002 has been parted from \002%s\002."), target->nick.c_str(), c->name.c_str()); } } -- cgit From 63b02b8c97e73d5a1fc7005e9693a954179ded0d Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 May 2014 22:57:53 -0400 Subject: Sanitize nuh masks more to prevent the other side from rewriting them, which screws with our internal tracking of them --- modules/protocol/bahamut.cpp | 2 +- modules/protocol/inspircd12.cpp | 2 +- modules/protocol/inspircd20.cpp | 13 +++++++------ modules/protocol/unreal.cpp | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 72c3ee8f9..206bca250 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -16,7 +16,7 @@ class ChannelModeFlood : public ChannelModeParam public: ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { } - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { try { diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 0cf3e991d..8b17d4140 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -28,7 +28,7 @@ class ChannelModeFlood : public ChannelModeParam public: ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { } - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { try { diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 07c25972c..b27249234 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -239,7 +239,7 @@ class ColonDelimitedParamMode : public ChannelModeParam public: ColonDelimitedParamMode(const Anope::string &modename, char modeChar) : ChannelModeParam(modename, modeChar, true) { } - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { return IsValid(value, false); } @@ -288,7 +288,7 @@ class SimpleNumberParamMode : public ChannelModeParam public: SimpleNumberParamMode(const Anope::string &modename, char modeChar) : ChannelModeParam(modename, modeChar, true) { } - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { if (value.empty()) return false; // empty param is never valid @@ -313,11 +313,12 @@ class ChannelModeFlood : public ColonDelimitedParamMode public: ChannelModeFlood(char modeChar) : ColonDelimitedParamMode("FLOOD", modeChar) { } - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { // The parameter of this mode is a bit different, it may begin with a '*', // ignore it if that's the case - return ((!value.empty()) && (ColonDelimitedParamMode::IsValid(value[0] == '*' ? value.substr(1) : value))); + Anope::string v = value[0] == '*' ? value.substr(1) : value; + return ((!value.empty()) && (ColonDelimitedParamMode::IsValid(v))); } }; @@ -326,7 +327,7 @@ class ChannelModeHistory : public ColonDelimitedParamMode public: ChannelModeHistory(char modeChar) : ColonDelimitedParamMode("HISTORY", modeChar) { } - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { return (ColonDelimitedParamMode::IsValid(value, true)); } @@ -337,7 +338,7 @@ class ChannelModeRedirect : public ChannelModeParam public: ChannelModeRedirect(char modeChar) : ChannelModeParam("REDIRECT", modeChar, true) { } - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { // The parameter of this mode is a channel, and channel names start with '#' return ((!value.empty()) && (value[0] == '#')); diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index f444947f6..fd7cb8e81 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -547,7 +547,7 @@ class ChannelModeFlood : public ChannelModeParam ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam("FLOOD", modeChar, minusNoArg) { } /* Borrowed part of this check from UnrealIRCd */ - bool IsValid(const Anope::string &value) const anope_override + bool IsValid(Anope::string &value) const anope_override { if (value.empty()) return false; -- cgit From 1931fcf0e5ffe34005d134e49c55d1b6239d1a6c Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 May 2014 22:59:41 -0400 Subject: Fix webpanel mode list to only show real list modes --- modules/webcpanel/pages/chanserv/modes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/webcpanel/pages/chanserv/modes.cpp b/modules/webcpanel/pages/chanserv/modes.cpp index a11d42fd9..d5b111708 100644 --- a/modules/webcpanel/pages/chanserv/modes.cpp +++ b/modules/webcpanel/pages/chanserv/modes.cpp @@ -61,7 +61,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st { ChannelMode *cm = ModeManager::GetChannelModes()[i]; - if (cm->type == MODE_LIST) + if (cm->type == MODE_LIST && cm->mchar) replacements["LISTMODES"] = cm->mchar; } -- cgit From df321a118e7dd44dcd3a389f8ee75e9ff915b55e Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 May 2014 19:10:23 -0400 Subject: Fix access lists showing the wrong mask if the display nick for a group expires but the group still exists. This can cause access entries for nicks to not be deleted whenever the nicks are deleted. --- modules/commands/cs_access.cpp | 31 ++++++++++++++--------------- modules/commands/cs_clone.cpp | 9 ++++----- modules/commands/cs_flags.cpp | 15 +++++++------- modules/commands/cs_seen.cpp | 2 +- modules/commands/cs_status.cpp | 2 +- modules/commands/cs_xop.cpp | 23 ++++++++++----------- modules/database/db_old.cpp | 2 +- modules/pseudoclients/chanserv.cpp | 9 ++++----- modules/webcpanel/pages/chanserv/access.cpp | 9 ++++----- 9 files changed, 48 insertions(+), 54 deletions(-) (limited to 'modules') diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index b4f682c66..d5f934862 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -180,7 +180,7 @@ class CommandCSAccess : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { const ChanAccess *access = ci->GetAccess(i - 1); - if (mask.equals_ci(access->mask)) + if (mask.equals_ci(access->Mask())) { /* Don't allow lowering from a level >= u_level */ if ((!highest || *access >= *highest) && !u_access.founder && !source.HasPriv("chanserv/access/modify")) @@ -204,8 +204,7 @@ class CommandCSAccess : public Command if (!provider) return; AccessChanAccess *access = anope_dynamic_static_cast(provider->Create()); - access->ci = ci; - access->mask = mask; + access->SetMask(mask, ci); access->creator = source.GetNick(); access->level = level; access->last_seen = 0; @@ -216,9 +215,9 @@ class CommandCSAccess : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level; if (p != NULL) - source.Reply(_("\002%s\002 added to %s access list at privilege %s (level %d)"), access->mask.c_str(), ci->name.c_str(), p->name.c_str(), level); + source.Reply(_("\002%s\002 added to %s access list at privilege %s (level %d)"), access->Mask().c_str(), ci->name.c_str(), p->name.c_str(), level); else - source.Reply(_("\002%s\002 added to %s access list at level \002%d\002."), access->mask.c_str(), ci->name.c_str(), level); + source.Reply(_("\002%s\002 added to %s access list at level \002%d\002."), access->Mask().c_str(), ci->name.c_str(), level); } void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) @@ -284,7 +283,7 @@ class CommandCSAccess : public Command AccessGroup ag = source.AccessFor(ci); const ChanAccess *u_highest = ag.Highest(); - if ((!u_highest || *u_highest <= *access) && !ag.founder && !this->override && !access->mask.equals_ci(source.nc->display)) + if ((!u_highest || *u_highest <= *access) && !ag.founder && !this->override && access->GetAccount() != source.nc) { denied = true; return; @@ -292,9 +291,9 @@ class CommandCSAccess : public Command ++deleted; if (!Nicks.empty()) - Nicks += ", " + access->mask; + Nicks += ", " + access->Mask(); else - Nicks = access->mask; + Nicks = access->Mask(); ci->EraseAccess(Number - 1); @@ -313,15 +312,15 @@ class CommandCSAccess : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { ChanAccess *access = ci->GetAccess(i - 1); - if (mask.equals_ci(access->mask)) + if (mask.equals_ci(access->Mask())) { - if (!access->mask.equals_ci(source.nc->display) && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) + if (access->GetAccount() != source.nc && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else { - source.Reply(_("\002%s\002 deleted from %s access list."), access->mask.c_str(), ci->name.c_str()); - bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; + source.Reply(_("\002%s\002 deleted from %s access list."), access->Mask().c_str(), ci->name.c_str()); + bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && access->GetAccount() != source.nc; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->Mask(); ci->EraseAccess(i - 1); FOREACH_MOD(OnAccessDel, (ci, source, access)); @@ -381,7 +380,7 @@ class CommandCSAccess : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(number); entry[