2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
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.
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
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/>.
23 #include "treesocket.h"
24 #include "treeserver.h"
27 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
29 bool TreeSocket::AddLine(const std::string &prefix, parameterlist ¶ms)
31 if (params.size() < 6)
33 ServerInstance->SNO->WriteToSnoMask('d', "%s sent me a malformed ADDLINE", MyRoot->GetName().c_str());
37 XLineFactory* xlf = ServerInstance->XLines->GetFactory(params[0]);
39 std::string setter = "<unknown>";
40 User* usr = ServerInstance->FindNick(prefix);
45 TreeServer* t = Utils->FindServer(prefix);
47 setter = t->GetName().c_str();
52 ServerInstance->SNO->WriteToSnoMask('d',"%s sent me an unknown ADDLINE type (%s).",setter.c_str(),params[0].c_str());
59 xl = xlf->Generate(ServerInstance->Time(), atoi(params[4].c_str()), params[2], params[5], params[1]);
61 catch (ModuleException &e)
63 ServerInstance->SNO->WriteToSnoMask('d',"Unable to ADDLINE type %s from %s: %s", params[0].c_str(), setter.c_str(), e.GetReason());
66 xl->SetCreateTime(atoi(params[3].c_str()));
67 if (ServerInstance->XLines->AddLine(xl, NULL))
71 ServerInstance->SNO->WriteToSnoMask('X',"%s added %s%s on %s to expire on %s: %s",setter.c_str(),params[0].c_str(),params[0].length() == 1 ? "-line" : "",
72 params[1].c_str(),ServerInstance->TimeString(xl->expiry).c_str(),params[5].c_str());
76 ServerInstance->SNO->WriteToSnoMask('X',"%s added permanent %s%s on %s: %s",setter.c_str(),params[0].c_str(),params[0].length() == 1 ? "-line" : "",
77 params[1].c_str(),params[5].c_str());
79 params[5] = ":" + params[5];
81 User* u = ServerInstance->FindNick(prefix);
82 Utils->DoOneToAllButSender(prefix, "ADDLINE", params, u ? u->server : prefix);
83 TreeServer *remoteserver = Utils->FindServer(u ? u->server : prefix);
85 if (!remoteserver->bursting)
87 ServerInstance->XLines->ApplyLines();