]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/xline.cpp
Started moving of data into ServerConfig class
[user/henk/code/inspircd.git] / src / xline.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include "inspircd_config.h"
20 #include "inspircd.h"
21 #include "inspircd_io.h"
22 #include "inspircd_util.h"
23 #include <unistd.h>
24 #include <fcntl.h>
25 #include <sys/errno.h>
26 #include <time.h>
27 #include <string>
28 #ifdef GCC3
29 #include <ext/hash_map>
30 #else
31 #include <hash_map>
32 #endif
33 #include <map>
34 #include <sstream>
35 #include <vector>
36 #include <deque>
37 #include "users.h"
38 #include "ctables.h"
39 #include "globals.h"
40 #include "modules.h"
41 #include "dynamic.h"
42 #include "wildcard.h"
43 #include "message.h"
44 #include "commands.h"
45 #include "xline.h"
46 #include "inspstring.h"
47 #include "helperfuncs.h"
48 #include "hashcomp.h"
49
50 extern int MODCOUNT;
51 extern std::vector<Module*> modules;
52 extern std::vector<ircd_module*> factory;
53 extern ServerConfig* Config;
54 extern std::stringstream config_f;
55 typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
56 extern user_hash clientlist;
57
58 /* Version two, now with optimized expiry!
59  *
60  * Because the old way was horrendously slow, the new way of expiring xlines is very
61  * very efficient. I have improved the efficiency of the algorithm in two ways:
62  *
63  * (1) There are now two lists of items for each linetype. One list holds temporary
64  *     items, and the other list holds permenant items (ones which will expire).
65  *     Items which are on the permenant list are NEVER checked at all by the
66  *     expire_lines() function.
67  * (2) The temporary xline lists are always kept in strict numerical order, keyed by 
68  *     current time + duration. This means that the line which is due to expire the
69  *     soonest is always pointed at by vector::begin(), so a simple while loop can
70  *     very efficiently, very quickly and above all SAFELY pick off the first few
71  *     items in the vector which need zapping.
72  *
73  *     -- Brain
74  */
75
76
77
78 extern time_t TIME;
79
80 /* Lists for temporary lines with an expiry time */
81
82 std::vector<KLine> klines;
83 std::vector<GLine> glines;
84 std::vector<ZLine> zlines;
85 std::vector<QLine> qlines;
86 std::vector<ELine> elines;
87
88 /* Seperate lists for perm XLines that isnt checked by expiry functions */
89
90 std::vector<KLine> pklines;
91 std::vector<GLine> pglines;
92 std::vector<ZLine> pzlines;
93 std::vector<QLine> pqlines;
94 std::vector<ELine> pelines;
95
96
97 bool GSortComparison ( const GLine one, const GLine two );
98 bool ZSortComparison ( const ZLine one, const ZLine two );
99 bool ESortComparison ( const ELine one, const ELine two );
100 bool QSortComparison ( const QLine one, const QLine two );
101 bool KSortComparison ( const KLine one, const KLine two );
102
103 // Reads the default bans from the config file.
104 // only a very small number of bans are defined
105 // this way these days, such as qlines against 
106 // services nicks, etc.
107
108 void read_xline_defaults()
109 {
110         char ipmask[MAXBUF];
111         char nick[MAXBUF];
112         char host[MAXBUF];
113         char reason[MAXBUF];
114
115         for (int i = 0; i < ConfValueEnum("badip",&config_f); i++)
116         {
117                 ConfValue("badip","ipmask",i,ipmask,&config_f);
118                 ConfValue("badip","reason",i,reason,&config_f);
119                 add_zline(0,"<Config>",reason,ipmask);
120                 log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason);
121         }
122         
123         for (int i = 0; i < ConfValueEnum("badnick",&config_f); i++)
124         {
125                 ConfValue("badnick","nick",i,nick,&config_f);
126                 ConfValue("badnick","reason",i,reason,&config_f);
127                 add_qline(0,"<Config>",reason,nick);
128                 log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason);
129         }
130         
131         for (int i = 0; i < ConfValueEnum("badhost",&config_f); i++)
132         {
133                 ConfValue("badhost","host",i,host,&config_f);
134                 ConfValue("badhost","reason",i,reason,&config_f);
135                 add_kline(0,"<Config>",reason,host);
136                 log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason);
137         }
138         for (int i = 0; i < ConfValueEnum("exception",&config_f); i++)
139         {
140                 ConfValue("exception","host",i,host,&config_f);
141                 ConfValue("exception","reason",i,reason,&config_f);
142                 add_eline(0,"<Config>",reason,host);
143                 log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason);
144         }
145 }
146
147 // adds a g:line
148
149 void add_gline(long duration, const char* source,const char* reason,const char* hostmask)
150 {
151         del_gline(hostmask);
152         GLine item;
153         item.duration = duration;
154         strlcpy(item.hostmask,hostmask,199);
155         strlcpy(item.reason,reason,MAXBUF);
156         strlcpy(item.source,source,255);
157         item.n_matches = 0;
158         item.set_time = TIME;
159         if (duration)
160         {
161                 glines.push_back(item);
162                 sort(glines.begin(), glines.end(),GSortComparison);
163         }
164         else
165         {
166                 pglines.push_back(item);
167         }
168 }
169
170 // adds an e:line (exception to bans)
171
172 void add_eline(long duration, const char* source, const char* reason, const char* hostmask)
173 {
174         del_eline(hostmask);
175         ELine item;
176         item.duration = duration;
177         strlcpy(item.hostmask,hostmask,199);
178         strlcpy(item.reason,reason,MAXBUF);
179         strlcpy(item.source,source,255);
180         item.n_matches = 0;
181         item.set_time = TIME;
182         if (duration)
183         {
184                 elines.push_back(item);
185                 sort(elines.begin(), elines.end(),ESortComparison);
186         }
187         else
188         {
189                 pelines.push_back(item);
190         }
191 }
192
193 // adds a q:line
194
195 void add_qline(long duration, const char* source, const char* reason, const char* nickname)
196 {
197         del_qline(nickname);
198         QLine item;
199         item.duration = duration;
200         strlcpy(item.nick,nickname,63);
201         strlcpy(item.reason,reason,MAXBUF);
202         strlcpy(item.source,source,255);
203         item.n_matches = 0;
204         item.is_global = false;
205         item.set_time = TIME;
206         if (duration)
207         {
208                 qlines.push_back(item);
209                 sort(qlines.begin(), qlines.end(),QSortComparison);
210         }
211         else
212         {
213                 pqlines.push_back(item);
214         }
215 }
216
217 // adds a z:line
218
219 void add_zline(long duration, const char* source, const char* reason, const char* ipaddr)
220 {
221         del_zline(ipaddr);
222         ZLine item;
223         item.duration = duration;
224         if (strchr(ipaddr,'@'))
225         {
226                 while (*ipaddr != '@')
227                         ipaddr++;
228                 ipaddr++;
229         }
230         strlcpy(item.ipaddr,ipaddr,39);
231         strlcpy(item.reason,reason,MAXBUF);
232         strlcpy(item.source,source,255);
233         item.n_matches = 0;
234         item.is_global = false;
235         item.set_time = TIME;
236         if (duration)
237         {
238                 zlines.push_back(item);
239                 sort(zlines.begin(), zlines.end(),ZSortComparison);
240         }
241         else
242         {
243                 pzlines.push_back(item);
244         }
245 }
246
247 // adds a k:line
248
249 void add_kline(long duration, const char* source, const char* reason, const char* hostmask)
250 {
251         del_kline(hostmask);
252         KLine item;
253         item.duration = duration;
254         strlcpy(item.hostmask,hostmask,200);
255         strlcpy(item.reason,reason,MAXBUF);
256         strlcpy(item.source,source,255);
257         item.n_matches = 0;
258         item.set_time = TIME;
259         if (duration)
260         {
261                 klines.push_back(item);
262                 sort(klines.begin(), klines.end(),KSortComparison);
263         }
264         else
265         {
266                 pklines.push_back(item);
267         }
268 }
269
270 // deletes a g:line, returns true if the line existed and was removed
271
272 bool del_gline(const char* hostmask)
273 {
274         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
275         {
276                 if (!strcasecmp(hostmask,i->hostmask))
277                 {
278                         glines.erase(i);
279                         return true;
280                 }
281         }
282         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
283         {
284                 if (!strcasecmp(hostmask,i->hostmask))
285                 {
286                         pglines.erase(i);
287                         return true;
288                 }
289         }
290         return false;
291 }
292
293 // deletes a e:line, returns true if the line existed and was removed
294
295 bool del_eline(const char* hostmask)
296 {
297         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
298         {
299                 if (!strcasecmp(hostmask,i->hostmask))
300                 {
301                         elines.erase(i);
302                         return true;
303                 }
304         }
305         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
306         {
307                 if (!strcasecmp(hostmask,i->hostmask))
308                 {
309                         pelines.erase(i);
310                         return true;
311                 }
312         }
313         return false;
314 }
315
316 // deletes a q:line, returns true if the line existed and was removed
317
318 bool del_qline(const char* nickname)
319 {
320         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
321         {
322                 if (!strcasecmp(nickname,i->nick))
323                 {
324                         qlines.erase(i);
325                         return true;
326                 }
327         }
328         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
329         {
330                 if (!strcasecmp(nickname,i->nick))
331                 {
332                         pqlines.erase(i);
333                         return true;
334                 }
335         }
336         return false;
337 }
338
339 bool qline_make_global(const char* nickname)
340 {
341         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
342         {
343                 if (!strcasecmp(nickname,i->nick))
344                 {
345                         i->is_global = true;
346                         return true;
347                 }
348         }
349         return false;
350 }
351
352 bool zline_make_global(const char* ipaddr)
353 {
354         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
355         {
356                 if (!strcasecmp(ipaddr,i->ipaddr))
357                 {
358                         i->is_global = true;
359                         return true;
360                 }
361         }
362         return false;
363 }
364
365 // deletes a z:line, returns true if the line existed and was removed
366
367 bool del_zline(const char* ipaddr)
368 {
369         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
370         {
371                 if (!strcasecmp(ipaddr,i->ipaddr))
372                 {
373                         zlines.erase(i);
374                         return true;
375                 }
376         }
377         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
378         {
379                 if (!strcasecmp(ipaddr,i->ipaddr))
380                 {
381                         pzlines.erase(i);
382                         return true;
383                 }
384         }
385         return false;
386 }
387
388 // deletes a k:line, returns true if the line existed and was removed
389
390 bool del_kline(const char* hostmask)
391 {
392         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
393         {
394                 if (!strcasecmp(hostmask,i->hostmask))
395                 {
396                         klines.erase(i);
397                         return true;
398                 }
399         }
400         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
401         {
402                 if (!strcasecmp(hostmask,i->hostmask))
403                 {
404                         pklines.erase(i);
405                         return true;
406                 }
407         }
408         return false;
409 }
410
411 // returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
412
413 char* matches_qline(const char* nick)
414 {
415         if ((qlines.empty()) && (pqlines.empty()))
416                 return NULL;
417         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
418                 if (match(nick,i->nick))
419                         return i->reason;
420         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
421                 if (match(nick,i->nick))
422                         return i->reason;
423         return NULL;
424 }
425
426 // returns a pointer to the reason if a host matches a gline, NULL if it didnt match
427
428 char* matches_gline(const char* host)
429 {
430         if ((glines.empty()) && (pglines.empty()))
431                 return NULL;
432         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
433                 if (match(host,i->hostmask))
434                         return i->reason;
435         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
436                 if (match(host,i->hostmask))
437                         return i->reason;
438         return NULL;
439 }
440
441 char* matches_exception(const char* host)
442 {
443         if ((elines.empty()) && (pelines.empty()))
444                 return NULL;
445         char host2[MAXBUF];
446         snprintf(host2,MAXBUF,"*@%s",host);
447         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
448                 if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
449                         return i->reason;
450         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
451                 if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
452                         return i->reason;
453         return NULL;
454 }
455
456
457 void gline_set_creation_time(char* host, time_t create_time)
458 {
459         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
460         {
461                 if (!strcasecmp(host,i->hostmask))
462                 {
463                         i->set_time = create_time;
464                         return;
465                 }
466         }
467         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
468         {
469                 if (!strcasecmp(host,i->hostmask))
470                 {
471                         i->set_time = create_time;
472                         return;
473                 }
474         }
475         return ;        
476 }
477
478 void eline_set_creation_time(char* host, time_t create_time)
479 {
480         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
481         {
482                 if (!strcasecmp(host,i->hostmask))
483                 {
484                         i->set_time = create_time;
485                         return;
486                 }
487         }
488         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++) 
489         {
490                 if (!strcasecmp(host,i->hostmask))
491                 {
492                         i->set_time = create_time;
493                         return;
494                 }
495         }
496         return;
497 }
498
499 void qline_set_creation_time(char* nick, time_t create_time)
500 {
501         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
502         {
503                 if (!strcasecmp(nick,i->nick))
504                 {
505                         i->set_time = create_time;
506                         return;
507                 }
508         }
509         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
510         {
511                 if (!strcasecmp(nick,i->nick))
512                 {
513                         i->set_time = create_time;
514                         return;
515                 }
516         }
517         return;
518 }
519
520 void zline_set_creation_time(char* ip, time_t create_time)
521 {
522         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
523         {
524                 if (!strcasecmp(ip,i->ipaddr))
525                 {
526                         i->set_time = create_time;
527                         return;
528                 }
529         }
530         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
531         {
532                 if (!strcasecmp(ip,i->ipaddr))
533                 {
534                         i->set_time = create_time;
535                         return;
536                 }
537         }
538         return;
539 }
540
541 // returns a pointer to the reason if an ip address matches a zline, NULL if it didnt match
542
543 char* matches_zline(const char* ipaddr)
544 {
545         if ((zlines.empty()) && (pzlines.empty()))
546                 return NULL;
547         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
548                 if (match(ipaddr,i->ipaddr))
549                         return i->reason;
550         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
551                 if (match(ipaddr,i->ipaddr))
552                         return i->reason;
553         return NULL;
554 }
555
556 // returns a pointer to the reason if a host matches a kline, NULL if it didnt match
557
558 char* matches_kline(const char* host)
559 {
560         if ((klines.empty()) && (pklines.empty()))
561                 return NULL;
562         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
563                 if (match(host,i->hostmask))
564                         return i->reason;
565         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
566                 if (match(host,i->hostmask))
567                         return i->reason;
568         return NULL;
569 }
570
571 bool GSortComparison ( const GLine one, const GLine two )
572 {
573         return (one.duration + one.set_time) < (two.duration + two.set_time);
574 }
575
576 bool ESortComparison ( const ELine one, const ELine two )
577 {
578         return (one.duration + one.set_time) < (two.duration + two.set_time);
579 }
580
581 bool ZSortComparison ( const ZLine one, const ZLine two )
582 {
583         return (one.duration + one.set_time) < (two.duration + two.set_time);
584 }
585
586 bool KSortComparison ( const KLine one, const KLine two )
587 {
588         return (one.duration + one.set_time) < (two.duration + two.set_time);
589 }
590
591 bool QSortComparison ( const QLine one, const QLine two )
592 {
593         return (one.duration + one.set_time) < (two.duration + two.set_time);
594 }
595
596 // removes lines that have expired
597
598 void expire_lines()
599 {
600         time_t current = TIME;
601
602         /* Because we now store all our XLines in sorted order using (i->duration + i->set_time) as a key, this
603          * means that to expire the XLines we just need to do a while, picking off the top few until there are
604          * none left at the head of the queue that are after the current time.
605          */
606
607         while ((glines.size()) && (current > (glines.begin()->duration + glines.begin()->set_time)))
608         {
609                 std::vector<GLine>::iterator i = glines.begin();
610                 WriteOpers("Expiring timed G-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
611                 glines.erase(i);
612         }
613
614         while ((elines.size()) && (current > (elines.begin()->duration + elines.begin()->set_time)))
615         {
616                 std::vector<ELine>::iterator i = elines.begin();
617                 WriteOpers("Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
618                 elines.erase(i);
619         }
620
621         while ((zlines.size()) && (current > (zlines.begin()->duration + zlines.begin()->set_time)))
622         {
623                 std::vector<ZLine>::iterator i = zlines.begin();
624                 WriteOpers("Expiring timed Z-Line %s (set by %s %d seconds ago)",i->ipaddr,i->source,i->duration);
625                 zlines.erase(i);
626         }
627
628         while ((klines.size()) && (current > (klines.begin()->duration + klines.begin()->set_time)))
629         {
630                 std::vector<KLine>::iterator i = klines.begin();
631                 WriteOpers("Expiring timed K-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
632                 klines.erase(i);
633         }
634
635         while ((qlines.size()) && (current > (qlines.begin()->duration + qlines.begin()->set_time)))
636         {
637                 std::vector<QLine>::iterator i = qlines.begin();
638                 WriteOpers("Expiring timed Q-Line %s (set by %s %d seconds ago)",i->nick,i->source,i->duration);
639                 qlines.erase(i);
640         }
641         
642 }
643
644 // applies lines, removing clients and changing nicks etc as applicable
645
646 void apply_lines(const int What)
647 {
648         bool go_again = true;
649         char reason[MAXBUF];
650         char host[MAXBUF];
651         
652         if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()))
653                 return;
654         
655         while (go_again)
656         {
657                 go_again = false;
658                 for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
659                 {
660                         if (u->second->fd > -1)
661                         {
662                                 snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host);
663                                 if (elines.size())
664                                 {
665                                         // ignore people matching exempts
666                                         if (matches_exception(host))
667                                                 continue;
668                                 }
669                                 if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
670                                 {
671                                         char* check = matches_gline(host);
672                                         if (check)
673                                         {
674                                                 WriteOpers("*** User %s matches G-Line: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",check);
675                                                 snprintf(reason,MAXBUF,"G-Lined: %s",check);
676                                                 kill_link(u->second,reason);
677                                                 go_again = true;
678                                                 break;
679                                         }
680                                 }
681                                 if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
682                                 {
683                                         char* check = matches_kline(host);
684                                         if (check)
685                                         {
686                                                 WriteOpers("*** User %s matches K-Line: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",check);
687                                                 snprintf(reason,MAXBUF,"K-Lined: %s",check);
688                                                 kill_link(u->second,reason);
689                                                 go_again = true;
690                                                 break;
691                                         }
692                                 }
693                                 if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
694                                 {
695                                         char* check = matches_qline(u->second->nick);
696                                         if (check)
697                                         {
698                                                 snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
699                                                 WriteOpers("*** Q-Lined nickname %s from %s: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",u->second->host,check);
700                                                 kill_link(u->second,reason);
701                                                 go_again = true;
702                                                 break;
703                                         }
704                                 }
705                                 if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
706                                 {
707                                         char* check = matches_zline(u->second->ip);
708                                         if (check)
709                                         {
710                                                 snprintf(reason,MAXBUF,"Z-Lined: %s",check);
711                                                 WriteOpers("*** User %s matches Z-Line: %s",u->second->registered == 7 ? u->second->nick:"<unknown>",u->second->host,check);
712                                                 kill_link(u->second,reason);
713                                                 go_again = true;
714                                                 break;
715                                         }
716                                 }
717                         }
718                 }
719         }
720 }
721
722 void stats_k(userrec* user)
723 {
724         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
725                 WriteServ(user->fd,"216 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
726         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
727                 WriteServ(user->fd,"216 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
728 }
729
730 void stats_g(userrec* user)
731 {
732         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
733                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
734         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
735                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
736 }
737
738 void stats_q(userrec* user)
739 {
740         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
741                 WriteServ(user->fd,"217 %s :%s %d %d %s %s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
742         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
743                 WriteServ(user->fd,"217 %s :%s %d %d %s %s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
744 }
745
746 void stats_z(userrec* user)
747 {
748         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
749                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
750         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
751                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
752 }
753
754 void stats_e(userrec* user)
755 {
756         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
757                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
758         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
759                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
760 }