]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/xline.cpp
24a1fccd08e19053c7314f3b68ccb330a8ee36fa
[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 = new GLine(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 = new ELine(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 = new QLine(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 = new ZLine(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 = new KLine(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                         delete *i;
239                         glines.erase(i);
240                         return true;
241                 }
242         }
243         for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
244         {
245                 if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
246                 {
247                         delete *i;
248                         pglines.erase(i);
249                         return true;
250                 }
251         }
252         return false;
253 }
254
255 // deletes a e:line, returns true if the line existed and was removed
256
257 bool XLineManager::del_eline(const char* hostmask)
258 {
259         IdentHostPair ih = IdentSplit(hostmask);
260         for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
261         {
262                 if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
263                 {
264                         delete *i;
265                         elines.erase(i);
266                         return true;
267                 }
268         }
269         for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
270         {
271                 if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
272                 {
273                         delete *i;
274                         pelines.erase(i);
275                         return true;
276                 }
277         }
278         return false;
279 }
280
281 // deletes a q:line, returns true if the line existed and was removed
282
283 bool XLineManager::del_qline(const char* nickname)
284 {
285         for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
286         {
287                 if (!strcasecmp(nickname,(*i)->nick))
288                 {
289                         delete *i;
290                         qlines.erase(i);
291                         return true;
292                 }
293         }
294         for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
295         {
296                 if (!strcasecmp(nickname,(*i)->nick))
297                 {
298                         delete *i;
299                         pqlines.erase(i);
300                         return true;
301                 }
302         }
303         return false;
304 }
305
306 // deletes a z:line, returns true if the line existed and was removed
307
308 bool XLineManager::del_zline(const char* ipaddr)
309 {
310         for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
311         {
312                 if (!strcasecmp(ipaddr,(*i)->ipaddr))
313                 {
314                         delete *i;
315                         zlines.erase(i);
316                         return true;
317                 }
318         }
319         for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
320         {
321                 if (!strcasecmp(ipaddr,(*i)->ipaddr))
322                 {
323                         delete *i;
324                         pzlines.erase(i);
325                         return true;
326                 }
327         }
328         return false;
329 }
330
331 // deletes a k:line, returns true if the line existed and was removed
332
333 bool XLineManager::del_kline(const char* hostmask)
334 {
335         IdentHostPair ih = IdentSplit(hostmask);
336         for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++)
337         {
338                 if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
339                 {
340                         delete *i;
341                         klines.erase(i);
342                         return true;
343                 }
344         }
345         for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
346         {
347                 if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask))
348                 {
349                         delete *i;
350                         pklines.erase(i);
351                         return true;
352                 }
353         }
354         return false;
355 }
356
357 // returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
358
359 QLine* XLineManager::matches_qline(const char* nick)
360 {
361         if ((qlines.empty()) && (pqlines.empty()))
362                 return NULL;
363         for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
364                 if (match(nick,(*i)->nick))
365                         return (*i);
366         for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
367                 if (match(nick,(*i)->nick))
368                         return (*i);
369         return NULL;
370 }
371
372 // returns a pointer to the reason if a host matches a gline, NULL if it didnt match
373
374 GLine* XLineManager::matches_gline(userrec* user)
375 {
376         if ((glines.empty()) && (pglines.empty()))
377                 return NULL;
378         for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.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);
385                         }
386                 }
387         }
388         for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
389         {
390                 if ((match(user->ident,(*i)->identmask)))
391                 {
392                         if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
393                         {
394                                 return (*i);
395                         }
396                 }
397         }
398         return NULL;
399 }
400
401 ELine* XLineManager::matches_exception(userrec* user)
402 {                       
403         if ((elines.empty()) && (pelines.empty()))
404                 return NULL;
405         char host2[MAXBUF];
406         snprintf(host2,MAXBUF,"*@%s",user->host);
407         for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.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);
414                         }
415                 }
416         }
417         for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
418         {
419                 if ((match(user->ident,(*i)->identmask)))
420                 {
421                         if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
422                         {
423                                 return (*i);
424                         }
425                 }
426         }
427         return NULL;
428 }
429
430
431 void XLineManager::gline_set_creation_time(const char* host, time_t create_time)
432 {
433         for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.end(); i++)
434         {
435                 if (!strcasecmp(host,(*i)->hostmask))
436                 {
437                         (*i)->set_time = create_time;
438                         return;
439                 }
440         }
441         for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
442         {
443                 if (!strcasecmp(host,(*i)->hostmask))
444                 {
445                         (*i)->set_time = create_time;
446                         return;
447                 }
448         }
449         return ;        
450 }
451
452 void XLineManager::eline_set_creation_time(const char* host, time_t create_time)
453 {
454         for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
455         {
456                 if (!strcasecmp(host,(*i)->hostmask))
457                 {
458                         (*i)->set_time = create_time;
459                         return;
460                 }
461         }
462         for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)        
463         {
464                 if (!strcasecmp(host,(*i)->hostmask))
465                 {
466                         (*i)->set_time = create_time;
467                         return;
468                 }
469         }
470         return;
471 }
472
473 void XLineManager::qline_set_creation_time(const char* nick, time_t create_time)
474 {
475         for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
476         {
477                 if (!strcasecmp(nick,(*i)->nick))
478                 {
479                         (*i)->set_time = create_time;
480                         return;
481                 }
482         }
483         for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
484         {
485                 if (!strcasecmp(nick,(*i)->nick))
486                 {
487                         (*i)->set_time = create_time;
488                         return;
489                 }
490         }
491         return;
492 }
493
494 void XLineManager::zline_set_creation_time(const char* ip, time_t create_time)
495 {
496         for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
497         {
498                 if (!strcasecmp(ip,(*i)->ipaddr))
499                 {
500                         (*i)->set_time = create_time;
501                         return;
502                 }
503         }
504         for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
505         {
506                 if (!strcasecmp(ip,(*i)->ipaddr))
507                 {
508                         (*i)->set_time = create_time;
509                         return;
510                 }
511         }
512         return;
513 }
514
515 // returns a pointer to the reason if an ip address matches a zline, NULL if it didnt match
516
517 ZLine* XLineManager::matches_zline(const char* ipaddr)
518 {
519         if ((zlines.empty()) && (pzlines.empty()))
520                 return NULL;
521         for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
522                 if (match(ipaddr,(*i)->ipaddr, true))
523                         return (*i);
524         for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
525                 if (match(ipaddr,(*i)->ipaddr, true))
526                         return (*i);
527         return NULL;
528 }
529
530 // returns a pointer to the reason if a host matches a kline, NULL if it didnt match
531
532 KLine* XLineManager::matches_kline(userrec* user)
533 {
534         if ((klines.empty()) && (pklines.empty()))
535                 return NULL;
536         for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.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);
543                         }
544                 }
545         }
546         for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
547         {
548                 if ((match(user->ident,(*i)->identmask)))
549                 {
550                         if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
551                         {
552                                 return (*i);
553                         }
554                 }
555         }
556         return NULL;
557 }
558
559 bool XLineManager::GSortComparison ( const GLine* one, const GLine* two )
560 {
561         return (one->expiry) < (two->expiry);
562 }
563
564 bool XLineManager::ESortComparison ( const ELine* one, const ELine* two )
565 {
566         return (one->expiry) < (two->expiry);
567 }
568
569 bool XLineManager::ZSortComparison ( const ZLine* one, const ZLine* two )
570 {
571         return (one->expiry) < (two->expiry);
572 }
573
574 bool XLineManager::KSortComparison ( const KLine* one, const KLine* two )
575 {
576         return (one->expiry) < (two->expiry);
577 }
578
579 bool XLineManager::QSortComparison ( const QLine* one, const QLine* two )
580 {
581         return (one->expiry) < (two->expiry);
582 }
583
584 // removes lines that have expired
585
586 void XLineManager::expire_lines()
587 {
588         time_t current = ServerInstance->Time();
589
590         /* Because we now store all our XLines in sorted order using ((*i)->duration + (*i)->set_time) as a key, this
591          * means that to expire the XLines we just need to do a while, picking off the top few until there are
592          * none left at the head of the queue that are after the current time.
593          */
594
595         while ((glines.size()) && (current > (*glines.begin())->expiry))
596         {
597                 std::vector<GLine*>::iterator i = glines.begin();
598                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed G-Line %s (set by %s %d seconds ago)",(*i)->hostmask,(*i)->source,(*i)->duration);
599                 glines.erase(i);
600         }
601
602         while ((elines.size()) && (current > (*elines.begin())->expiry))
603         {
604                 std::vector<ELine*>::iterator i = elines.begin();
605                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed E-Line %s (set by %s %d seconds ago)",(*i)->hostmask,(*i)->source,(*i)->duration);
606                 elines.erase(i);
607         }
608
609         while ((zlines.size()) && (current > (*zlines.begin())->expiry))
610         {
611                 std::vector<ZLine*>::iterator i = zlines.begin();
612                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Z-Line %s (set by %s %d seconds ago)",(*i)->ipaddr,(*i)->source,(*i)->duration);
613                 zlines.erase(i);
614         }
615
616         while ((klines.size()) && (current > (*klines.begin())->expiry))
617         {
618                 std::vector<KLine*>::iterator i = klines.begin();
619                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed K-Line %s (set by %s %d seconds ago)",(*i)->hostmask,(*i)->source,(*i)->duration);
620                 klines.erase(i);
621         }
622
623         while ((qlines.size()) && (current > (*qlines.begin())->expiry))
624         {
625                 std::vector<QLine*>::iterator i = qlines.begin();
626                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Q-Line %s (set by %s %d seconds ago)",(*i)->nick,(*i)->source,(*i)->duration);
627                 qlines.erase(i);
628         }
629         
630 }
631
632 // applies lines, removing clients and changing nicks etc as applicable
633
634 void XLineManager::apply_lines(const int What)
635 {
636         char reason[MAXBUF];
637
638         if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()) &&
639         (!pglines.size()) && (!pklines.size()) && (!pzlines.size()) && (!pqlines.size()))
640                 return;
641
642         CullList* Goners = new CullList(ServerInstance);
643         XLine* check = NULL;
644         for (std::vector<userrec*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
645         {
646                 userrec* u = (userrec*)(*u2);
647
648                 if (elines.size() || pelines.size())
649                 {
650                         // ignore people matching exempts
651                         if (matches_exception(u))
652                                 continue;
653                 }
654                 if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
655                 {
656                         if ((check = matches_gline(u)))
657                         {
658                                 snprintf(reason,MAXBUF,"G-Lined: %s",check->reason);
659                                 Goners->AddItem(u,reason);
660                         }
661                 }
662                 if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
663                 {
664                         if ((check = matches_kline(u)))
665                         {
666                                 snprintf(reason,MAXBUF,"K-Lined: %s",check->reason);
667                                 Goners->AddItem(u,reason);
668                         }
669                 }
670                 if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
671                 {
672                         if ((check = matches_qline(u->nick)))
673                         {
674                                 snprintf(reason,MAXBUF,"Q-Lined: %s",check->reason);
675                                 Goners->AddItem(u,reason);
676                         }
677                 }
678                 if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
679                 {
680                         if ((check = matches_zline(u->GetIPString())))
681                         {
682                                 snprintf(reason,MAXBUF,"Z-Lined: %s",check->reason);
683                                 Goners->AddItem(u,reason);
684                         }
685                 }
686         }
687
688         Goners->Apply();
689         DELETE(Goners);
690 }
691
692 void XLineManager::stats_k(userrec* user, string_list &results)
693 {
694         std::string sn = ServerInstance->Config->ServerName;
695         for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++)
696                 results.push_back(sn+" 216 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
697         for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
698                 results.push_back(sn+" 216 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
699 }
700
701 void XLineManager::stats_g(userrec* user, string_list &results)
702 {
703         std::string sn = ServerInstance->Config->ServerName;
704         for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.end(); i++)
705                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
706         for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
707                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
708 }
709
710 void XLineManager::stats_q(userrec* user, string_list &results)
711 {
712         std::string sn = ServerInstance->Config->ServerName;
713         for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
714                 results.push_back(sn+" 217 "+user->nick+" :"+(*i)->nick+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
715         for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
716                 results.push_back(sn+" 217 "+user->nick+" :"+(*i)->nick+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
717 }
718
719 void XLineManager::stats_z(userrec* user, string_list &results)
720 {
721         std::string sn = ServerInstance->Config->ServerName;
722         for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
723                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->ipaddr+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
724         for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
725                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->ipaddr+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
726 }
727
728 void XLineManager::stats_e(userrec* user, string_list &results)
729 {
730         std::string sn = ServerInstance->Config->ServerName;
731         for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
732                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
733         for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
734                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
735 }
736
737 XLineManager::XLineManager(InspIRCd* Instance) : ServerInstance(Instance)
738 {
739 }