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