summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xline.h8
-rw-r--r--src/modules/m_spanningtree/main.cpp12
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp38
-rw-r--r--src/xline.cpp22
4 files changed, 54 insertions, 26 deletions
diff --git a/include/xline.h b/include/xline.h
index 990934c56..32ae04d5a 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -415,6 +415,14 @@ class CoreExport XLineManager
*/
void CheckELines();
+ /** Get all lines of a certain type to an XLineLookup (std::map<std::string, XLine*>)
+ */
+ XLineLookup* GetAll(const std::string &type);
+
+ /** Return all known types of line currently stored by the XLineManager
+ */
+ std::vector<std::string> GetAllTypes();
+
/** Add a new GLine
* @param line The line to be added
* @param user The user adding the line or NULL for the local server
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 87206ea2a..2e743689c 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -742,7 +742,7 @@ void ModuleSpanningTree::OnAddLine(XLine* line, User* user)
{
/* Server-set lines */
char data[MAXBUF];
- snprintf(data,MAXBUF,"%c %s %s %lu %lu :%s", line->type, line->Displayable(), ServerInstance->Config->ServerName, line->set_time,
+ snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", line->type.c_str(), line->Displayable(), ServerInstance->Config->ServerName, line->set_time,
line->duration, line->reason);
std::deque<std::string> params;
params.push_back(data);
@@ -750,10 +750,13 @@ void ModuleSpanningTree::OnAddLine(XLine* line, User* user)
}
else
{
+ /** XXX: This is WRONG and needs fixing.
+ * We need to implement a DELLINE
+ */
if (user && IS_LOCAL(user))
{
char type[8];
- snprintf(type,8,"%cLINE",line->type);
+ snprintf(type,8,"%sLINE",line->type.c_str());
std::string stype(type);
char sduration[MAXBUF];
snprintf(sduration,MAXBUF,"%ld",line->duration);
@@ -770,8 +773,11 @@ void ModuleSpanningTree::OnDelLine(XLine* line, User* user)
{
if (user && IS_LOCAL(user))
{
+ /** XXX: This is WRONG and needs fixing.
+ * We need to implement a DELLINE
+ */
char type[8];
- snprintf(type,8,"%cLINE",line->type);
+ snprintf(type,8,"%sLINE",line->type.c_str());
std::string stype(type);
std::deque<std::string> params;
params.push_back(line->Displayable());
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 84964833f..18ae9b6cd 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -1217,31 +1217,27 @@ void TreeSocket::SendXLines(TreeServer* Current)
std::string buffer;
std::string n = this->Instance->Config->GetSID();
const char* sn = n.c_str();
- /* Yes, these arent too nice looking, but they get the job done */
- /* FIXME: FOR THE LOVE OF ZOMBIE JESUS, FIX ME */
+ std::vector<std::string> types = Instance->XLines->GetAllTypes();
-/* for (std::vector<ZLine*>::iterator i = Instance->XLines->zlines.begin(); i != Instance->XLines->zlines.end(); i++)
+ for (std::vector<std::string>::iterator it = types.begin(); it != types.end(); ++it)
{
- snprintf(data,MAXBUF,":%s ADDLINE Z %s %s %lu %lu :%s\r\n",sn,(*i)->ipaddr,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
- }
- for (std::vector<QLine*>::iterator i = Instance->XLines->qlines.begin(); i != Instance->XLines->qlines.end(); i++)
- {
- snprintf(data,MAXBUF,":%s ADDLINE Q %s %s %lu %lu :%s\r\n",sn,(*i)->nick,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
- }
- for (std::vector<GLine*>::iterator i = Instance->XLines->glines.begin(); i != Instance->XLines->glines.end(); i++)
- {
- snprintf(data,MAXBUF,":%s ADDLINE G %s@%s %s %lu %lu :%s\r\n",sn,(*i)->identmask,(*i)->hostmask,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
- }
- for (std::vector<ELine*>::iterator i = Instance->XLines->elines.begin(); i != Instance->XLines->elines.end(); i++)
- {
- snprintf(data,MAXBUF,":%s ADDLINE E %s@%s %s %lu %lu :%s\r\n",sn,(*i)->identmask,(*i)->hostmask,(*i)->source,(unsigned long)(*i)->set_time,(unsigned long)(*i)->duration,(*i)->reason);
- buffer.append(data);
+ XLineLookup* lookup = Instance->XLines->GetAll(*it);
+
+ if (lookup)
+ {
+ for (LookupIter i = lookup->begin(); i != lookup->end(); ++i)
+ {
+ snprintf(data,MAXBUF,":%s ADDLINE %s %s %s %lu %lu :%s\r\n",sn, it->c_str(), i->second->Displayable(),
+ i->second->source,
+ (unsigned long)i->second->set_time,
+ (unsigned long)i->second->duration,
+ i->second->reason);
+ buffer.append(data);
+ }
+ }
}
-*/
+
if (!buffer.empty())
this->WriteLine(buffer);
}
diff --git a/src/xline.cpp b/src/xline.cpp
index b11f9f27c..028067794 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -59,9 +59,9 @@ bool XLine::Matches(User *u)
*/
void XLineManager::CheckELines()
{
- ContainerIter n = ServerInstance->XLines->lookup_lines.find("E");
+ ContainerIter n = lookup_lines.find("E");
- if (n == ServerInstance->XLines->lookup_lines.end())
+ if (n == lookup_lines.end())
return;
XLineLookup& ELines = n->second;
@@ -82,6 +82,24 @@ void XLineManager::CheckELines()
}
+XLineLookup* XLineManager::GetAll(const std::string &type)
+{
+ ContainerIter n = lookup_lines.find(type);
+
+ if (n == lookup_lines.end())
+ return NULL;
+
+ return &(n->second);
+}
+
+std::vector<std::string> XLineManager::GetAllTypes()
+{
+ std::vector<std::string> items;
+ for (ContainerIter x = lookup_lines.begin(); x != lookup_lines.end(); ++x)
+ items.push_back(x->first);
+ return items;
+}
+
IdentHostPair XLineManager::IdentSplit(const std::string &ident_and_host)
{
IdentHostPair n = std::make_pair<std::string,std::string>("*","*");