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