addline.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "inspircd.h"
00015 #include "xline.h"
00016
00017 #include "m_spanningtree/treesocket.h"
00018 #include "m_spanningtree/treeserver.h"
00019 #include "m_spanningtree/utils.h"
00020
00021
00022
00023 bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> ¶ms)
00024 {
00025 if (params.size() < 6)
00026 {
00027 this->Instance->SNO->WriteToSnoMask('x',"%s sent me a malformed ADDLINE of type %s.",prefix.c_str(),params[0].c_str());
00028 return true;
00029 }
00030
00031 XLineFactory* xlf = Instance->XLines->GetFactory(params[0]);
00032
00033 std::string setter = "<unknown>";
00034 User* usr = Instance->FindNick(prefix);
00035 if (usr)
00036 setter = usr->nick;
00037 else
00038 {
00039 TreeServer* t = Utils->FindServer(prefix);
00040 if (t)
00041 setter = t->GetName().c_str();
00042 }
00043
00044 if (!xlf)
00045 {
00046 this->Instance->SNO->WriteToSnoMask('x',"%s sent me an unknown ADDLINE type (%s).",setter.c_str(),params[0].c_str());
00047 return true;
00048 }
00049
00050 XLine* xl = xlf->Generate(Instance->Time(), atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
00051 xl->SetCreateTime(atoi(params[3].c_str()));
00052 if (Instance->XLines->AddLine(xl,NULL))
00053 {
00054 if (xl->duration)
00055 {
00056 this->Instance->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" : "",
00057 params[1].c_str(),Instance->TimeString(xl->expiry).c_str(),params[5].c_str());
00058 }
00059 else
00060 {
00061 this->Instance->SNO->WriteToSnoMask('x',"%s added permanent %s%s on %s (%s).",setter.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
00062 params[1].c_str(),params[5].c_str());
00063 }
00064 params[5] = ":" + params[5];
00065
00066 User* u = Instance->FindNick(prefix);
00067 Utils->DoOneToAllButSender(prefix, "ADDLINE", params, u ? u->server : prefix);
00068 TreeServer *remoteserver = Utils->FindServer(u ? u->server : prefix);
00069
00070 if (!remoteserver->bursting)
00071 {
00072 Instance->XLines->ApplyLines();
00073 }
00074 }
00075 else
00076 delete xl;
00077
00078 return true;
00079 }
00080