diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/chanserv/access.cpp | 22 | ||||
| -rw-r--r-- | modules/chanserv/main/chanaccess.cpp | 20 | ||||
| -rw-r--r-- | modules/chanserv/mode.cpp | 29 | ||||
| -rw-r--r-- | modules/memoserv/main/memoserv.cpp | 33 | ||||
| -rw-r--r-- | modules/memoserv/read.cpp | 12 | ||||
| -rw-r--r-- | modules/nickserv/main/account.cpp | 9 | ||||
| -rw-r--r-- | modules/nickserv/main/account.h | 4 | ||||
| -rw-r--r-- | modules/nickserv/main/accounttype.cpp | 1 | ||||
| -rw-r--r-- | modules/nickserv/main/accounttype.h | 1 | ||||
| -rw-r--r-- | modules/nickserv/register.cpp | 4 | ||||
| -rw-r--r-- | modules/operserv/list.cpp | 9 | ||||
| -rw-r--r-- | modules/protocol/charybdis.cpp | 1 | ||||
| -rw-r--r-- | modules/protocol/plexus.cpp | 36 | ||||
| -rw-r--r-- | modules/sqlite.cpp | 6 |
14 files changed, 143 insertions, 44 deletions
diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index a29524a73..8342e5973 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -60,20 +60,20 @@ class AccessChanAccessImpl : public AccessChanAccess } } - bool operator>(ChanServ::ChanAccess &other) override + int Compare(ChanAccess *other) override { - if (this->GetSerializableType() != other.GetSerializableType()) - return ChanServ::ChanAccess::operator>(other); - else - return this->GetLevel() > anope_dynamic_static_cast<AccessChanAccess *>(&other)->GetLevel(); - } + if (this->GetSerializableType() != other->GetSerializableType()) + return ChanAccess::Compare(other); - bool operator<(ChanServ::ChanAccess &other) override - { - if (this->GetSerializableType() != other.GetSerializableType()) - return ChanAccess::operator<(other); + int lev = this->GetLevel(); + int theirlev = anope_dynamic_static_cast<AccessChanAccess *>(other)->GetLevel(); + + if (lev > theirlev) + return 1; + else if (lev < theirlev) + return -1; else - return this->GetLevel() < anope_dynamic_static_cast<AccessChanAccess *>(&other)->GetLevel(); + return 0; } }; diff --git a/modules/chanserv/main/chanaccess.cpp b/modules/chanserv/main/chanaccess.cpp index f2b170989..bc2778bc3 100644 --- a/modules/chanserv/main/chanaccess.cpp +++ b/modules/chanserv/main/chanaccess.cpp @@ -110,3 +110,23 @@ bool ChanAccessImpl::Matches(const User *u, NickServ::Account *acc) return false; } + +int ChanAccessImpl::Compare(ChanAccess *other) +{ + const std::vector<ChanServ::Privilege> &privs = ChanServ::service->GetPrivileges(); + for (unsigned int i = privs.size(); i > 0; --i) + { + bool this_p = this->HasPriv(privs[i - 1].name), + other_p = other->HasPriv(privs[i - 1].name); + + if (!this_p && !other_p) + continue; + + if (this_p && !other_p) + return 1; + else if (!this_p && other_p) + return -1; + } + + return 0; +} diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp index f0acd8456..7687c3576 100644 --- a/modules/chanserv/mode.cpp +++ b/modules/chanserv/mode.cpp @@ -334,6 +334,12 @@ class CommandCSMode : public Command break; } + if (cm->type == MODE_STATUS && !CanSet(source, ci, cm, false)) + { + source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), cm->name, ci->GetName()); + break; + } + if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c)) { source.Reply(_("List for mode \002{0}\002 is full."), cm->mchar); @@ -492,9 +498,6 @@ class CommandCSMode : public Command spacesepstream sep(params.size() > 3 ? params[3] : ""); Anope::string modes = params[2], param; - logger.Command(source, ci, _("{source} used {command} on {channel} to set {3}"), - params[2] + (params.size() > 3 ? " " + params[3] : "")); - int adding = -1; for (size_t i = 0; i < modes.length(); ++i) { @@ -560,20 +563,19 @@ class CommandCSMode : public Command if (param.find_first_of("*?") != Anope::string::npos) { - if (!this->CanSet(source, ci, cm, false) && !source.IsOverride()) + if (!this->CanSet(source, ci, cm, false) && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("You do not have access to set mode \002{0}\002."), cm->mchar); break; } - for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end;) + for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) { ChanUserContainer *uc = it->second; - ++it; ChanServ::AccessGroup targ_access = ci->AccessFor(uc->user); - if (uc->user->IsProtected() || (ci->IsPeace() && targ_access >= u_access && !source.IsOverride())) + if (uc->user->IsProtected() || (ci->IsPeace() && targ_access >= u_access && !source.HasOverridePriv("chanserv/administration"))) { source.Reply(_("You do not have the access to change the modes of \002{0}\002."), uc->user->nick.c_str()); continue; @@ -591,13 +593,13 @@ class CommandCSMode : public Command else { User *target = User::Find(param, true); - if (target == NULL) + if (target == nullptr) { source.Reply(_("User \002{0}\002 isn't currently online."), param); break; } - if (!this->CanSet(source, ci, cm, source.GetUser() == target) && !source.IsOverride()) + if (!this->CanSet(source, ci, cm, source.GetUser() == target) && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("You do not have access to set mode \002{0}\002."), cm->mchar); break; @@ -606,12 +608,13 @@ class CommandCSMode : public Command if (source.GetUser() != target) { ChanServ::AccessGroup targ_access = ci->AccessFor(target); - if (ci->IsPeace() && targ_access >= u_access && !source.IsOverride()) + if (ci->IsPeace() && targ_access >= u_access && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("You do not have the access to change the modes of \002{0}\002"), target->nick); break; } - else if (target->IsProtected()) + + if (target->IsProtected()) { source.Reply(_("Access denied. \002{0}\002 is protected and can not have their modes changed."), target->nick); break; @@ -645,6 +648,10 @@ class CommandCSMode : public Command } } } + + logger.Command(source, ci, _("{source} used {command} on {channel} to set {0}"), + params[2] + (params.size() > 3 ? " " + params[3] : "")); + } void DoClear(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) diff --git a/modules/memoserv/main/memoserv.cpp b/modules/memoserv/main/memoserv.cpp index 757b95563..833a32f68 100644 --- a/modules/memoserv/main/memoserv.cpp +++ b/modules/memoserv/main/memoserv.cpp @@ -95,18 +95,29 @@ class MemoServCore : public Module, public MemoServ::MemoServService if (mi == NULL) return MEMO_INVALID_TARGET; + Anope::string sender_display = source; + User *sender = User::Find(source, true); - if (sender != NULL && !sender->HasPriv("memoserv/no-limit") && !force) + if (sender != NULL) { - time_t send_delay = Config->GetModule("memoserv/main")->Get<time_t>("senddelay"); - if (send_delay > 0 && sender->lastmemosend + send_delay > Anope::CurTime) - return MEMO_TOO_FAST; - if (!mi->GetMemoMax()) - return MEMO_TARGET_FULL; - if (mi->GetMemoMax() > 0 && mi->GetMemos().size() >= static_cast<unsigned>(mi->GetMemoMax())) - return MEMO_TARGET_FULL; - if (mi->HasIgnore(sender)) - return MEMO_SUCCESS; + if (!sender->HasPriv("memoserv/no-limit") && !force) + { + time_t send_delay = Config->GetModule("memoserv/main")->Get<time_t>("senddelay"); + if (send_delay > 0 && sender->lastmemosend + send_delay > Anope::CurTime) + return MEMO_TOO_FAST; + if (!mi->GetMemoMax()) + return MEMO_TARGET_FULL; + if (mi->GetMemoMax() > 0 && mi->GetMemos().size() >= static_cast<unsigned>(mi->GetMemoMax())) + return MEMO_TARGET_FULL; + if (mi->HasIgnore(sender)) + return MEMO_SUCCESS; + } + + NickServ::Account *acc = sender->Account(); + if (acc != NULL) + { + sender_display = acc->GetDisplay(); + } } if (sender != NULL) @@ -114,7 +125,7 @@ class MemoServCore : public Module, public MemoServ::MemoServService MemoServ::Memo *m = Serialize::New<MemoServ::Memo *>(); m->SetMemoInfo(mi); - m->SetSender(source); + m->SetSender(sender_display); m->SetTime(Anope::CurTime); m->SetText(message); m->SetUnread(true); diff --git a/modules/memoserv/read.cpp b/modules/memoserv/read.cpp index 706682a32..4eff0a2b3 100644 --- a/modules/memoserv/read.cpp +++ b/modules/memoserv/read.cpp @@ -88,7 +88,7 @@ class CommandMSRead : public Command CommandMSRead(Module *creator) : Command(creator, "memoserv/read", 1, 2) { this->SetDesc(_("Read a memo or memos")); - this->SetSyntax(_("[\037channel\037] {\037num\037 | \037list\037 | LAST | NEW}")); + this->SetSyntax(_("[\037channel\037] {\037num\037 | \037list\037 | LAST | NEW | ALL}")); } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override @@ -122,7 +122,7 @@ class CommandMSRead : public Command mi = source.nc->GetMemos(); } - if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && numstr.find_first_not_of("0123456789.,-") != Anope::string::npos)) + if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && !numstr.equals_ci("ALL") && numstr.find_first_not_of("0123456789.,-") != Anope::string::npos)) { this->OnSyntaxError(source, numstr); return; @@ -166,6 +166,13 @@ class CommandMSRead : public Command for (i = 0, end = memos.size() - 1; i < end; ++i); DoRead(source, mi, ci, i); } + else if (numstr.equals_ci("ALL")) + { + for (i = 0, end = memos.size(); i < end; ++i) + { + DoRead(source, mi, ci, i); + } + } else /* number[s] */ { bool shown = false; @@ -191,6 +198,7 @@ class CommandMSRead : public Command source.Reply(_("Sends you the text of the memos specified." " If LAST is given, sends you the memo you most recently received." " If NEW is given, sends you all of your new memos." + " If ALL is given, sends you all of your memos." " Otherwise, sends you memo number \037num\037." " You can also give a list of numbers, as in the example:\n" "\n" diff --git a/modules/nickserv/main/account.cpp b/modules/nickserv/main/account.cpp index 86c96b14f..9200bc1f7 100644 --- a/modules/nickserv/main/account.cpp +++ b/modules/nickserv/main/account.cpp @@ -314,3 +314,12 @@ unsigned int AccountImpl::GetChannelCount() return i; } +time_t AccountImpl::GetLastMail() +{ + return Get(&AccountType::last_mail); +} + +void AccountImpl::SetLastMail(time_t lastmail) +{ + Set(&AccountType::last_mail, lastmail); +} diff --git a/modules/nickserv/main/account.h b/modules/nickserv/main/account.h index ba07a2a13..6cb65e759 100644 --- a/modules/nickserv/main/account.h +++ b/modules/nickserv/main/account.h @@ -37,6 +37,7 @@ class AccountImpl : public NickServ::Account Serialize::Storage<bool> secure; Serialize::Storage<bool> memosignon, memoreceive, memomail; Serialize::Storage<bool> hideemail, hidemask, hidestatus, hidequit; + Serialize::Storage<time_t> lastmail; public: using NickServ::Account::Account; @@ -116,4 +117,7 @@ class AccountImpl : public NickServ::Account void SetDisplay(NickServ::Nick *na) override; bool IsOnAccess(User *u) override; unsigned int GetChannelCount() override; + + time_t GetLastMail() override; + void SetLastMail(time_t) override; }; diff --git a/modules/nickserv/main/accounttype.cpp b/modules/nickserv/main/accounttype.cpp index ccc02726a..e6509694f 100644 --- a/modules/nickserv/main/accounttype.cpp +++ b/modules/nickserv/main/accounttype.cpp @@ -43,6 +43,7 @@ AccountType::AccountType(Module *me) : Serialize::Type<AccountImpl>(me) , hidemask(this, "hide_mask", &AccountImpl::hidemask) , hidestatus(this, "hide_status", &AccountImpl::hidestatus) , hidequit(this, "hide_quit", &AccountImpl::hidequit) + , last_mail(this, "last_mail", &AccountImpl::lastmail) { } diff --git a/modules/nickserv/main/accounttype.h b/modules/nickserv/main/accounttype.h index f8d6a31a5..f749a5430 100644 --- a/modules/nickserv/main/accounttype.h +++ b/modules/nickserv/main/accounttype.h @@ -39,6 +39,7 @@ class AccountType : public Serialize::Type<AccountImpl> Serialize::Field<AccountImpl, bool> unconfirmed, _private, autoop, keepmodes, killprotect, killquick, killimmed, msg, secure, memosignon, memoreceive, memomail, hideemail, hidemask, hidestatus, hidequit; + Serialize::Field<AccountImpl, time_t> last_mail; AccountType(Module *); diff --git a/modules/nickserv/register.cpp b/modules/nickserv/register.cpp index cb6f85dc5..13c18e0b3 100644 --- a/modules/nickserv/register.cpp +++ b/modules/nickserv/register.cpp @@ -339,7 +339,7 @@ class CommandNSResend : public Command return; } - if (Anope::CurTime < source.nc->lastmail + Config->GetModule(this->GetOwner())->Get<time_t>("resenddelay")) + if (Anope::CurTime < source.nc->GetLastMail() + Config->GetModule(this->GetOwner())->Get<time_t>("resenddelay")) { source.Reply(_("Cannot send mail now; please retry a little later.")); return; @@ -351,7 +351,7 @@ class CommandNSResend : public Command return; } - na->GetAccount()->lastmail = Anope::CurTime; + na->GetAccount()->SetLastMail(Anope::CurTime); source.Reply(_("Your passcode has been re-sent to \002{0}\002."), na->GetAccount()->GetEmail()); logger.Command(LogType::COMMAND, source, _("{source} used {command} to resend registration verification code")); } diff --git a/modules/operserv/list.cpp b/modules/operserv/list.cpp index 39ca2288b..77eaf56ed 100644 --- a/modules/operserv/list.cpp +++ b/modules/operserv/list.cpp @@ -182,8 +182,13 @@ class CommandOSUserList : public Command if (!pattern.empty()) { - Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + u2->ip.addr(); - if (!Anope::Match(mask, pattern) && !Anope::Match(mask2, pattern) && !Anope::Match(mask3, pattern)) + Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), + mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, + mask3 = u2->nick + "!" + u2->GetIdent() + "@" + u2->ip.addr(); + + if (!Anope::Match(mask, pattern, false, true) + && !Anope::Match(mask2, pattern, false, true) + && !Anope::Match(mask3, pattern, false, true)) continue; if (!modes.empty()) for (std::set<Anope::string>::iterator mit = modes.begin(), mit_end = modes.end(); mit != mit_end; ++mit) diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index a808bb594..4b97e72f5 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -43,6 +43,7 @@ void charybdis::senders::NickIntroduction::Send(User *user) Anope::string modes = "+" + user->GetModes(); Uplink::Send(Me, "EUID", user->nick, 1, user->timestamp, modes, user->GetIdent(), user->host, 0, user->GetUID(), "*", "*", user->realname); } + void charybdis::senders::SASL::Send(const ::SASL::Message& message) { Server *s = Server::Find(message.target.substr(0, 3)); diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 68c23f18e..6788cabe0 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -20,6 +20,7 @@ /* Dependencies: anope_protocol.ratbox */ #include "module.h" +#include "modules/sasl.h" #include "modules/protocol/plexus.h" #include "modules/protocol/hybrid.h" #include "modules/protocol/ratbox.h" @@ -44,6 +45,14 @@ void plexus::senders::NOOP::Send(Server* server, bool mode) Uplink::Send("ENCAP", server->GetName(), "SVSNOOP", (mode ? "+" : "-")); } +void plexus::senders::SASL::Send(const ::SASL::Message& message) +{ + Anope::string sid = message.target.substr(0, 3); + Server *s = Server::Find(sid); + Uplink::Send(Me, "ENCAP", s ? s->GetName() : sid, "SASL", + message.source, message.target, message.type, message.data, message.ext.empty() ? "" : message.ext); +} + void plexus::senders::Topic::Send(const MessageSource &source, Channel *channel, const Anope::string &topic, time_t topic_ts, const Anope::string &topic_setter) { Uplink::Send(source, "ENCAP", "*", "TOPIC", channel->name, topic_setter, topic_ts, topic); @@ -54,6 +63,14 @@ void plexus::senders::SVSJoin::Send(const MessageSource& source, User* user, con Uplink::Send(source, "ENCAP", user->server->GetName(), "SVSJOIN", user->GetUID(), chan); } +void plexus::senders::SVSLogin::Send(const Anope::string& uid, const Anope::string& acc, const Anope::string& vident, const Anope::string& vhost) +{ + Anope::string sid = uid.substr(0, 3); + Server *s = Server::Find(sid); + + Uplink::Send(Me, "ENCAP", s ? s->GetName() : sid, "SVSLOGIN", uid, "*", vident.empty() ? "*" : vident, vhost.empty() ? "*" : vhost, acc); +} + void plexus::senders::SVSNick::Send(User* u, const Anope::string& newnick, time_t ts) { Uplink::Send(Me, "ENCAP", u->server->GetName(), "SVSNICK", u->GetUID(), u->timestamp, newnick, ts); @@ -79,7 +96,7 @@ void plexus::senders::VhostSet::Send(User* u, const Anope::string& vident, const plexus::Proto::Proto(Module *creator) : ts6::Proto(creator, "Plexus 4") { - DefaultPseudoclientModes = "+oiU"; + DefaultPseudoclientModes = "+iU"; CanSVSNick = true; CanSVSJoin = true; CanSetVHost = true; @@ -168,7 +185,18 @@ void plexus::Encap::Run(MessageSource &source, const std::vector<Anope::string> EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u); } } - return; + + else if (params[1] == "SASL" && sasl && params.size() >= 6) + { + SASL::Message m; + m.source = params[2]; + m.target = params[3]; + m.type = params[4]; + m.data = params[5]; + m.ext = params.size() > 6 ? params[6] : ""; + + sasl->ProcessMessage(m); + } } struct IRCDMessagePass : IRCDMessage @@ -308,7 +336,9 @@ class ProtoPlexus : public Module plexus::senders::ModeUser sender_mode_user; plexus::senders::NickIntroduction sender_nickintroduction; plexus::senders::NOOP sender_noop; + plexus::senders::SASL sender_sasl; plexus::senders::SVSJoin sender_svsjoin; + plexus::senders::SVSLogin sender_svslogin; plexus::senders::SVSNick sender_svsnick; plexus::senders::SVSPart sender_svspart; plexus::senders::Topic sender_topic; @@ -367,6 +397,7 @@ class ProtoPlexus : public Module , sender_nickchange(this) , sender_nickintroduction(this) , sender_noop(this) + , sender_sasl(this) , sender_notice(this) , sender_part(this) , sender_ping(this) @@ -380,6 +411,7 @@ class ProtoPlexus : public Module , sender_svshold(this) , sender_svsholddel(this) , sender_svsjoin(this) + , sender_svslogin(this) , sender_svsnick(this) , sender_svspart(this) , sender_topic(this) diff --git a/modules/sqlite.cpp b/modules/sqlite.cpp index 95af6e39a..41123adb3 100644 --- a/modules/sqlite.cpp +++ b/modules/sqlite.cpp @@ -86,7 +86,7 @@ class SQLiteService : public Provider void Run(Interface *i, const Query &query) override; - Result RunQuery(const Query &query); + Result RunQuery(const Query &query) override; std::vector<Query> InitSchema(const Anope::string &prefix) override; std::vector<Query> Replace(const Anope::string &table, const Query &, const std::set<Anope::string> &) override; @@ -100,7 +100,7 @@ class SQLiteService : public Provider Serialize::ID GetID(const Anope::string &prefix, const Anope::string &type) override; - Query GetTables(const Anope::string &prefix); + Query GetTables(const Anope::string &prefix) override; Anope::string BuildQuery(const Query &q); @@ -113,7 +113,7 @@ class ModuleSQLite : public Module std::map<Anope::string, SQLiteService *> SQLiteServices; public: - ModuleSQLite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + ModuleSQLite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) { } |
