diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.cpp | 2 | ||||
-rw-r--r-- | src/bots.cpp | 2 | ||||
-rw-r--r-- | src/channels.cpp | 38 | ||||
-rw-r--r-- | src/main.cpp | 3 | ||||
-rw-r--r-- | src/modes.cpp | 63 | ||||
-rw-r--r-- | src/regchannel.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 2 |
7 files changed, 28 insertions, 84 deletions
diff --git a/src/actions.cpp b/src/actions.cpp index 2dcd948e7..4d4dd7d0c 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -78,7 +78,7 @@ void common_unban(ChannelInfo *ci, User *u, bool full) std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> bans = ci->c->GetModeList(CMODE_BAN); for (; bans.first != bans.second;) { - Entry ban(bans.first->second); + Entry ban(CMODE_BAN, bans.first->second); ++bans.first; if (ban.Matches(u, full)) ci->c->RemoveMode(NULL, CMODE_BAN, ban.GetMask()); diff --git a/src/bots.cpp b/src/bots.cpp index 7e895a4be..f8d692d74 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -179,7 +179,7 @@ void BotInfo::Join(Channel *c, ChannelStatus *status) /* We check for bans */ for (; bans.first != bans.second; ++bans.first) { - Entry ban(bans.first->second); + Entry ban(CMODE_BAN, bans.first->second); if (ban.Matches(this)) c->RemoveMode(NULL, CMODE_BAN, ban.GetMask()); } diff --git a/src/channels.cpp b/src/channels.cpp index 9a8427bf3..089b3831b 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -1234,9 +1234,10 @@ void MassChannelModes(BotInfo *bi, const Anope::string &modes) static const Anope::string EntryFlagString[] = { "ENTRYTYPE_NONE", "ENTRYTYPE_CIDR", "ENTRYTYPE_NICK_WILD", "ENTRYTYPE_NICK", "ENTRYTYPE_USER_WILD", "ENTRYTYPE_USER", "ENTRYTYPE_HOST_WILD", "ENTRYTYPE_HOST", "" }; /** Constructor + * @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode * @param _host A full nick!ident@host/cidr mask */ -Entry::Entry(const Anope::string &_host) : Flags<EntryType>(EntryFlagString) +Entry::Entry(ChannelModeName mode, const Anope::string &_host) : Flags<EntryType>(EntryFlagString), modename(mode) { this->SetFlag(ENTRYTYPE_NONE); this->cidr_len = 0; @@ -1330,8 +1331,7 @@ const Anope::string Entry::GetMask() */ bool Entry::Matches(User *u, bool full) const { - if (!this->FlagCount()) - return false; + bool ret = true; if (this->HasFlag(ENTRYTYPE_CIDR)) { @@ -1339,39 +1339,43 @@ bool Entry::Matches(User *u, bool full) const { cidr cidr_mask(this->host, this->cidr_len); if (!u->ip() || !cidr_mask.match(u->ip)) - { - return false; - } + ret = false; /* If we're not matching fully and their displayed host isnt their IP */ else if (!full && u->ip.addr() != u->GetDisplayedHost()) - { - return false; - } + ret = false; } catch (const SocketException &) { - return false; + ret = false; } } if (this->HasFlag(ENTRYTYPE_NICK) && !this->nick.equals_ci(u->nick)) - return false; + ret = false; if (this->HasFlag(ENTRYTYPE_USER) && !this->user.equals_ci(u->GetVIdent()) && (!full || !this->user.equals_ci(u->GetIdent()))) - return false; + ret = false; if (this->HasFlag(ENTRYTYPE_HOST) && !this->host.equals_ci(u->GetDisplayedHost()) && (!full || (!this->host.equals_ci(u->host) && !this->host.equals_ci(u->chost) && !this->host.equals_ci(u->vhost) && (!u->ip() || !this->host.equals_ci(u->ip.addr()))))) - return false; + ret = false; if (this->HasFlag(ENTRYTYPE_NICK_WILD) && !Anope::Match(u->nick, this->nick)) - return false; + ret = false; if (this->HasFlag(ENTRYTYPE_USER_WILD) && !Anope::Match(u->GetVIdent(), this->user) && (!full || !Anope::Match(u->GetIdent(), this->user))) - return false; + ret = false; if (this->HasFlag(ENTRYTYPE_HOST_WILD) && !Anope::Match(u->GetDisplayedHost(), this->host) && (!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->chost, this->host) && !Anope::Match(u->vhost, this->host) && (!u->ip() || !Anope::Match(u->ip.addr(), this->host))))) - return false; + ret = false; + + ChannelMode *cm = ModeManager::FindChannelModeByName(this->modename); + if (cm != NULL && cm->Type == MODE_LIST) + { + ChannelModeList *cml = debug_cast<ChannelModeList *>(cm); + if (cml->Matches(u, this)) + ret = true; + } - return true; + return ret; } diff --git a/src/main.cpp b/src/main.cpp index 563262195..eea96dee9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -491,7 +491,8 @@ int main(int ac, char **av, char **envp) threadEngine.Process(); /* Process any modes that need to be (un)set */ - ModeManager::ProcessModes(); + if (Me != NULL && Me->IsSynced()) + ModeManager::ProcessModes(); /* Process the socket engine */ SocketEngine->Process(); diff --git a/src/modes.cpp b/src/modes.cpp index 76b05422a..dd147118c 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -294,7 +294,7 @@ void ChannelModeBan::OnAdd(Channel *chan, const Anope::string &mask) { BotInfo *bi = chan->ci->bi; - Entry ban(mask); + Entry ban(CMODE_BAN, mask); if (ban.Matches(bi)) chan->RemoveMode(NULL, CMODE_BAN, mask); } @@ -302,67 +302,6 @@ void ChannelModeBan::OnAdd(Channel *chan, const Anope::string &mask) Log(LOG_DEBUG) << "Added ban " << mask << " to channel " << chan->name; } -/** Remove a ban from the channel - * @param chan The channel - * @param mask The ban - */ -void ChannelModeBan::OnDel(Channel *chan, const Anope::string &mask) -{ - if (!chan || mask.empty()) - return; - - Log(LOG_DEBUG) << "Deleted ban " << mask << " from channel " << chan->name; -} - -/** Add an except to the channel - * @param chan The channel - * @param mask The except - */ -void ChannelModeExcept::OnAdd(Channel *chan, const Anope::string &mask) -{ - if (!chan || mask.empty()) - return; - - Log(LOG_DEBUG) << "Added except " << mask << " to channel " << chan->name; -} - -/** Remove an except from the channel - * @param chan The channel - * @param mask The except - */ -void ChannelModeExcept::OnDel(Channel *chan, const Anope::string &mask) -{ - if (!chan || mask.empty()) - return; - - Log(LOG_DEBUG) << "Deleted except " << mask << " to channel " << chan->name; -} - -/** Add an invex to the channel - * @param chan The channel - * @param mask The invex - */ -void ChannelModeInvex::OnAdd(Channel *chan, const Anope::string &mask) -{ - if (!chan || mask.empty()) - return; - - Log(LOG_DEBUG) << "Added invite " << mask << " to channel " << chan->name; - -} - -/** Remove an invex from the channel - * @param chan The channel - * @param mask The index - */ -void ChannelModeInvex::OnDel(Channel *chan, const Anope::string &mask) -{ - if (!chan || mask.empty()) - return; - - Log(LOG_DEBUG) << "Deleted invite " << mask << " to channel " << chan->name; -} - void StackerInfo::AddMode(Mode *mode, bool Set, const Anope::string &Param) { ChannelMode *cm = NULL; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 1da17530f..20cfc7aed 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -762,7 +762,7 @@ bool ChannelInfo::CheckKick(User *user) } else { - Entry akick_mask(autokick->mask); + Entry akick_mask(CMODE_BEGIN, autokick->mask); if (akick_mask.Matches(user)) do_kick = true; } diff --git a/src/users.cpp b/src/users.cpp index a11e1b5ce..e343e3ad2 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -870,7 +870,7 @@ bool matches_list(Channel *c, User *user, ChannelModeName mode) std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> modes = c->GetModeList(mode); for (; modes.first != modes.second; ++modes.first) { - Entry e(modes.first->second); + Entry e(mode, modes.first->second); if (e.Matches(user)) return true; } |