summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-06 12:59:54 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-06 12:59:54 +0000
commitf905e65cd98cc45d52e74f2b17f32a791db93765 (patch)
tree40b386a0c2c0128a8ddc3d19fcec52b00dc15f0f /src
parent9c701f3098f6d69abf20bd2e795d2812382f1e57 (diff)
Added ADDLINE
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2217 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/commands.cpp1
-rw-r--r--src/modules/m_spanningtree.cpp79
2 files changed, 75 insertions, 5 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 1fa29bf8d..38880a586 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1922,7 +1922,6 @@ void handle_eline(char **parameters, int pcnt, userrec *user)
void handle_gline(char **parameters, int pcnt, userrec *user)
{
- char netdata[MAXBUF];
if (pcnt >= 3)
{
add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index c2526c2b0..d8289d25a 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -37,6 +37,7 @@ using namespace std;
#include "inspstring.h"
#include "hashcomp.h"
#include "message.h"
+#include "xline.h"
#ifdef GCC3
#define nspace __gnu_cxx
@@ -790,6 +791,32 @@ class TreeSocket : public InspSocket
}
}
+ void SendXLines(TreeServer* Current)
+ {
+ char data[MAXBUF];
+ // for zlines and qlines, we should first check if theyre global...
+ for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
+ {
+ snprintf(data,MAXBUF,":%s ADDLINE Z %s %s %lu %lu :%s",Srv->GetServerName().c_str(),i->ipaddr,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason);
+ this->WriteLine(data);
+ }
+ for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
+ {
+ snprintf(data,MAXBUF,":%s ADDLINE Q %s %s %lu %lu :%s",Srv->GetServerName().c_str(),i->nick,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason);
+ this->WriteLine(data);
+ }
+ for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
+ {
+ snprintf(data,MAXBUF,":%s ADDLINE G %s %s %lu %lu :%s",Srv->GetServerName().c_str(),i->hostmask,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason);
+ this->WriteLine(data);
+ }
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ {
+ snprintf(data,MAXBUF,":%s ADDLINE E %s %s %lu %lu :%s",Srv->GetServerName().c_str(),i->hostmask,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason);
+ this->WriteLine(data);
+ }
+ }
+
void SendChannelModes(TreeServer* Current)
{
char data[MAXBUF];
@@ -848,6 +875,7 @@ class TreeSocket : public InspSocket
this->SendUsers(s);
// Send everything else (channel modes etc)
this->SendChannelModes(s);
+ this->SendXLines(s);
this->WriteLine("ENDBURST");
}
@@ -992,6 +1020,45 @@ class TreeSocket : public InspSocket
return true;
}
+ bool AddLine(std::string prefix, std::deque<std::string> params)
+ {
+ if (params.size() < 6)
+ return true;
+ std::string linetype = params[0]; /* Z, Q, E, G, K */
+ std::string mask = params[1]; /* Line type dependent */
+ std::string source = params[2]; /* may not be online or may be a server */
+ std::string settime = params[3]; /* EPOCH time set */
+ std::string duration = params[4]; /* Duration secs */
+ std::string reason = params[5];
+
+ switch (*(linetype.c_str()))
+ {
+ case 'Z':
+ add_zline(atoi(duration), source.c_str(), reason.c_str(), mask.c_str());
+ break;
+ case 'Q':
+ add_qline(atoi(duration), source.c_str(), reason.c_str(), mask.c_str());
+ break;
+ case 'E':
+ add_eline(atoi(duration), source.c_str(), reason.c_str(), mask.c_str());
+ break;
+ case 'G':
+ add_gline(atoi(duration), source.c_str(), reason.c_str(), mask.c_str());
+ break;
+ case 'K':
+ add_kline(atoi(duration), source.c_str(), reason.c_str(), mask.c_str());
+ break;
+ default:
+ /* Just in case... */
+ Srv->SendOpers("*** \2WARNING\2: Invalid xline type '"+linetype+"' sent by server "+prefix+", ignored!")
+ break;
+ }
+ /* Send it on its way */
+ params[5] = ":" + params[5];
+ DoOneToAllButSender(prefix,"ADDLINE",params,prefix);
+ return true;
+ }
+
bool ChangeName(std::string prefix, std::deque<std::string> params)
{
if (params.size() < 1)
@@ -1330,6 +1397,10 @@ class TreeSocket : public InspSocket
{
return this->ChangeName(prefix,params);
}
+ else if (command == "ADDLINE")
+ {
+ return this->AddLine(prefix,params);
+ }
else if (command == "SQUIT")
{
if (params.size() == 2)
@@ -2256,22 +2327,22 @@ class ModuleSpanningTree : public Module
virtual void OnDelGLine(userrec* source, std::string hostmask)
{
- OnLine(source,hostmask,false,'G',"","");
+ OnLine(source,hostmask,false,'G',0,"");
}
virtual void OnDelZLine(userrec* source, std::string ipmask)
{
- OnLine(source,ipmask,false,'Z',"","");
+ OnLine(source,ipmask,false,'Z',0,"");
}
virtual void OnDelQLine(userrec* source, std::string nickmask)
{
- OnLine(source,nickmask,false,'Q',"","");
+ OnLine(source,nickmask,false,'Q',0,"");
}
virtual void OnDelELine(userrec* source, std::string hostmask)
{
- OnLine(source,hostmask,false,'E',"","");
+ OnLine(source,hostmask,false,'E',0,"");
}
virtual void OnMode(userrec* user, void* dest, int target_type, std::string text)