irc.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * irc.h -- part of irc.mod
  3. *
  4. */
  5. #ifndef _EGG_MOD_IRC_IRC_H
  6. #define _EGG_MOD_IRC_IRC_H
  7. #include "src/auth.h"
  8. enum { BC_NOCOOKIE = 1, BC_SLACK, BC_HASH, BC_COUNTER };
  9. //#define REVENGE_KICK 1 /* Kicked victim */
  10. //#define REVENGE_DEOP 2 /* Took op */
  11. #define PRIO_DEOP 1
  12. #define PRIO_KICK 2
  13. /* For flushmodes */
  14. #define NORMAL 0
  15. #define QUICK 1
  16. #ifdef MAKING_IRC
  17. namespace bd {
  18. class String;
  19. }
  20. #ifdef CACHE
  21. typedef struct cache_chan_b {
  22. struct cache_chan_b *next;
  23. bool invite; /* set to invite on userhost */
  24. bool ban; /* set to ban on join */
  25. bool op; /* should we auto-op? */
  26. bool invited; /* set when we've called cache_invite, meaning we aren't hijacked */
  27. char dname[81];
  28. } cache_chan_t;
  29. typedef struct cache_b {
  30. struct cache_b *next;
  31. cache_chan_t *cchan;
  32. // struct chanset_t *chan;
  33. // struct userrec *user;
  34. time_t timeval;
  35. // bool invite; /* INVITE ON USERHOST */
  36. // bool ban; /* BAN ON USERHOST */
  37. // bool invited; /* INVITED - CLEARED */
  38. bool bot;
  39. char nick[NICKLEN];
  40. char handle[NICKLEN];
  41. char uhost[UHOSTLEN];
  42. } cache_t;
  43. static void cache_chan_del(char *, char *);
  44. //static cache_chan_t *cache_chan_find(cache_t *, char *, char *);
  45. static void cache_chan_find(cache_t *, cache_chan_t *, char *, char *);
  46. static cache_chan_t *cache_chan_add(cache_t *, char *);
  47. static cache_t *cache_find(char *);
  48. static cache_t *cache_new(char *);
  49. static void cache_del(char *, cache_t *);
  50. static void cache_debug(void);
  51. #endif /* CACHE */
  52. static void cache_invite(struct chanset_t *, char *, char *, char *, bool, bool);
  53. //static char *makecookie(const char *, const memberlist*, const memberlist*, const memberlist* = NULL, const memberlist* = NULL);
  54. void makecookie(char*, size_t, const char *, const memberlist*, const memberlist*, const memberlist* = NULL, const memberlist* = NULL);
  55. static int checkcookie(const char*, const memberlist*, const memberlist*, const char*, int);
  56. extern void counter_clear(const char*);
  57. static bool any_ops(struct chanset_t *);
  58. static char *getchanmode(struct chanset_t *);
  59. static void flush_mode(struct chanset_t *, int);
  60. static bool member_getuser(memberlist* m, bool act_on_lookup = 0);
  61. static void do_protect(struct chanset_t* chan, const char* reason);
  62. /* reset(bans|exempts|invites) are now just macros that call resetmasks
  63. * in order to reduce the code duplication. <cybah>
  64. */
  65. #define resetbans(chan) resetmasks((chan), (chan)->channel.ban, (chan)->bans, global_bans, 'b')
  66. #define resetexempts(chan) resetmasks((chan), (chan)->channel.exempt, (chan)->exempts, global_exempts, 'e')
  67. #define resetinvites(chan) resetmasks((chan), (chan)->channel.invite, (chan)->invites, global_invites, 'I')
  68. //static void detect_offense(memberlist*, struct chanset_t *, char *);
  69. /* static int target_priority(struct chanset_t *, memberlist *, int); */
  70. static bool do_op(char *, struct chanset_t *, bool, bool);
  71. static void request_op(struct chanset_t *);
  72. static void request_in(struct chanset_t *);
  73. //static void maybe_revenge(struct chanset_t *, char *, char *, int);
  74. static bool detect_chan_flood(char *, char *, char *, struct chanset_t *, int,
  75. char *);
  76. static bool new_mask(masklist *, char *, char *);
  77. static void do_closed_kick(struct chanset_t *, memberlist *);
  78. static char *quickban(struct chanset_t *, char *);
  79. static bool killmember(struct chanset_t *chan, char *nick);
  80. static void check_lonely_channel(struct chanset_t *chan);
  81. static int gotmode(char *, char *);
  82. void unset_im(struct chanset_t* chan);
  83. void detected_drone_flood(struct chanset_t* chan, memberlist*);
  84. static void send_chan_who(int queue, struct chanset_t* chan, bool chain = 0);
  85. #define newban(chan, mask, who) new_mask((chan)->channel.ban, mask, who)
  86. #define newexempt(chan, mask, who) new_mask((chan)->channel.exempt, mask, who)
  87. #define newinvite(chan, mask, who) new_mask((chan)->channel.invite, mask, who)
  88. void resolve_to_member(struct chanset_t *chan, char *nick, char *host);
  89. typedef struct resolvstruct resolv_member;
  90. void resolve_to_rbl(struct chanset_t *chan, const char *host, struct resolvstruct *r = NULL);
  91. static void do_mask(struct chanset_t *chan, masklist *m, char *mask, char Mode);
  92. static void get_channel_masks(struct chanset_t* chan);
  93. #endif /* MAKING_IRC */
  94. void my_setkey(struct chanset_t *, char *);
  95. void force_join_chan(struct chanset_t* chan, int idx = DP_MODE);
  96. void join_chan(struct chanset_t* chan, int idx = DP_MODE);
  97. int check_bind_authc(char *, Auth *, char *, char *);
  98. void notice_invite(struct chanset_t *, char *, char *, char *, bool);
  99. void real_add_mode(struct chanset_t *, const char, const char, const char *, bool);
  100. #define add_mode(chan, pls, mode, nick) real_add_mode(chan, pls, mode, nick, 0)
  101. #define add_cookie(chan, nick) real_add_mode(chan, '+', 'o', nick, 1)
  102. bool me_op(const struct chanset_t *);
  103. bool me_voice(const struct chanset_t *);
  104. void check_this_ban(struct chanset_t *, char *, bool);
  105. void check_this_exempt(struct chanset_t *, char *, bool);
  106. void check_this_invite(struct chanset_t *, char *, bool);
  107. inline void check_this_mask(const char type, struct chanset_t *chan, char *mask, bool sticky)
  108. {
  109. if (channel_active(chan)) {
  110. if (type == 'b')
  111. check_this_ban(chan, mask, sticky);
  112. else if (type == 'e')
  113. check_this_exempt(chan, mask, sticky);
  114. else if (type == 'I')
  115. check_this_invite(chan, mask, sticky);
  116. }
  117. }
  118. void check_this_user(char *, int, char *);
  119. void raise_limit(struct chanset_t *);
  120. void enforce_closed(struct chanset_t *);
  121. void recheck_channel(struct chanset_t *, int);
  122. void recheck_channel_modes(struct chanset_t *);
  123. void irc_report(int, int);
  124. void flush_modes();
  125. void reset_chan_info(struct chanset_t *);
  126. char *getnick(const char *, struct chanset_t *);
  127. void check_shouldjoin(struct chanset_t* chan);
  128. extern int max_bans, max_exempts, max_invites, max_modes;
  129. extern bool use_354, include_lk;
  130. extern unsigned int modesperline;
  131. extern unsigned long my_cookie_counter;
  132. #endif /* _EGG_MOD_IRC_IRC_H */