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