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