2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
5 * Copyright (C) 2018 linuxdaemon <linuxdaemon.irc@gmail.com>
6 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
7 * Copyright (C) 2012, 2018-2019 Robby <robby@chatbelgie.be>
8 * Copyright (C) 2012, 2014 Attila Molnar <attilamolnar@hush.com>
9 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
11 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
12 * Copyright (C) 2006-2008, 2010 Craig Edwards <brain@inspircd.org>
14 * This file is part of InspIRCd. InspIRCd is free software: you can
15 * redistribute it and/or modify it under the terms of the GNU General Public
16 * License as published by the Free Software Foundation, version 2.
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include "core_xline.h"
32 CommandEline::CommandEline(Module* parent)
33 : Command(parent, "ELINE", 1, 3)
36 syntax = "<user@host> [<duration> :<reason>]";
41 CmdResult CommandEline::Handle(User* user, const Params& parameters)
43 std::string target = parameters[0];
45 if (parameters.size() >= 3)
48 User* find = ServerInstance->FindNick(target);
49 if ((find) && (find->registered == REG_ALL))
52 ih.second = find->GetIPString();
53 target = std::string("*@") + find->GetIPString();
56 ih = ServerInstance->XLines->IdentSplit(target);
60 user->WriteNotice("*** Target not found.");
64 InsaneBan::IPHostMatcher matcher;
65 if (InsaneBan::MatchesEveryone(ih.first+"@"+ih.second, matcher, user, "E", "hostmasks"))
68 unsigned long duration;
69 if (!InspIRCd::Duration(parameters[1], duration))
71 user->WriteNotice("*** Invalid duration for E-line.");
74 ELine* el = new ELine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
75 if (ServerInstance->XLines->AddLine(el, user))
79 ServerInstance->SNO->WriteToSnoMask('x', "%s added permanent E-line for %s: %s", user->nick.c_str(), target.c_str(), parameters[2].c_str());
83 ServerInstance->SNO->WriteToSnoMask('x', "%s added timed E-line for %s, expires in %s (on %s): %s",
84 user->nick.c_str(), target.c_str(), InspIRCd::DurationString(duration).c_str(),
85 InspIRCd::TimeString(ServerInstance->Time() + duration).c_str(), parameters[2].c_str());
91 user->WriteNotice("*** E-line for " + target + " already exists.");
98 if (ServerInstance->XLines->DelLine(target.c_str(), "E", reason, user))
100 ServerInstance->SNO->WriteToSnoMask('x', "%s removed E-line on %s: %s", user->nick.c_str(), target.c_str(), reason.c_str());
104 user->WriteNotice("*** E-line " + target + " not found on the list.");