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