diff options
Diffstat (limited to 'modules/chanserv')
| -rw-r--r-- | modules/chanserv/access.cpp | 9 | ||||
| -rw-r--r-- | modules/chanserv/flags.cpp | 59 | ||||
| -rw-r--r-- | modules/chanserv/main/chanaccess.cpp | 16 | ||||
| -rw-r--r-- | modules/chanserv/main/chanaccesstype.h | 4 | ||||
| -rw-r--r-- | modules/chanserv/xop.cpp | 61 |
5 files changed, 39 insertions, 110 deletions
diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index 44d21734e..a29524a73 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -202,7 +202,7 @@ class CommandCSAccess : public Command access = Serialize::New<AccessChanAccess *>(); if (na) - access->SetObj(na->GetAccount()); + access->SetAccount(na->GetAccount()); access->SetChannel(ci); access->SetMask(mask); access->SetCreator(source.GetNick()); @@ -263,7 +263,7 @@ class CommandCSAccess : public Command ChanServ::AccessGroup ag = source.AccessFor(ci); ChanServ::ChanAccess *u_highest = ag.Highest(); - if ((!u_highest || *u_highest <= *access) && !ag.founder && !source.IsOverride() && access->GetObj() != source.nc) + if ((!u_highest || *u_highest <= *access) && !ag.founder && !source.IsOverride() && access->GetAccount() != source.nc) { denied = true; return; @@ -305,7 +305,7 @@ class CommandCSAccess : public Command ChanServ::ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->Mask())) { - if (access->GetObj() != source.nc && !u_access.founder && (!highest || *highest <= *access) && !source.HasOverridePriv("chanserv/access/modify")) + if (access->GetAccount() != source.nc && !u_access.founder && (!highest || *highest <= *access) && !source.HasOverridePriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to remove the access of \002{1}\002."), ci->GetName(), access->Mask()); } @@ -555,9 +555,6 @@ class CommandCSAccess : public Command " Use of this command requires the \002{4}\002 privilege on \037channel\037."), source.GetCommand(), ChanServ::ACCESS_INVALID + 1, ChanServ::ACCESS_FOUNDER - 1, "AUTOOP", "ACCESS_CHANGE"); - if (!Config->GetModule("chanserv/main")->Get<bool>("disallow_channel_access")) - source.Reply(_("The given \037mask\037 may also be a channel, which will use the access list from the other channel up to the given \037level\037.")); - //XXX show def levels source.Reply(_("\n" diff --git a/modules/chanserv/flags.cpp b/modules/chanserv/flags.cpp index 6ec65d104..f535aa136 100644 --- a/modules/chanserv/flags.cpp +++ b/modules/chanserv/flags.cpp @@ -108,55 +108,28 @@ class CommandCSFlags : public Command ChanServ::AccessGroup u_access = source.AccessFor(ci); ChanServ::ChanAccess *highest = u_access.Highest(); - NickServ::Nick *na = nullptr; - ChanServ::Channel *targ_ci = nullptr; - - if (IRCD->IsChannelValid(mask)) + NickServ::Nick *na = NickServ::FindNick(mask); + if (!na && Config->GetModule("chanserv/main")->Get<bool>("disallow_hostmask_access")) { - if (Config->GetModule("chanserv/main")->Get<bool>("disallow_channel_access")) - { - source.Reply(_("Channels may not be on access lists.")); - return; - } - - targ_ci = ChanServ::Find(mask); - if (targ_ci == NULL) - { - source.Reply(_("Channel \002{0}\002 isn't registered."), mask); - return; - } - else if (ci == targ_ci) - { - source.Reply(_("You can't add a channel to its own access list.")); - return; - } - - mask = targ_ci->GetName(); + source.Reply(_("Masks and unregistered users may not be on access lists.")); + return; } - else + + if (mask.find_first_of("!*@") == Anope::string::npos && !na) { - na = NickServ::FindNick(mask); - if (!na && Config->GetModule("chanserv/main")->Get<bool>("disallow_hostmask_access")) + User *targ = User::Find(mask, true); + if (targ != NULL) + mask = "*!*@" + targ->GetDisplayedHost(); + else { - source.Reply(_("Masks and unregistered users may not be on access lists.")); + source.Reply(_("\002{0}\002 isn't registered."), mask); return; } - else if (mask.find_first_of("!*@") == Anope::string::npos && !na) - { - User *targ = User::Find(mask, true); - if (targ != NULL) - mask = "*!*@" + targ->GetDisplayedHost(); - else - { - source.Reply(_("\002{0}\002 isn't registered."), mask); - return; - } - } - - if (na) - mask = na->GetNick(); } + if (na) + mask = na->GetNick(); + ChanServ::ChanAccess *current = NULL; unsigned current_idx; std::set<char> current_flags; @@ -275,9 +248,7 @@ class CommandCSFlags : public Command FlagsChanAccess *access = Serialize::New<FlagsChanAccess *>(); if (na) - access->SetObj(na->GetAccount()); - else if (targ_ci) - access->SetObj(targ_ci); + access->SetAccount(na->GetAccount()); access->SetChannel(ci); access->SetMask(mask); access->SetCreator(source.GetNick()); diff --git a/modules/chanserv/main/chanaccess.cpp b/modules/chanserv/main/chanaccess.cpp index 75c70ed9c..f2b170989 100644 --- a/modules/chanserv/main/chanaccess.cpp +++ b/modules/chanserv/main/chanaccess.cpp @@ -71,14 +71,14 @@ void ChanAccessImpl::SetMask(const Anope::string &n) Object::Set(&ChanAccessType<ChanServ::ChanAccess>::mask, n); } -Serialize::Object *ChanAccessImpl::GetObj() +NickServ::Account *ChanAccessImpl::GetAccount() { - return Get(&ChanAccessType<ChanServ::ChanAccess>::obj); + return Get(&ChanAccessType<ChanServ::ChanAccess>::account); } -void ChanAccessImpl::SetObj(Serialize::Object *o) +void ChanAccessImpl::SetAccount(NickServ::Account *acc) { - Object::Set(&ChanAccessType<ChanServ::ChanAccess>::obj, o); + Object::Set(&ChanAccessType<ChanServ::ChanAccess>::account, acc); } Anope::string ChanAccessImpl::Mask() @@ -89,14 +89,6 @@ Anope::string ChanAccessImpl::Mask() return GetMask(); } -NickServ::Account *ChanAccessImpl::GetAccount() -{ - if (!GetObj() || GetObj()->GetSerializableType()->GetName() != NickServ::Account::NAME) - return nullptr; - - return anope_dynamic_static_cast<NickServ::Account *>(GetObj()); -} - bool ChanAccessImpl::Matches(const User *u, NickServ::Account *acc) { if (this->GetAccount()) diff --git a/modules/chanserv/main/chanaccesstype.h b/modules/chanserv/main/chanaccesstype.h index b93747be7..4d95ee8b7 100644 --- a/modules/chanserv/main/chanaccesstype.h +++ b/modules/chanserv/main/chanaccesstype.h @@ -25,7 +25,7 @@ class ChanAccessType : public Serialize::Type<T> public: Serialize::ObjectField<ChanServ::ChanAccess, ChanServ::Channel *> channel; Serialize::Field<ChanServ::ChanAccess, Anope::string> mask; - Serialize::ObjectField<ChanServ::ChanAccess, Serialize::Object *> obj; + Serialize::ObjectField<ChanServ::ChanAccess, NickServ::Account *> account; Serialize::Field<ChanServ::ChanAccess, Anope::string> creator; Serialize::Field<ChanServ::ChanAccess, time_t> last_seen; Serialize::Field<ChanServ::ChanAccess, time_t> created; @@ -33,7 +33,7 @@ class ChanAccessType : public Serialize::Type<T> ChanAccessType(Module *me) : Serialize::Type<T>(me) , channel(this, "channel", &ChanServ::ChanAccess::channel, true) , mask(this, "mask", &ChanServ::ChanAccess::mask) - , obj(this, "obj", &ChanServ::ChanAccess::object, true) + , account(this, "account", &ChanServ::ChanAccess::account, true) , creator(this, "creator", &ChanServ::ChanAccess::creator) , last_seen(this, "last_seen", &ChanServ::ChanAccess::last_seen) , created(this, "created", &ChanServ::ChanAccess::created) diff --git a/modules/chanserv/xop.cpp b/modules/chanserv/xop.cpp index 91fc7e4f1..d41ed7ae6 100644 --- a/modules/chanserv/xop.cpp +++ b/modules/chanserv/xop.cpp @@ -153,58 +153,29 @@ class CommandCSXOP : public Command } } - NickServ::Nick *na = nullptr; - ChanServ::Channel *targ_ci = nullptr; + NickServ::Nick *na = NickServ::FindNick(mask); - if (IRCD->IsChannelValid(mask)) + if (!na && Config->GetModule("chanserv/main")->Get<bool>("disallow_hostmask_access")) { - if (Config->GetModule("chanserv/main")->Get<bool>("disallow_channel_access")) - { - source.Reply(_("Channels may not be on access lists.")); - return; - } - - targ_ci = ChanServ::Find(mask); - if (targ_ci == NULL) - { - source.Reply(_("Channel \002{0}\002 isn't registered."), mask); - return; - } - - if (ci == targ_ci) - { - source.Reply(_("You can't add a channel to its own access list.")); - return; - } - - mask = targ_ci->GetName(); + source.Reply(_("Masks and unregistered users may not be on access lists.")); + return; } - else - { - na = NickServ::FindNick(mask); - if (!na && Config->GetModule("chanserv/main")->Get<bool>("disallow_hostmask_access")) + if (mask.find_first_of("!*@") == Anope::string::npos && !na) + { + User *targ = User::Find(mask, true); + if (targ != NULL) + mask = "*!*@" + targ->GetDisplayedHost(); + else { - source.Reply(_("Masks and unregistered users may not be on access lists.")); + source.Reply(_("\002{0}\002 isn't registered."), mask); return; } - - if (mask.find_first_of("!*@") == Anope::string::npos && !na) - { - User *targ = User::Find(mask, true); - if (targ != NULL) - mask = "*!*@" + targ->GetDisplayedHost(); - else - { - source.Reply(_("\002{0}\002 isn't registered."), mask); - return; - } - } - - if (na) - mask = na->GetNick(); } + if (na) + mask = na->GetNick(); + for (unsigned i = 0; i < ci->GetAccessCount(); ++i) { ChanServ::ChanAccess *a = ci->GetAccess(i); @@ -231,9 +202,7 @@ class CommandCSXOP : public Command XOPChanAccess *acc = Serialize::New<XOPChanAccess *>(); if (na) - acc->SetObj(na->GetAccount()); - else if (targ_ci) - acc->SetObj(targ_ci); + acc->SetAccount(na->GetAccount()); acc->SetChannel(ci); acc->SetMask(mask); acc->SetCreator(source.GetNick()); |
