1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
20 // include the common header files
31 const int APPLY_GLINES = 1;
32 const int APPLY_KLINES = 2;
33 const int APPLY_QLINES = 4;
34 const int APPLY_ZLINES = 8;
35 const int APPLY_ALL = APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES;
37 /** XLine is the base class for ban lines such as G lines and K lines.
39 class XLine : public classbase
43 /** The time the line was added.
47 /** The duration of the ban, or 0 if permenant
51 /** Source of the ban. This can be a servername or an oper nickname
55 /** Reason for the ban
59 /** Number of times the core matches the ban, for statistics
67 class KLine : public XLine
70 /** Hostmask (ident@host) to match against
71 * May contain wildcards.
78 class GLine : public XLine
81 /** Hostmask (ident@host) to match against
82 * May contain wildcards.
87 class ELine : public XLine
90 /** Hostmask (ident@host) to match against
91 * May contain wildcards.
98 class ZLine : public XLine
101 /** IP Address (xx.yy.zz.aa) to match against
102 * May contain wildcards.
105 /** Set if this is a global Z:line
106 * (e.g. it came from another server)
113 class QLine : public XLine
116 /** Nickname to match against.
117 * May contain wildcards.
120 /** Set if this is a global Z:line
121 * (e.g. it came from another server)
129 bool InitXLine(ServerConfig* conf, const char* tag);
130 bool DoneXLine(ServerConfig* conf, const char* tag);
132 bool DoZLine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types);
133 bool DoQLine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types);
134 bool DoKLine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types);
135 bool DoELine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types);
140 InspIRCd* ServerInstance;
142 static bool XLineManager::GSortComparison ( const GLine one, const GLine two );
143 static bool XLineManager::ESortComparison ( const ELine one, const ELine two );
144 static bool XLineManager::ZSortComparison ( const ZLine one, const ZLine two );
145 static bool XLineManager::KSortComparison ( const KLine one, const KLine two );
146 static bool XLineManager::QSortComparison ( const QLine one, const QLine two );
148 /* Lists for temporary lines with an expiry time */
149 std::vector<KLine> klines;
150 std::vector<GLine> glines;
151 std::vector<ZLine> zlines;
152 std::vector<QLine> qlines;
153 std::vector<ELine> elines;
155 /* Seperate lists for perm XLines that isnt checked by expiry functions */
156 std::vector<KLine> pklines;
157 std::vector<GLine> pglines;
158 std::vector<ZLine> pzlines;
159 std::vector<QLine> pqlines;
160 std::vector<ELine> pelines;
162 XLineManager(InspIRCd* Instance);
164 bool add_gline(long duration, const char* source, const char* reason, const char* hostmask);
165 bool add_qline(long duration, const char* source, const char* reason, const char* nickname);
166 bool add_zline(long duration, const char* source, const char* reason, const char* ipaddr);
167 bool add_kline(long duration, const char* source, const char* reason, const char* hostmask);
168 bool add_eline(long duration, const char* source, const char* reason, const char* hostmask);
170 bool del_gline(const char* hostmask);
171 bool del_qline(const char* nickname);
172 bool del_zline(const char* ipaddr);
173 bool del_kline(const char* hostmask);
174 bool del_eline(const char* hostmask);
176 char* matches_qline(const char* nick);
177 char* matches_gline(const char* host);
178 char* matches_zline(const char* ipaddr);
179 char* matches_kline(const char* host);
180 char* matches_exception(const char* host);
183 void apply_lines(const int What);
185 void stats_k(userrec* user, string_list &results);
186 void stats_g(userrec* user, string_list &results);
187 void stats_q(userrec* user, string_list &results);
188 void stats_z(userrec* user, string_list &results);
189 void stats_e(userrec* user, string_list &results);
191 void gline_set_creation_time(const char* host, time_t create_time);
192 void qline_set_creation_time(const char* nick, time_t create_time);
193 void zline_set_creation_time(const char* ip, time_t create_time);
194 void eline_set_creation_time(const char* host, time_t create_time);
196 bool zline_make_global(const char* ipaddr);
197 bool qline_make_global(const char* nickname);