]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/xline.cpp
84c46592773c7fe94fd0a2f9ab4272d309875539
[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                         (*i)->expiry = create_time + (*i)->duration;
439                         return;
440                 }
441         }
442         for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
443         {
444                 if (!strcasecmp(host,(*i)->hostmask))
445                 {
446                         (*i)->set_time = create_time;
447                         return;
448                 }
449         }
450         return ;        
451 }
452
453 void XLineManager::eline_set_creation_time(const char* host, time_t create_time)
454 {
455         for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
456         {
457                 if (!strcasecmp(host,(*i)->hostmask))
458                 {
459                         (*i)->set_time = create_time;
460                         (*i)->expiry = create_time + (*i)->duration;
461                         return;
462                 }
463         }
464         for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)        
465         {
466                 if (!strcasecmp(host,(*i)->hostmask))
467                 {
468                         (*i)->set_time = create_time;
469                         return;
470                 }
471         }
472         return;
473 }
474
475 void XLineManager::qline_set_creation_time(const char* nick, time_t create_time)
476 {
477         for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
478         {
479                 if (!strcasecmp(nick,(*i)->nick))
480                 {
481                         (*i)->set_time = create_time;
482                         (*i)->expiry = create_time + (*i)->duration;
483                         return;
484                 }
485         }
486         for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
487         {
488                 if (!strcasecmp(nick,(*i)->nick))
489                 {
490                         (*i)->set_time = create_time;
491                         return;
492                 }
493         }
494         return;
495 }
496
497 void XLineManager::zline_set_creation_time(const char* ip, time_t create_time)
498 {
499         for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
500         {
501                 if (!strcasecmp(ip,(*i)->ipaddr))
502                 {
503                         (*i)->set_time = create_time;
504                         (*i)->expiry = create_time + (*i)->duration;
505                         return;
506                 }
507         }
508         for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
509         {
510                 if (!strcasecmp(ip,(*i)->ipaddr))
511                 {
512                         (*i)->set_time = create_time;
513                         return;
514                 }
515         }
516         return;
517 }
518
519 // returns a pointer to the reason if an ip address matches a zline, NULL if it didnt match
520
521 ZLine* XLineManager::matches_zline(const char* ipaddr)
522 {
523         if ((zlines.empty()) && (pzlines.empty()))
524                 return NULL;
525         for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
526                 if (match(ipaddr,(*i)->ipaddr, true))
527                         return (*i);
528         for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
529                 if (match(ipaddr,(*i)->ipaddr, true))
530                         return (*i);
531         return NULL;
532 }
533
534 // returns a pointer to the reason if a host matches a kline, NULL if it didnt match
535
536 KLine* XLineManager::matches_kline(userrec* user)
537 {
538         if ((klines.empty()) && (pklines.empty()))
539                 return NULL;
540         for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++)
541         {
542                 if ((match(user->ident,(*i)->identmask)))
543                 {
544                         if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
545                         {
546                                 return (*i);
547                         }
548                 }
549         }
550         for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
551         {
552                 if ((match(user->ident,(*i)->identmask)))
553                 {
554                         if ((match(user->host,(*i)->hostmask, true)) || (match(user->GetIPString(),(*i)->hostmask, true)))
555                         {
556                                 return (*i);
557                         }
558                 }
559         }
560         return NULL;
561 }
562
563 bool XLineManager::GSortComparison ( const GLine* one, const GLine* two )
564 {
565         return (one->expiry) < (two->expiry);
566 }
567
568 bool XLineManager::ESortComparison ( const ELine* one, const ELine* two )
569 {
570         return (one->expiry) < (two->expiry);
571 }
572
573 bool XLineManager::ZSortComparison ( const ZLine* one, const ZLine* two )
574 {
575         return (one->expiry) < (two->expiry);
576 }
577
578 bool XLineManager::KSortComparison ( const KLine* one, const KLine* two )
579 {
580         return (one->expiry) < (two->expiry);
581 }
582
583 bool XLineManager::QSortComparison ( const QLine* one, const QLine* two )
584 {
585         return (one->expiry) < (two->expiry);
586 }
587
588 // removes lines that have expired
589
590 void XLineManager::expire_lines()
591 {
592         time_t current = ServerInstance->Time();
593
594         /* Because we now store all our XLines in sorted order using ((*i)->duration + (*i)->set_time) as a key, this
595          * means that to expire the XLines we just need to do a while, picking off the top few until there are
596          * none left at the head of the queue that are after the current time.
597          */
598
599         while ((glines.size()) && (current > (*glines.begin())->expiry))
600         {
601                 std::vector<GLine*>::iterator i = glines.begin();
602                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed G-Line %s (set by %s %d seconds ago)",(*i)->hostmask,(*i)->source,(*i)->duration);
603                 glines.erase(i);
604         }
605
606         while ((elines.size()) && (current > (*elines.begin())->expiry))
607         {
608                 std::vector<ELine*>::iterator i = elines.begin();
609                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed E-Line %s (set by %s %d seconds ago)",(*i)->hostmask,(*i)->source,(*i)->duration);
610                 elines.erase(i);
611         }
612
613         while ((zlines.size()) && (current > (*zlines.begin())->expiry))
614         {
615                 std::vector<ZLine*>::iterator i = zlines.begin();
616                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Z-Line %s (set by %s %d seconds ago)",(*i)->ipaddr,(*i)->source,(*i)->duration);
617                 zlines.erase(i);
618         }
619
620         while ((klines.size()) && (current > (*klines.begin())->expiry))
621         {
622                 std::vector<KLine*>::iterator i = klines.begin();
623                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed K-Line %s (set by %s %d seconds ago)",(*i)->hostmask,(*i)->source,(*i)->duration);
624                 klines.erase(i);
625         }
626
627         while ((qlines.size()) && (current > (*qlines.begin())->expiry))
628         {
629                 std::vector<QLine*>::iterator i = qlines.begin();
630                 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Q-Line %s (set by %s %d seconds ago)",(*i)->nick,(*i)->source,(*i)->duration);
631                 qlines.erase(i);
632         }
633         
634 }
635
636 // applies lines, removing clients and changing nicks etc as applicable
637
638 void XLineManager::apply_lines(const int What)
639 {
640         char reason[MAXBUF];
641
642         if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()) &&
643         (!pglines.size()) && (!pklines.size()) && (!pzlines.size()) && (!pqlines.size()))
644                 return;
645
646         CullList* Goners = new CullList(ServerInstance);
647         XLine* check = NULL;
648         for (std::vector<userrec*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++)
649         {
650                 userrec* u = (userrec*)(*u2);
651
652                 if (elines.size() || pelines.size())
653                 {
654                         // ignore people matching exempts
655                         if (matches_exception(u))
656                                 continue;
657                 }
658                 if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
659                 {
660                         if ((check = matches_gline(u)))
661                         {
662                                 snprintf(reason,MAXBUF,"G-Lined: %s",check->reason);
663                                 Goners->AddItem(u,reason);
664                         }
665                 }
666                 if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
667                 {
668                         if ((check = matches_kline(u)))
669                         {
670                                 snprintf(reason,MAXBUF,"K-Lined: %s",check->reason);
671                                 Goners->AddItem(u,reason);
672                         }
673                 }
674                 if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
675                 {
676                         if ((check = matches_qline(u->nick)))
677                         {
678                                 snprintf(reason,MAXBUF,"Q-Lined: %s",check->reason);
679                                 Goners->AddItem(u,reason);
680                         }
681                 }
682                 if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
683                 {
684                         if ((check = matches_zline(u->GetIPString())))
685                         {
686                                 snprintf(reason,MAXBUF,"Z-Lined: %s",check->reason);
687                                 Goners->AddItem(u,reason);
688                         }
689                 }
690         }
691
692         Goners->Apply();
693         DELETE(Goners);
694 }
695
696 void XLineManager::stats_k(userrec* user, string_list &results)
697 {
698         std::string sn = ServerInstance->Config->ServerName;
699         for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++)
700                 results.push_back(sn+" 216 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
701         for (std::vector<KLine*>::iterator i = pklines.begin(); i != pklines.end(); i++)
702                 results.push_back(sn+" 216 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
703 }
704
705 void XLineManager::stats_g(userrec* user, string_list &results)
706 {
707         std::string sn = ServerInstance->Config->ServerName;
708         for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.end(); i++)
709                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
710         for (std::vector<GLine*>::iterator i = pglines.begin(); i != pglines.end(); i++)
711                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
712 }
713
714 void XLineManager::stats_q(userrec* user, string_list &results)
715 {
716         std::string sn = ServerInstance->Config->ServerName;
717         for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++)
718                 results.push_back(sn+" 217 "+user->nick+" :"+(*i)->nick+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
719         for (std::vector<QLine*>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
720                 results.push_back(sn+" 217 "+user->nick+" :"+(*i)->nick+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
721 }
722
723 void XLineManager::stats_z(userrec* user, string_list &results)
724 {
725         std::string sn = ServerInstance->Config->ServerName;
726         for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++)
727                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->ipaddr+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
728         for (std::vector<ZLine*>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
729                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->ipaddr+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
730 }
731
732 void XLineManager::stats_e(userrec* user, string_list &results)
733 {
734         std::string sn = ServerInstance->Config->ServerName;
735         for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++)
736                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
737         for (std::vector<ELine*>::iterator i = pelines.begin(); i != pelines.end(); i++)
738                 results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);
739 }
740
741 XLineManager::XLineManager(InspIRCd* Instance) : ServerInstance(Instance)
742 {
743 }