]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/modules/shun.h
Merge branch 'insp20' into master.
[user/henk/code/inspircd.git] / include / modules / shun.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2017 Dylan Frank <b00mx0r@aureus.pw>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #pragma once
21
22 #include "xline.h"
23
24 /** Shun class
25  */
26 class Shun : public XLine
27 {
28   public:
29         /** Create a Shun.
30          * @param s_time The set time
31          * @param d The duration of the xline
32          * @param src The sender of the xline
33          * @param re The reason of the xline
34          * @param shunmask Mask to match
35          */
36         Shun(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& shunmask)
37                 : XLine(s_time, d, src, re, "SHUN")
38                 , matchtext(shunmask)
39         {
40         }
41
42         bool Matches(User* u) CXX11_OVERRIDE
43         {
44                 LocalUser* lu = IS_LOCAL(u);
45                 if (lu && lu->exempt)
46                         return false;
47
48                 if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetIPString(), matchtext))
49                         return true;
50
51                 if (InspIRCd::MatchCIDR(u->GetIPString(), matchtext, ascii_case_insensitive_map))
52                         return true;
53
54                 return false;
55         }
56
57         bool Matches(const std::string& str) CXX11_OVERRIDE
58         {
59                 return (matchtext == str);
60         }
61
62         const std::string& Displayable() CXX11_OVERRIDE
63         {
64                 return matchtext;
65         }
66
67   private:
68         /** Matching mask **/
69         std::string matchtext;
70 };