]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/xline.cpp
Added CullList class
[user/henk/code/inspircd.git] / src / xline.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2005 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 #include "typedefs.h"
50 #include "cull_list.h"
51
52 extern ServerConfig *Config;
53
54 extern int MODCOUNT;
55 extern std::vector<Module*> modules;
56 extern std::vector<ircd_module*> factory;
57 extern ServerConfig* Config;
58 extern user_hash clientlist;
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 void read_xline_defaults()
111 {
112         char ipmask[MAXBUF];
113         char nick[MAXBUF];
114         char host[MAXBUF];
115         char reason[MAXBUF];
116
117         for (int i = 0; i < Config->ConfValueEnum("badip",&Config->config_f); i++)
118         {
119                 Config->ConfValue("badip","ipmask",i,ipmask,&Config->config_f);
120                 Config->ConfValue("badip","reason",i,reason,&Config->config_f);
121                 add_zline(0,"<Config>",reason,ipmask);
122                 log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason);
123         }
124         
125         for (int i = 0; i < Config->ConfValueEnum("badnick",&Config->config_f); i++)
126         {
127                 Config->ConfValue("badnick","nick",i,nick,&Config->config_f);
128                 Config->ConfValue("badnick","reason",i,reason,&Config->config_f);
129                 add_qline(0,"<Config>",reason,nick);
130                 log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason);
131         }
132         
133         for (int i = 0; i < Config->ConfValueEnum("badhost",&Config->config_f); i++)
134         {
135                 Config->ConfValue("badhost","host",i,host,&Config->config_f);
136                 Config->ConfValue("badhost","reason",i,reason,&Config->config_f);
137                 add_kline(0,"<Config>",reason,host);
138                 log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason);
139         }
140         for (int i = 0; i < Config->ConfValueEnum("exception",&Config->config_f); i++)
141         {
142                 Config->ConfValue("exception","host",i,host,&Config->config_f);
143                 Config->ConfValue("exception","reason",i,reason,&Config->config_f);
144                 add_eline(0,"<Config>",reason,host);
145                 log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason);
146         }
147 }
148
149 // adds a g:line
150
151 void add_gline(long duration, const char* source,const char* reason,const char* hostmask)
152 {
153         del_gline(hostmask);
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         if (duration)
162         {
163                 glines.push_back(item);
164                 sort(glines.begin(), glines.end(),GSortComparison);
165         }
166         else
167         {
168                 pglines.push_back(item);
169         }
170 }
171
172 // adds an e:line (exception to bans)
173
174 void add_eline(long duration, const char* source, const char* reason, const char* hostmask)
175 {
176         del_eline(hostmask);
177         ELine item;
178         item.duration = duration;
179         strlcpy(item.hostmask,hostmask,199);
180         strlcpy(item.reason,reason,MAXBUF);
181         strlcpy(item.source,source,255);
182         item.n_matches = 0;
183         item.set_time = TIME;
184         if (duration)
185         {
186                 elines.push_back(item);
187                 sort(elines.begin(), elines.end(),ESortComparison);
188         }
189         else
190         {
191                 pelines.push_back(item);
192         }
193 }
194
195 // adds a q:line
196
197 void add_qline(long duration, const char* source, const char* reason, const char* nickname)
198 {
199         del_qline(nickname);
200         QLine item;
201         item.duration = duration;
202         strlcpy(item.nick,nickname,63);
203         strlcpy(item.reason,reason,MAXBUF);
204         strlcpy(item.source,source,255);
205         item.n_matches = 0;
206         item.is_global = false;
207         item.set_time = TIME;
208         if (duration)
209         {
210                 qlines.push_back(item);
211                 sort(qlines.begin(), qlines.end(),QSortComparison);
212         }
213         else
214         {
215                 pqlines.push_back(item);
216         }
217 }
218
219 // adds a z:line
220
221 void add_zline(long duration, const char* source, const char* reason, const char* ipaddr)
222 {
223         del_zline(ipaddr);
224         ZLine item;
225         item.duration = duration;
226         if (strchr(ipaddr,'@'))
227         {
228                 while (*ipaddr != '@')
229                         ipaddr++;
230                 ipaddr++;
231         }
232         strlcpy(item.ipaddr,ipaddr,39);
233         strlcpy(item.reason,reason,MAXBUF);
234         strlcpy(item.source,source,255);
235         item.n_matches = 0;
236         item.is_global = false;
237         item.set_time = TIME;
238         if (duration)
239         {
240                 zlines.push_back(item);
241                 sort(zlines.begin(), zlines.end(),ZSortComparison);
242         }
243         else
244         {
245                 pzlines.push_back(item);
246         }
247 }
248
249 // adds a k:line
250
251 void add_kline(long duration, const char* source, const char* reason, const char* hostmask)
252 {
253         del_kline(hostmask);
254         KLine item;
255         item.duration = duration;
256         strlcpy(item.hostmask,hostmask,200);
257         strlcpy(item.reason,reason,MAXBUF);
258         strlcpy(item.source,source,255);
259         item.n_matches = 0;
260         item.set_time = TIME;
261         if (duration)
262         {
263                 klines.push_back(item);
264                 sort(klines.begin(), klines.end(),KSortComparison);
265         }
266         else
267         {
268                 pklines.push_back(item);
269         }
270 }
271
272 // deletes a g:line, returns true if the line existed and was removed
273
274 bool del_gline(const char* hostmask)
275 {
276         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
277         {
278                 if (!strcasecmp(hostmask,i->hostmask))
279                 {
280                         glines.erase(i);
281                         return true;
282                 }
283         }
284         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
285         {
286                 if (!strcasecmp(hostmask,i->hostmask))
287                 {
288                         pglines.erase(i);
289                         return true;
290                 }
291         }
292         return false;
293 }
294
295 // deletes a e:line, returns true if the line existed and was removed
296
297 bool del_eline(const char* hostmask)
298 {
299         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
300         {
301                 if (!strcasecmp(hostmask,i->hostmask))
302                 {
303                         elines.erase(i);
304                         return true;
305                 }
306         }
307         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
308         {
309                 if (!strcasecmp(hostmask,i->hostmask))
310                 {
311                         pelines.erase(i);
312                         return true;
313                 }
314         }
315         return false;
316 }
317
318 // deletes a q:line, returns true if the line existed and was removed
319
320 bool del_qline(const char* nickname)
321 {
322         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
323         {
324                 if (!strcasecmp(nickname,i->nick))
325                 {
326                         qlines.erase(i);
327                         return true;
328                 }
329         }
330         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
331         {
332                 if (!strcasecmp(nickname,i->nick))
333                 {
334                         pqlines.erase(i);
335                         return true;
336                 }
337         }
338         return false;
339 }
340
341 bool qline_make_global(const char* nickname)
342 {
343         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
344         {
345                 if (!strcasecmp(nickname,i->nick))
346                 {
347                         i->is_global = true;
348                         return true;
349                 }
350         }
351         return false;
352 }
353
354 bool zline_make_global(const char* ipaddr)
355 {
356         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
357         {
358                 if (!strcasecmp(ipaddr,i->ipaddr))
359                 {
360                         i->is_global = true;
361                         return true;
362                 }
363         }
364         return false;
365 }
366
367 // deletes a z:line, returns true if the line existed and was removed
368
369 bool del_zline(const char* ipaddr)
370 {
371         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
372         {
373                 if (!strcasecmp(ipaddr,i->ipaddr))
374                 {
375                         zlines.erase(i);
376                         return true;
377                 }
378         }
379         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
380         {
381                 if (!strcasecmp(ipaddr,i->ipaddr))
382                 {
383                         pzlines.erase(i);
384                         return true;
385                 }
386         }
387         return false;
388 }
389
390 // deletes a k:line, returns true if the line existed and was removed
391
392 bool del_kline(const char* hostmask)
393 {
394         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
395         {
396                 if (!strcasecmp(hostmask,i->hostmask))
397                 {
398                         klines.erase(i);
399                         return true;
400                 }
401         }
402         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
403         {
404                 if (!strcasecmp(hostmask,i->hostmask))
405                 {
406                         pklines.erase(i);
407                         return true;
408                 }
409         }
410         return false;
411 }
412
413 // returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
414
415 char* matches_qline(const char* nick)
416 {
417         if ((qlines.empty()) && (pqlines.empty()))
418                 return NULL;
419         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
420                 if (match(nick,i->nick))
421                         return i->reason;
422         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
423                 if (match(nick,i->nick))
424                         return i->reason;
425         return NULL;
426 }
427
428 // returns a pointer to the reason if a host matches a gline, NULL if it didnt match
429
430 char* matches_gline(const char* host)
431 {
432         if ((glines.empty()) && (pglines.empty()))
433                 return NULL;
434         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
435                 if (match(host,i->hostmask))
436                         return i->reason;
437         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
438                 if (match(host,i->hostmask))
439                         return i->reason;
440         return NULL;
441 }
442
443 char* matches_exception(const char* host)
444 {
445         if ((elines.empty()) && (pelines.empty()))
446                 return NULL;
447         char host2[MAXBUF];
448         snprintf(host2,MAXBUF,"*@%s",host);
449         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
450                 if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
451                         return i->reason;
452         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
453                 if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
454                         return i->reason;
455         return NULL;
456 }
457
458
459 void gline_set_creation_time(char* host, time_t create_time)
460 {
461         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
462         {
463                 if (!strcasecmp(host,i->hostmask))
464                 {
465                         i->set_time = create_time;
466                         return;
467                 }
468         }
469         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
470         {
471                 if (!strcasecmp(host,i->hostmask))
472                 {
473                         i->set_time = create_time;
474                         return;
475                 }
476         }
477         return ;        
478 }
479
480 void eline_set_creation_time(char* host, time_t create_time)
481 {
482         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
483         {
484                 if (!strcasecmp(host,i->hostmask))
485                 {
486                         i->set_time = create_time;
487                         return;
488                 }
489         }
490         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++) 
491         {
492                 if (!strcasecmp(host,i->hostmask))
493                 {
494                         i->set_time = create_time;
495                         return;
496                 }
497         }
498         return;
499 }
500
501 void qline_set_creation_time(char* nick, time_t create_time)
502 {
503         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
504         {
505                 if (!strcasecmp(nick,i->nick))
506                 {
507                         i->set_time = create_time;
508                         return;
509                 }
510         }
511         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
512         {
513                 if (!strcasecmp(nick,i->nick))
514                 {
515                         i->set_time = create_time;
516                         return;
517                 }
518         }
519         return;
520 }
521
522 void zline_set_creation_time(char* ip, time_t create_time)
523 {
524         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
525         {
526                 if (!strcasecmp(ip,i->ipaddr))
527                 {
528                         i->set_time = create_time;
529                         return;
530                 }
531         }
532         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
533         {
534                 if (!strcasecmp(ip,i->ipaddr))
535                 {
536                         i->set_time = create_time;
537                         return;
538                 }
539         }
540         return;
541 }
542
543 // returns a pointer to the reason if an ip address matches a zline, NULL if it didnt match
544
545 char* matches_zline(const char* ipaddr)
546 {
547         if ((zlines.empty()) && (pzlines.empty()))
548                 return NULL;
549         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
550                 if (match(ipaddr,i->ipaddr))
551                         return i->reason;
552         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
553                 if (match(ipaddr,i->ipaddr))
554                         return i->reason;
555         return NULL;
556 }
557
558 // returns a pointer to the reason if a host matches a kline, NULL if it didnt match
559
560 char* matches_kline(const char* host)
561 {
562         if ((klines.empty()) && (pklines.empty()))
563                 return NULL;
564         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
565                 if (match(host,i->hostmask))
566                         return i->reason;
567         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
568                 if (match(host,i->hostmask))
569                         return i->reason;
570         return NULL;
571 }
572
573 bool GSortComparison ( const GLine one, const GLine two )
574 {
575         return (one.duration + one.set_time) < (two.duration + two.set_time);
576 }
577
578 bool ESortComparison ( const ELine one, const ELine two )
579 {
580         return (one.duration + one.set_time) < (two.duration + two.set_time);
581 }
582
583 bool ZSortComparison ( const ZLine one, const ZLine two )
584 {
585         return (one.duration + one.set_time) < (two.duration + two.set_time);
586 }
587
588 bool KSortComparison ( const KLine one, const KLine two )
589 {
590         return (one.duration + one.set_time) < (two.duration + two.set_time);
591 }
592
593 bool QSortComparison ( const QLine one, const QLine two )
594 {
595         return (one.duration + one.set_time) < (two.duration + two.set_time);
596 }
597
598 // removes lines that have expired
599
600 void expire_lines()
601 {
602         time_t current = TIME;
603
604         /* Because we now store all our XLines in sorted order using (i->duration + i->set_time) as a key, this
605          * means that to expire the XLines we just need to do a while, picking off the top few until there are
606          * none left at the head of the queue that are after the current time.
607          */
608
609         while ((glines.size()) && (current > (glines.begin()->duration + glines.begin()->set_time)))
610         {
611                 std::vector<GLine>::iterator i = glines.begin();
612                 WriteOpers("Expiring timed G-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
613                 glines.erase(i);
614         }
615
616         while ((elines.size()) && (current > (elines.begin()->duration + elines.begin()->set_time)))
617         {
618                 std::vector<ELine>::iterator i = elines.begin();
619                 WriteOpers("Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
620                 elines.erase(i);
621         }
622
623         while ((zlines.size()) && (current > (zlines.begin()->duration + zlines.begin()->set_time)))
624         {
625                 std::vector<ZLine>::iterator i = zlines.begin();
626                 WriteOpers("Expiring timed Z-Line %s (set by %s %d seconds ago)",i->ipaddr,i->source,i->duration);
627                 zlines.erase(i);
628         }
629
630         while ((klines.size()) && (current > (klines.begin()->duration + klines.begin()->set_time)))
631         {
632                 std::vector<KLine>::iterator i = klines.begin();
633                 WriteOpers("Expiring timed K-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
634                 klines.erase(i);
635         }
636
637         while ((qlines.size()) && (current > (qlines.begin()->duration + qlines.begin()->set_time)))
638         {
639                 std::vector<QLine>::iterator i = qlines.begin();
640                 WriteOpers("Expiring timed Q-Line %s (set by %s %d seconds ago)",i->nick,i->source,i->duration);
641                 qlines.erase(i);
642         }
643         
644 }
645
646 // applies lines, removing clients and changing nicks etc as applicable
647
648 void apply_lines(const int What)
649 {
650         char reason[MAXBUF];
651         char host[MAXBUF];
652         
653         if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()))
654                 return;
655
656         CullList* Goners = new CullList();
657         
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                                         snprintf(reason,MAXBUF,"G-Lined: %s",check);
675                                         Goners->AddItem(u->second,reason);
676                                 }
677                         }
678                         if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
679                         {
680                                 char* check = matches_kline(host);
681                                 if (check)
682                                 {
683                                         snprintf(reason,MAXBUF,"K-Lined: %s",check);
684                                         Goners->AddItem(u->second,reason);
685                                 }
686                         }
687                         if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
688                         {
689                                 char* check = matches_qline(u->second->nick);
690                                 if (check)
691                                 {
692                                         snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
693                                         Goners->AddItem(u->second,reason);
694                                 }
695                         }
696                         if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
697                         {
698                                 char* check = matches_zline(u->second->ip);
699                                 if (check)
700                                 {
701                                         snprintf(reason,MAXBUF,"Z-Lined: %s",check);
702                                         Goners->AddItem(u->second,reason);
703                                 }
704                         }
705                 }
706         }
707
708         Goners->Apply();
709         delete Goners;
710 }
711
712 void stats_k(userrec* user)
713 {
714         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
715                 WriteServ(user->fd,"216 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
716         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
717                 WriteServ(user->fd,"216 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
718 }
719
720 void stats_g(userrec* user)
721 {
722         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
723                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
724         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
725                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
726 }
727
728 void stats_q(userrec* user)
729 {
730         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
731                 WriteServ(user->fd,"217 %s :%s %d %d %s %s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
732         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
733                 WriteServ(user->fd,"217 %s :%s %d %d %s %s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
734 }
735
736 void stats_z(userrec* user)
737 {
738         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
739                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
740         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
741                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
742 }
743
744 void stats_e(userrec* user)
745 {
746         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
747                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
748         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
749                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
750 }