diff options
author | Adam <Adam@anope.org> | 2016-02-13 14:16:29 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-02-13 14:16:29 -0500 |
commit | 4e2ca31cf5fc874ab928dc4d3735f4345a910d0d (patch) | |
tree | 1590da2a86eb164389dd781870648d8f3824f9a3 /modules/commands | |
parent | addd2a1987dccff6ad4c8a68f5c48c9f850912ec (diff) |
Rewrite access path system to be simplier and use recursion
Show where access is "from" in chanserv/status
Diffstat (limited to 'modules/commands')
-rw-r--r-- | modules/commands/cs_access.cpp | 4 | ||||
-rw-r--r-- | modules/commands/cs_seen.cpp | 9 | ||||
-rw-r--r-- | modules/commands/cs_status.cpp | 21 | ||||
-rw-r--r-- | modules/commands/ns_alist.cpp | 13 |
4 files changed, 38 insertions, 9 deletions
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 543082a2d..6e9b79c6a 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -370,7 +370,7 @@ class CommandCSAccess : public Command if (ci->c) for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) { - ChanAccess::Path p; + ChannelInfo *p; if (access->Matches(cit->second->user, cit->second->user->Account(), p)) timebuf = "Now"; } @@ -407,7 +407,7 @@ class CommandCSAccess : public Command if (ci->c) for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) { - ChanAccess::Path p; + ChannelInfo *p; if (access->Matches(cit->second->user, cit->second->user->Account(), p)) timebuf = "Now"; } diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 41f8ee97c..80bc8e548 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -236,9 +236,14 @@ class CommandSeen : public Command AccessGroup ag = source.c->ci->AccessFor(na->nc); time_t last = 0; - for (unsigned i = 0; i < ag.size(); ++i) + for (unsigned int i = 0; i < ag.paths.size(); ++i) { - ChanAccess *a = ag[i]; + ChanAccess::Path &p = ag.paths[i]; + + if (p.empty()) + continue; + + ChanAccess *a = p[p.size() - 1]; if (a->GetAccount() == na->nc && a->last_seen > last) last = a->last_seen; diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index 28fe60619..b984d5952 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -57,11 +57,26 @@ public: { source.Reply(_("Access for \002%s\002 on \002%s\002:"), nick.c_str(), ci->name.c_str()); - for (unsigned i = 0; i < ag.size(); ++i) + for (unsigned i = 0; i < ag.paths.size(); ++i) { - ChanAccess *acc = ag[i]; + ChanAccess::Path &p = ag.paths[i]; - source.Reply(_("\002%s\002 matches access entry %s, which has privilege %s."), nick.c_str(), acc->Mask().c_str(), acc->AccessSerialize().c_str()); + if (p.empty()) + continue; + + if (p.size() == 1) + { + ChanAccess *acc = p[0]; + + source.Reply(_("\002%s\002 matches access entry %s, which has privilege %s."), nick.c_str(), acc->Mask().c_str(), acc->AccessSerialize().c_str()); + } + else + { + ChanAccess *first = p[0]; + ChanAccess *acc = p[p.size() - 1]; + + source.Reply(_("\002%s\002 matches access entry %s (from entry %s), which has privilege %s."), nick.c_str(), acc->Mask().c_str(), first->Mask().c_str(), acc->AccessSerialize().c_str()); + } } } diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index d273ec59f..6ccbe94ba 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -86,8 +86,17 @@ class CommandNSAList : public Command entry["Number"] = stringify(chan_count); entry["Channel"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name; - for (unsigned j = 0; j < access.size(); ++j) - entry["Access"] = entry["Access"] + ", " + access[j]->AccessSerialize(); + for (unsigned j = 0; j < access.paths.size(); ++j) + { + ChanAccess::Path &p = access.paths[i]; + + // not interested in indirect access + if (p.size() != 1) + continue; + + ChanAccess *a = p[0]; + entry["Access"] = entry["Access"] + ", " + a->AccessSerialize(); + } entry["Access"] = entry["Access"].substr(2); entry["Description"] = ci->desc; list.AddEntry(entry); |