Anope IRC Services  Version 2.0
modes.cpp
Go to the documentation of this file.
1 /* Mode support
2  *
3  * Copyright (C) 2008-2011 Adam <Adam@anope.org>
4  * Copyright (C) 2008-2014 Anope Team <team@anope.org>
5  *
6  * Please read COPYING and README for further details.
7  *
8  */
9 
10 #include "services.h"
11 #include "modules.h"
12 #include "config.h"
13 #include "sockets.h"
14 #include "protocol.h"
15 #include "channels.h"
16 #include "uplink.h"
17 
18 struct StackerInfo;
19 
20 /* List of pairs of user/channels and their stacker info */
21 static std::map<User *, StackerInfo *> UserStackerObjects;
22 static std::map<Channel *, StackerInfo *> ChannelStackerObjects;
23 
24 /* Array of all modes Anope knows about.*/
25 static std::vector<ChannelMode *> ChannelModes;
26 static std::vector<UserMode *> UserModes;
27 
28 /* Modes are in this array are at position
29  * modechar. Additionally, status modes are in this array (again) at statuschar.
30  */
31 static std::vector<ChannelMode *> ChannelModesIdx;
32 static std::vector<UserMode *> UserModesIdx;
33 
34 static std::map<Anope::string, ChannelMode *> ChannelModesByName;
35 static std::map<Anope::string, UserMode *> UserModesByName;
36 
37 /* Sorted by status */
38 static std::vector<ChannelModeStatus *> ChannelModesByStatus;
39 
40 /* Number of generic modes we support */
42 
44 {
45  /* Modes to be added */
46  std::list<std::pair<Mode *, Anope::string> > AddModes;
47  /* Modes to be deleted */
48  std::list<std::pair<Mode *, Anope::string> > DelModes;
49  /* Bot this is sent from */
51 
52  StackerInfo() : bi(NULL) { }
53 
59  void AddMode(Mode *mode, bool set, const Anope::string &param);
60 };
61 
63 {
64 }
65 
67 {
68 }
69 
71 {
72  if (modes.find(c) == Anope::string::npos)
73  modes.append(c);
74 }
75 
77 {
78  modes = modes.replace_all_cs(c, "");
79 }
80 
81 bool ChannelStatus::HasMode(char c) const
82 {
83  return modes.find(c) != Anope::string::npos;
84 }
85 
87 {
88  return modes.empty();
89 }
90 
92 {
93  modes.clear();
94 }
95 
97 {
98  return modes;
99 }
100 
102 {
103  Anope::string ret;
104 
105  for (size_t i = 0; i < modes.length(); ++i)
106  {
108  if (cm != NULL && cm->type == MODE_STATUS)
109  {
111  ret += cms->symbol;
112  }
113  }
114 
115  return ret;
116 }
117 
118 Mode::Mode(const Anope::string &mname, ModeClass mcl, char mch, ModeType mt) : name(mname), mclass(mcl), mchar(mch), type(mt)
119 {
120 }
121 
123 {
124 }
125 
126 bool Mode::CanSet(User *u) const
127 {
128  return true;
129 }
130 
131 UserMode::UserMode(const Anope::string &un, char mch) : Mode(un, MC_USER, mch, MODE_REGULAR)
132 {
133 }
134 
135 UserModeParam::UserModeParam(const Anope::string &un, char mch) : UserMode(un, mch)
136 {
137  this->type = MODE_PARAM;
138 }
139 
141 {
142 }
143 
144 bool ChannelMode::CanSet(User *u) const
145 {
146  EventReturn MOD_RESULT;
147  FOREACH_RESULT(OnCanSet, MOD_RESULT, (u, this));
148  return MOD_RESULT != EVENT_STOP;
149 }
150 
152 {
153  return this;
154 }
155 
157 {
158  for (unsigned i = 0; i < listeners.size(); ++i)
159  {
160  ChannelMode *cm = listeners[i]->Unwrap(this, param);
161  if (cm != this)
162  return cm;
163  }
164 
165  return this;
166 }
167 
169 {
170  throw CoreException("Unwrap in channel mode");
171 }
172 
174 {
175  this->type = MODE_LIST;
176 }
177 
179 {
180  if (name == "BAN" || name == "EXCEPT" || name == "INVITEOVERRIDE")
181  mask = IRCD->NormalizeMask(mask);
182  return true;
183 }
184 
185 ChannelModeParam::ChannelModeParam(const Anope::string &cm, char mch, bool ma) : ChannelMode(cm, mch), minus_no_arg(ma)
186 {
187  this->type = MODE_PARAM;
188 }
189 
190 ChannelModeStatus::ChannelModeStatus(const Anope::string &mname, char modeChar, char msymbol, short mlevel) : ChannelMode(mname, modeChar), symbol(msymbol), level(mlevel)
191 {
192  this->type = MODE_STATUS;
193 }
194 
195 template<typename T>
196 ChannelModeVirtual<T>::ChannelModeVirtual(const Anope::string &mname, const Anope::string &basename) : T(mname, 0)
197  , base(basename)
198 {
200  if (basech)
201  basech->listeners.push_back(this);
202 }
203 
204 template<typename T>
206 {
207  if (basech)
208  {
209  std::vector<ChannelMode *>::iterator it = std::find(basech->listeners.begin(), basech->listeners.end(), this);
210  if (it != basech->listeners.end())
211  basech->listeners.erase(it);
212  }
213 }
214 
215 template<typename T>
217 {
218  if (basech == NULL)
219  {
220  basech = ModeManager::FindChannelModeByName(base);
221  if (basech)
222  basech->listeners.push_back(this);
223  }
224 
225  return basech;
226 }
227 
228 template class ChannelModeVirtual<ChannelMode>;
230 
232 {
233  return u && u->HasMode("OPER");
234 }
235 
237 {
238  return false;
239 }
240 
242 {
243  if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos)
244  return true;
245 
246  return false;
247 }
248 
250 {
251  return u && u->HasMode("OPER");
252 }
253 
255 {
256  return false;
257 }
258 
259 void StackerInfo::AddMode(Mode *mode, bool set, const Anope::string &param)
260 {
261  bool is_param = mode->type == MODE_PARAM;
262 
263  std::list<std::pair<Mode *, Anope::string> > *list, *otherlist;
264  if (set)
265  {
266  list = &AddModes;
267  otherlist = &DelModes;
268  }
269  else
270  {
271  list = &DelModes;
272  otherlist = &AddModes;
273  }
274 
275  /* Loop through the list and find if this mode is already on here */
276  std::list<std::pair<Mode *, Anope::string > >::iterator it, it_end;
277  for (it = list->begin(), it_end = list->end(); it != it_end; ++it)
278  {
279  /* The param must match too (can have multiple status or list modes), but
280  * if it is a param mode it can match no matter what the param is
281  */
282  if (it->first == mode && (is_param || param.equals_cs(it->second)))
283  {
284  list->erase(it);
285  /* It can only be on this list once */
286  break;
287  }
288  }
289  /* If the mode is on the other list, remove it from there (eg, we dont want +o-o Adam Adam) */
290  for (it = otherlist->begin(), it_end = otherlist->end(); it != it_end; ++it)
291  {
292  /* The param must match too (can have multiple status or list modes), but
293  * if it is a param mode it can match no matter what the param is
294  */
295  if (it->first == mode && (is_param || param.equals_cs(it->second)))
296  {
297  otherlist->erase(it);
298  return;
299  /* Note that we return here because this is like setting + and - on the same mode within the same
300  * cycle, no change is made. This causes no problems with something like - + and -, because after the
301  * second mode change the list is empty, and the third mode change starts fresh.
302  */
303  }
304  }
305 
306  /* Add this mode and its param to our list */
307  list->push_back(std::make_pair(mode, param));
308 }
309 
310 static class ModePipe : public Pipe
311 {
312  public:
313  void OnNotify()
314  {
316  }
317 } *modePipe;
318 
323 template<typename List, typename Object>
324 static StackerInfo *GetInfo(List &l, Object *o)
325 {
326  typename List::const_iterator it = l.find(o);
327  if (it != l.end())
328  return it->second;
329 
330  StackerInfo *s = new StackerInfo();
331  l[o] = s;
332  return s;
333 }
334 
339 static std::list<Anope::string> BuildModeStrings(StackerInfo *info)
340 {
341  std::list<Anope::string> ret;
342  std::list<std::pair<Mode *, Anope::string> >::iterator it, it_end;
343  Anope::string buf = "+", parambuf;
344  unsigned NModes = 0;
345 
346  for (it = info->AddModes.begin(), it_end = info->AddModes.end(); it != it_end; ++it)
347  {
348  if (++NModes > IRCD->MaxModes || (buf.length() + parambuf.length() > IRCD->MaxLine - 100)) // Leave room for command, channel, etc
349  {
350  ret.push_back(buf + parambuf);
351  buf = "+";
352  parambuf.clear();
353  NModes = 1;
354  }
355 
356  buf += it->first->mchar;
357 
358  if (!it->second.empty())
359  parambuf += " " + it->second;
360  }
361 
362  if (buf[buf.length() - 1] == '+')
363  buf.erase(buf.length() - 1);
364 
365  buf += "-";
366  for (it = info->DelModes.begin(), it_end = info->DelModes.end(); it != it_end; ++it)
367  {
368  if (++NModes > IRCD->MaxModes || (buf.length() + parambuf.length() > IRCD->MaxLine - 100)) // Leave room for command, channel, etc
369  {
370  ret.push_back(buf + parambuf);
371  buf = "-";
372  parambuf.clear();
373  NModes = 1;
374  }
375 
376  buf += it->first->mchar;
377 
378  if (!it->second.empty())
379  parambuf += " " + it->second;
380  }
381 
382  if (buf[buf.length() - 1] == '-')
383  buf.erase(buf.length() - 1);
384 
385  if (!buf.empty())
386  ret.push_back(buf + parambuf);
387 
388  return ret;
389 }
390 
392 {
393  if (ModeManager::FindUserModeByChar(um->mchar) != NULL)
394  return false;
395  if (ModeManager::FindUserModeByName(um->name) != NULL)
396  return false;
397 
398  if (um->name.empty())
399  {
401  Log() << "ModeManager: Added generic support for user mode " << um->mchar;
402  }
403 
404  unsigned want = um->mchar;
405  if (want >= UserModesIdx.size())
406  UserModesIdx.resize(want + 1);
407  UserModesIdx[want] = um;
408 
409  UserModesByName[um->name] = um;
410 
411  UserModes.push_back(um);
412 
413  FOREACH_MOD(OnUserModeAdd, (um));
414 
415  return true;
416 }
417 
419 {
420  if (cm->mchar && ModeManager::FindChannelModeByChar(cm->mchar) != NULL)
421  return false;
422  if (ModeManager::FindChannelModeByName(cm->name) != NULL)
423  return false;
424 
425  if (cm->name.empty())
426  {
428  Log() << "ModeManager: Added generic support for channel mode " << cm->mchar;
429  }
430 
431  if (cm->mchar)
432  {
433  unsigned want = cm->mchar;
434  if (want >= ChannelModesIdx.size())
435  ChannelModesIdx.resize(want + 1);
436  ChannelModesIdx[want] = cm;
437  }
438 
439  if (cm->type == MODE_STATUS)
440  {
442  unsigned want = cms->symbol;
443  if (want >= ChannelModesIdx.size())
444  ChannelModesIdx.resize(want + 1);
445  ChannelModesIdx[want] = cms;
446 
448  }
449 
450  ChannelModesByName[cm->name] = cm;
451 
452  ChannelModes.push_back(cm);
453 
454  FOREACH_MOD(OnChannelModeAdd, (cm));
455 
456  return true;
457 }
458 
460 {
461  if (!um)
462  return;
463 
464  unsigned want = um->mchar;
465  if (want >= UserModesIdx.size())
466  return;
467 
468  if (UserModesIdx[want] != um)
469  return;
470 
471  UserModesIdx[want] = NULL;
472 
473  UserModesByName.erase(um->name);
474 
475  std::vector<UserMode *>::iterator it = std::find(UserModes.begin(), UserModes.end(), um);
476  if (it != UserModes.end())
477  UserModes.erase(it);
478 
479  StackerDel(um);
480 }
481 
483 {
484  if (!cm)
485  return;
486 
487  if (cm->mchar)
488  {
489  unsigned want = cm->mchar;
490  if (want >= ChannelModesIdx.size())
491  return;
492 
493  if (ChannelModesIdx[want] != cm)
494  return;
495 
496  ChannelModesIdx[want] = NULL;
497  }
498 
499  if (cm->type == MODE_STATUS)
500  {
502  unsigned want = cms->symbol;
503 
504  if (want >= ChannelModesIdx.size())
505  return;
506 
507  if (ChannelModesIdx[want] != cm)
508  return;
509 
510  ChannelModesIdx[want] = NULL;
511 
513  }
514 
515  ChannelModesByName.erase(cm->name);
516 
517  std::vector<ChannelMode *>::iterator it = std::find(ChannelModes.begin(), ChannelModes.end(), cm);
518  if (it != ChannelModes.end())
519  ChannelModes.erase(it);
520 
521  StackerDel(cm);
522 }
523 
525 {
526  unsigned want = mode;
527  if (want >= ChannelModesIdx.size())
528  return NULL;
529 
530  return ChannelModesIdx[want];
531 }
532 
534 {
535  unsigned want = mode;
536  if (want >= UserModesIdx.size())
537  return NULL;
538 
539  return UserModesIdx[want];
540 }
541 
543 {
544  std::map<Anope::string, ChannelMode *>::iterator it = ChannelModesByName.find(name);
545  if (it != ChannelModesByName.end())
546  return it->second;
547  return NULL;
548 }
549 
551 {
552  std::map<Anope::string, UserMode *>::iterator it = UserModesByName.find(name);
553  if (it != UserModesByName.end())
554  return it->second;
555  return NULL;
556 }
557 
559 {
560  unsigned want = value;
561  if (want >= ChannelModesIdx.size())
562  return 0;
563 
564  ChannelMode *cm = ChannelModesIdx[want];
565  if (cm == NULL || cm->type != MODE_STATUS || cm->mchar == value)
566  return 0;
567 
568  return cm->mchar;
569 }
570 
571 const std::vector<ChannelMode *> &ModeManager::GetChannelModes()
572 {
573  return ChannelModes;
574 }
575 
576 const std::vector<UserMode *> &ModeManager::GetUserModes()
577 {
578  return UserModes;
579 }
580 
581 const std::vector<ChannelModeStatus *> &ModeManager::GetStatusChannelModesByRank()
582 {
583  return ChannelModesByStatus;
584 }
585 
586 static struct StatusSort
587 {
589  {
590  return cm1->level > cm2->level;
591  }
592 } statuscmp;
593 
595 {
596  ChannelModesByStatus.clear();
597  for (unsigned j = 0; j < ChannelModesIdx.size(); ++j)
598  {
599  ChannelMode *cm = ChannelModesIdx[j];
600 
601  if (cm && cm->type == MODE_STATUS && std::find(ChannelModesByStatus.begin(), ChannelModesByStatus.end(), cm) == ChannelModesByStatus.end())
602  ChannelModesByStatus.push_back(anope_dynamic_static_cast<ChannelModeStatus *>(cm));
603  }
604  std::sort(ChannelModesByStatus.begin(), ChannelModesByStatus.end(), statuscmp);
605 }
606 
607 void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param)
608 {
610  s->AddMode(cm, Set, Param);
611  if (bi)
612  s->bi = bi;
613  else
614  s->bi = c->ci->WhoSends();
615 
616  if (!modePipe)
617  modePipe = new ModePipe();
618  modePipe->Notify();
619 }
620 
621 void ModeManager::StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param)
622 {
624  s->AddMode(um, Set, Param);
625  if (bi)
626  s->bi = bi;
627 
628  if (!modePipe)
629  modePipe = new ModePipe();
630  modePipe->Notify();
631 }
632 
634 {
635  if (!UserStackerObjects.empty())
636  {
637  for (std::map<User *, StackerInfo *>::const_iterator it = UserStackerObjects.begin(), it_end = UserStackerObjects.end(); it != it_end; ++it)
638  {
639  User *u = it->first;
640  StackerInfo *s = it->second;
641 
642  std::list<Anope::string> ModeStrings = BuildModeStrings(s);
643  for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
644  IRCD->SendMode(s->bi, u, lit->c_str());
645  delete it->second;
646  }
647  UserStackerObjects.clear();
648  }
649 
650  if (!ChannelStackerObjects.empty())
651  {
652  for (std::map<Channel *, StackerInfo *>::const_iterator it = ChannelStackerObjects.begin(), it_end = ChannelStackerObjects.end(); it != it_end; ++it)
653  {
654  Channel *c = it->first;
655  StackerInfo *s = it->second;
656 
657  std::list<Anope::string> ModeStrings = BuildModeStrings(s);
658  for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
659  IRCD->SendMode(s->bi, c, lit->c_str());
660  delete it->second;
661  }
662  ChannelStackerObjects.clear();
663  }
664 }
665 
666 template<typename T>
667 static void StackerDel(std::map<T *, StackerInfo *> &map, T *obj)
668 {
669  typename std::map<T *, StackerInfo *>::iterator it = map.find(obj);
670  if (it != map.end())
671  {
672  StackerInfo *si = it->second;
673  std::list<Anope::string> ModeStrings = BuildModeStrings(si);
674  for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit)
675  IRCD->SendMode(si->bi, obj, lit->c_str());
676 
677  delete si;
678  map.erase(it);
679  }
680 }
681 
683 {
685 }
686 
688 {
690 }
691 
693 {
694  for (std::map<User *, StackerInfo *>::const_iterator it = UserStackerObjects.begin(), it_end = UserStackerObjects.end(); it != it_end;)
695  {
696  StackerInfo *si = it->second;
697  ++it;
698 
699  for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->AddModes.begin(), it2_end = si->AddModes.end(); it2 != it2_end;)
700  {
701  if (it2->first == m)
702  it2 = si->AddModes.erase(it2);
703  else
704  ++it2;
705  }
706 
707  for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->DelModes.begin(), it2_end = si->DelModes.end(); it2 != it2_end;)
708  {
709  if (it2->first == m)
710  it2 = si->DelModes.erase(it2);
711  else
712  ++it2;
713  }
714  }
715 
716  for (std::map<Channel *, StackerInfo *>::const_iterator it = ChannelStackerObjects.begin(), it_end = ChannelStackerObjects.end(); it != it_end;)
717  {
718  StackerInfo *si = it->second;
719  ++it;
720 
721  for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->AddModes.begin(), it2_end = si->AddModes.end(); it2 != it2_end;)
722  {
723  if (it2->first == m)
724  it2 = si->AddModes.erase(it2);
725  else
726  ++it2;
727  }
728 
729  for (std::list<std::pair<Mode *, Anope::string> >::iterator it2 = si->DelModes.begin(), it2_end = si->DelModes.end(); it2 != it2_end;)
730  {
731  if (it2->first == m)
732  it2 = si->DelModes.erase(it2);
733  else
734  ++it2;
735  }
736  }
737 }
738 
739 Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh), cidr_len(0)
740 {
741  Anope::string n, u, h;
742 
743  size_t at = fh.find('@');
744  if (at != Anope::string::npos)
745  {
746  this->host = fh.substr(at + 1);
747 
748  const Anope::string &nu = fh.substr(0, at);
749 
750  size_t ex = nu.find('!');
751  if (ex != Anope::string::npos)
752  {
753  this->user = nu.substr(ex + 1);
754  this->nick = nu.substr(0, ex);
755  }
756  else
757  this->user = nu;
758  }
759  else
760  {
761  if (fh.find('.') != Anope::string::npos || fh.find(':') != Anope::string::npos)
762  this->host = fh;
763  else
764  this->nick = fh;
765  }
766 
767  at = this->host.find('#');
768  if (at != Anope::string::npos)
769  {
770  this->real = this->host.substr(at + 1);
771  this->host = this->host.substr(0, at);
772  }
773 
774  /* If the mask is all *'s it will match anything, so just clear it */
775  if (this->nick.find_first_not_of("*") == Anope::string::npos)
776  this->nick.clear();
777 
778  if (this->user.find_first_not_of("*") == Anope::string::npos)
779  this->user.clear();
780 
781  if (this->host.find_first_not_of("*") == Anope::string::npos)
782  this->host.clear();
783  else
784  {
785  /* Host might be a CIDR range */
786  size_t sl = this->host.find_last_of('/');
787  if (sl != Anope::string::npos)
788  {
789  const Anope::string &cidr_ip = this->host.substr(0, sl),
790  &cidr_range = this->host.substr(sl + 1);
791 
792  sockaddrs addr(cidr_ip);
793 
794  try
795  {
796  if (addr.valid() && cidr_range.is_pos_number_only())
797  {
798  this->cidr_len = convertTo<unsigned short>(cidr_range);
799  /* If we got here, cidr_len is a valid number.
800  * If cidr_len is >32 (or 128) it is handled later in
801  * cidr::match
802  */
803 
804  this->host = cidr_ip;
805 
806  Log(LOG_DEBUG) << "Ban " << m << " has cidr " << this->cidr_len;
807  }
808  }
809  catch (const ConvertException &) { }
810  }
811  }
812 
813  if (this->real.find_first_not_of("*") == Anope::string::npos)
814  this->real.clear();
815 }
816 
818 {
819  return this->mask;
820 }
821 
823 {
824  Anope::string n = nick.empty() ? "*" : nick,
825  u = user.empty() ? "*" : user,
826  h = host.empty() ? "*" : host;
827  return n + "!" + u + "@" + h;
828 }
829 
830 bool Entry::Matches(User *u, bool full) const
831 {
832  /* First check if this mode has defined any matches (usually for extbans). */
833  if (IRCD->IsExtbanValid(this->mask))
834  {
836  if (cm != NULL && cm->type == MODE_LIST)
837  {
839  if (cml->Matches(u, this))
840  return true;
841  }
842  }
843 
844  /* If the user's displayed host is their real host, then we can do a full match without
845  * having to worry about exposing a user's IP
846  */
847  full |= u->GetDisplayedHost() == u->host;
848 
849  bool ret = true;
850 
851  if (!this->nick.empty() && !Anope::Match(u->nick, this->nick))
852  ret = false;
853 
854  if (!this->user.empty() && !Anope::Match(u->GetVIdent(), this->user) && (!full || !Anope::Match(u->GetIdent(), this->user)))
855  ret = false;
856 
857  if (this->cidr_len && full)
858  {
859  try
860  {
861  if (!cidr(this->host, this->cidr_len).match(u->ip))
862  ret = false;
863  }
864  catch (const SocketException &)
865  {
866  ret = false;
867  }
868  }
869  else if (!this->host.empty() && !Anope::Match(u->GetDisplayedHost(), this->host) && !Anope::Match(u->GetCloakedHost(), this->host) &&
870  (!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->ip.addr(), this->host))))
871  ret = false;
872 
873  if (!this->real.empty() && !Anope::Match(u->realname, this->real))
874  ret = false;
875 
876  return ret;
877 }
878 
Definition: modes.h:39
Definition: bots.h:24
bool HasMode(const Anope::string &name) const
Definition: users.cpp:513
static std::map< Channel *, StackerInfo * > ChannelStackerObjects
Definition: modes.cpp:22
bool equals_cs(const char *_str) const
Definition: anope.h:74
static const std::vector< ChannelMode * > & GetChannelModes()
Definition: modes.cpp:571
const Anope::string GetMask() const
Definition: modes.cpp:817
virtual ~Mode()
Definition: modes.cpp:122
static ChannelMode * FindChannelModeByName(const Anope::string &name)
Definition: modes.cpp:542
bool Matches(User *u, bool full=false) const
Definition: modes.cpp:830
const Anope::string & GetIdent() const
Definition: users.cpp:264
void clear()
Definition: anope.h:187
string & append(const string &s)
Definition: anope.h:144
bool IsValid(Anope::string &value) const anope_override
Definition: modes.cpp:241
virtual bool Matches(User *u, const Entry *e)
Definition: modes.h:146
std::list< std::pair< Mode *, Anope::string > > DelModes
Definition: modes.cpp:48
bool match(const sockaddrs &other)
Definition: sockets.cpp:233
static UserMode * FindUserModeByChar(char mode)
Definition: modes.cpp:533
void AddMode(Mode *mode, bool set, const Anope::string &param)
Definition: modes.cpp:259
static std::list< Anope::string > BuildModeStrings(StackerInfo *info)
Definition: modes.cpp:339
unsigned short cidr_len
Definition: modes.h:393
void push_back(char c)
Definition: anope.h:142
static StackerInfo * GetInfo(List &l, Object *o)
Definition: modes.cpp:324
Anope::string addr() const
Definition: sockets.cpp:73
static unsigned GenericChannelModes
Definition: modes.h:297
static void RebuildStatusModes()
Definition: modes.cpp:594
static std::map< Anope::string, UserMode * > UserModesByName
Definition: modes.cpp:35
Anope::string nick
Definition: modes.h:394
static std::map< Anope::string, ChannelMode * > ChannelModesByName
Definition: modes.cpp:34
virtual bool IsValid(Anope::string &mask) const
Definition: modes.cpp:178
Definition: users.h:34
Anope::string modes
Definition: modes.h:226
void DelMode(char c)
Definition: modes.cpp:76
ModeClass
Definition: modes.h:31
std::list< std::pair< Mode *, Anope::string > > AddModes
Definition: modes.cpp:46
Entry(const Anope::string &mode, const Anope::string &host)
Definition: modes.cpp:739
#define FOREACH_RESULT(ename, ret, args)
Definition: modules.h:95
Definition: sockets.h:87
ChannelMode * basech
Definition: modes.h:211
bool CanSet(User *u) const anope_override
Definition: modes.cpp:249
Serialize::Reference< ChannelInfo > ci
Definition: channels.h:46
bool HasMode(char c) const
Definition: modes.cpp:81
static UserMode * FindUserModeByName(const Anope::string &name)
Definition: modes.cpp:550
virtual bool IsExtbanValid(const Anope::string &)
Definition: protocol.h:238
#define FOREACH_MOD(ename, args)
Definition: modules.h:62
Definition: sockets.h:454
iterator erase(const iterator &i)
Definition: anope.h:155
std::vector< ChannelMode * > listeners
Definition: modes.h:100
ChannelMode * Unwrap(Anope::string &param)
Definition: modes.cpp:156
static void StackerDel(User *u)
Definition: modes.cpp:682
string substr(size_type pos=0, size_type n=npos) const
Definition: anope.h:277
Anope::string host
Definition: modes.h:394
bool CanSet(User *u) const anope_override
Definition: modes.cpp:231
ChannelModeVirtual(const Anope::string &mname, const Anope::string &basename)
Definition: modes.cpp:196
size_type length() const
Definition: anope.h:131
bool CanSet(User *u) const anope_override
Definition: modes.cpp:236
void OnNotify()
Definition: modes.cpp:313
static std::vector< UserMode * > UserModesIdx
Definition: modes.cpp:32
Anope::string name
Definition: modes.h:390
ChannelModeList(const Anope::string &name, char mc)
Definition: modes.cpp:173
ModeType type
Definition: modes.h:49
void Notify()
Definition: pipeengine.cpp:77
UserMode(const Anope::string &name, char mc)
Definition: modes.cpp:131
bool valid() const
Definition: sockets.cpp:99
unsigned MaxModes
Definition: protocol.h:73
CoreExport bool Match(const string &str, const string &mask, bool case_sensitive=false, bool use_regex=false)
Definition: misc.cpp:407
Anope::string real
Definition: modes.h:394
static std::map< User *, StackerInfo * > UserStackerObjects
Definition: modes.cpp:18
static char GetStatusChar(char symbol)
Definition: modes.cpp:558
static bool AddUserMode(UserMode *um)
Definition: modes.cpp:391
virtual ChannelMode * Wrap(Anope::string &param)
Definition: modes.cpp:151
static const size_type npos
Definition: anope.h:44
string replace_all_cs(const string &_orig, const string &_repl) const
Definition: anope.h:229
void AddMode(char c)
Definition: modes.cpp:70
const Anope::string & GetDisplayedHost() const
Definition: users.cpp:203
Anope::string user
Definition: modes.h:394
ChannelStatus()
Definition: modes.cpp:62
ChannelMode(const Anope::string &name, char mc)
Definition: modes.cpp:140
Definition: modes.h:68
char mchar
Definition: modes.h:47
static ChannelMode * FindChannelModeByChar(char mode)
Definition: modes.cpp:524
bool operator()(ChannelModeStatus *cm1, ChannelModeStatus *cm2) const
Definition: modes.cpp:588
static std::vector< ChannelMode * > ChannelModes
Definition: modes.cpp:25
const Anope::string & GetVIdent() const
Definition: users.cpp:247
static Anope::map< std::pair< bool, Anope::string > > modes
Definition: cs_mode.cpp:745
BotInfo * bi
Definition: modes.cpp:50
bool empty() const
Definition: anope.h:126
static std::vector< ChannelMode * > ChannelModesIdx
Definition: modes.cpp:31
Anope::string host
Definition: users.h:65
Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type)
Definition: modes.cpp:118
sockaddrs ip
Definition: users.h:75
CoreExport IRCDProto * IRCD
Definition: protocol.cpp:23
EventReturn
Definition: modules.h:129
ChannelModeStatus(const Anope::string &name, char mc, char msymbol, short mlevel)
Definition: modes.cpp:190
static void RemoveChannelMode(ChannelMode *cm)
Definition: modes.cpp:482
bool CanSet(User *u) const anope_override
Definition: modes.cpp:144
Anope::string base
Definition: modes.h:210
ChannelMode * Wrap(Anope::string &param) anope_override
Definition: modes.cpp:216
size_type find_first_not_of(const string &_str, size_type pos=0) const
Definition: anope.h:205
static unsigned GenericUserModes
Definition: modes.h:298
static void RemoveUserMode(UserMode *um)
Definition: modes.cpp:459
StackerInfo()
Definition: modes.cpp:52
Anope::string stringify(const T &x)
Definition: anope.h:710
static void StackerDel(std::map< T *, StackerInfo * > &map, T *obj)
Definition: modes.cpp:667
static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool set, const Anope::string &param="")
Definition: modes.cpp:607
ChannelModeParam(const Anope::string &name, char mc, bool minus_no_arg=false)
Definition: modes.cpp:185
Anope::string realname
Definition: users.h:71
virtual bool CanSet(User *u) const
Definition: modes.cpp:126
static void ProcessModes()
Definition: modes.cpp:633
Anope::string nick
Definition: users.h:62
UserModeParam(const Anope::string &name, char mc)
Definition: modes.cpp:135
const Anope::string & GetCloakedHost() const
Definition: users.cpp:225
void Clear()
Definition: modes.cpp:91
static bool AddChannelMode(ChannelMode *cm)
Definition: modes.cpp:418
bool CanSet(User *u) const anope_override
Definition: modes.cpp:254
virtual Anope::string NormalizeMask(const Anope::string &mask)
Definition: protocol.cpp:437
T anope_dynamic_static_cast(O ptr)
Definition: anope.h:774
Anope::string name
Definition: access.cpp:22
bool Empty() const
Definition: modes.cpp:86
const Anope::string & Modes() const
Definition: modes.cpp:96
static std::vector< UserMode * > UserModes
Definition: modes.cpp:26
Definition: logger.h:53
virtual void SendMode(const MessageSource &source, const Channel *dest, const char *fmt,...)
Definition: protocol.cpp:188
static std::vector< ChannelModeStatus * > ChannelModesByStatus
Definition: modes.cpp:38
Definition: modes.h:34
static struct StatusSort statuscmp
static const std::vector< ChannelModeStatus * > & GetStatusChannelModesByRank()
Definition: modes.cpp:581
const Anope::string GetNUHMask() const
Definition: modes.cpp:822
Anope::string name
Definition: modes.h:43
ModeType
Definition: modes.h:17
unsigned MaxLine
Definition: protocol.h:75
ModePipe * modePipe
size_type find(const string &_str, size_type pos=0) const
Definition: anope.h:192
size_type find_last_of(const string &_str, size_type pos=npos) const
Definition: anope.h:208
Anope::string mask
Definition: modes.h:391
static const std::vector< UserMode * > & GetUserModes()
Definition: modes.cpp:576
Anope::string BuildModePrefixList() const
Definition: modes.cpp:101