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