]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Whoops, stuff in the wrong place
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index 7f854809bc326e5ed1b8774ca9a7441a75366e66..e2543c05eabb7a66d43077e199b2c2831fec7e65 100644 (file)
@@ -3402,6 +3402,18 @@ class TreeSocket : public InspSocket
                                        }
                                        return true;
                                }
+                               else if (command == "OPERNOTICE")
+                               {
+                                       std::string sourceserv = this->myhost;
+
+                                       if (this->InboundServerName != "")
+                                               sourceserv = this->InboundServerName;
+
+                                       if (params.size() >= 1)
+                                               Instance->WriteOpers("*** From " + sourceserv + ": " + params[1]);
+
+                                       return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
+                               }
                                else if (command == "ENDBURST")
                                {
                                        this->bursting = false;
@@ -3429,6 +3441,25 @@ class TreeSocket : public InspSocket
                                        {
                                                sourceserv = this->InboundServerName;
                                        }
+                                       if ((!who) && (command == "MODE"))
+                                       {
+                                               if (Utils->IsServer(prefix))
+                                               {
+                                                       const char* modelist[127];
+                                                       for (size_t i = 0; i < params.size(); i++)
+                                                               modelist[i] = params[i].c_str();
+
+                                                       userrec* fake = new userrec(Instance);
+                                                       fake->SetFd(FD_MAGIC_NUMBER);
+
+                                                       this->Instance->SendMode(modelist, params.size(), fake);
+       
+                                                       delete fake;
+
+                                                       /* Hot potato! pass it on! */
+                                                       return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
+                                               }
+                                       }
                                        if (who)
                                        {
                                                if ((command == "NICK") && (params.size() > 0))
@@ -3874,67 +3905,27 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
                        std::string Port = Conf->ReadValue("bind","port",j);
                        if (Type == "servers")
                        {
-                               irc::commasepstream portrange(Port);
-                               std::string portno = "*";
-                               while ((portno = portrange.GetToken()) != "")
+                               irc::portparser portrange(Port, false);
+                               int portno = -1;
+                               while ((portno = portrange.GetToken()))
                                {
-                                       std::string::size_type dash = portno.rfind('-');
-                                       if (dash != std::string::npos)
-                                       {
-                                               std::string sbegin = portno.substr(0, dash);
-                                               std::string send = portno.substr(dash+1, portno.length());
-                                               long begin = atoi(sbegin.c_str());
-                                               long end = atoi(send.c_str());
+                                       ServerInstance->Log(DEBUG,"m_spanningtree: Binding server port %s:%d", IP.c_str(), portno);
+                                       if (IP == "*")
+                                               IP = "";
 
-                                               if ((begin < 0) || (end < 0) || (begin > 65535) || (end > 65535) || (begin >= end))
-                                               {
-                                                       ServerInstance->Log(DEFAULT,"WARNING: Port range \"%d-%d\" discarded. begin >= end, or begin/end out of range.", begin, end);
-                                               }
-                                               else
-                                               {
-                                                       for (long port = begin; port <= end; ++port)
-                                                       {
-                                                               ServerInstance->Log(DEBUG,"m_spanningtree: Binding server port %s:%d (part of range %s)", IP.c_str(), port, portno.c_str());
-                                                               if (IP == "*")
-                                                                       IP = "";
-
-                                                               TreeSocket* listener = new TreeSocket(this, ServerInstance, IP.c_str(), port, true, 10);
-                                                               if (listener->GetState() == I_LISTENING)
-                                                               {
-                                                                       ServerInstance->Log(DEFAULT,"m_spanningtree: Binding server port %s:%d successful!", IP.c_str(), port);
-                                                                       Bindings.push_back(listener);
-                                                               }
-                                                               else
-                                                               {
-                                                                       ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port %s:%d (forms part of range '%s')",IP.c_str(),
-                                                                                       port, portno.c_str());
-                                                                       listener->Close();
-                                                                       DELETE(listener);
-                                                               }
-                                                               ServerInstance->Log(DEBUG,"Done with this binding");
-                                                       }
-                                               }
+                                       TreeSocket* listener = new TreeSocket(this, ServerInstance, IP.c_str(), portno, true, 10);
+                                       if (listener->GetState() == I_LISTENING)
+                                       {
+                                               ServerInstance->Log(DEFAULT,"m_spanningtree: Binding server port %s:%d successful!", IP.c_str(), portno);
+                                               Bindings.push_back(listener);
                                        }
                                        else
                                        {
-                                               ServerInstance->Log(DEBUG,"m_spanningtree: Binding server port %s:%s (single port %s)", IP.c_str(), portno.c_str(), portno.c_str());
-                                               if (IP == "*")
-                                                       IP = "";
-
-                                               TreeSocket* listener = new TreeSocket(this, ServerInstance, IP.c_str(),atoi(portno.c_str()),true,10);
-                                               if (listener->GetState() == I_LISTENING)
-                                               {
-                                                       ServerInstance->Log(DEFAULT,"m_spanningtree: Binding server port %s:%s successful!", IP.c_str(), portno.c_str());
-                                                       Bindings.push_back(listener);
-                                               }
-                                               else
-                                               {
-                                                       ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port %s:%s",IP.c_str(), portno.c_str());
-                                                       listener->Close();
-                                                       DELETE(listener);
-                                               }
-                                               ServerInstance->Log(DEBUG,"Done with this binding");
+                                               ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port %s:%d",IP.c_str(), portno);
+                                               listener->Close();
+                                               DELETE(listener);
                                        }
+                                       ServerInstance->Log(DEBUG,"Done with this binding");
                                }
                        }
                }
@@ -4980,7 +4971,8 @@ class ModuleSpanningTree : public Module
                {
                        /* Server-set lines */
                        char data[MAXBUF];
-                       snprintf(data,MAXBUF,"%c %s %s %lu %lu :%s", linetype, host.c_str(), ServerInstance->Config->ServerName, ServerInstance->Time(false), duration, reason.c_str());
+                       snprintf(data,MAXBUF,"%c %s %s %lu %lu :%s", linetype, host.c_str(), ServerInstance->Config->ServerName, (unsigned long)ServerInstance->Time(false),
+                                       (unsigned long)duration, reason.c_str());
                        std::deque<std::string> params;
                        params.push_back(data);
                        Utils->DoOneToMany(ServerInstance->Config->ServerName, "ADDLINE", params);
@@ -5177,6 +5169,19 @@ class ModuleSpanningTree : public Module
                        params->insert(params->begin() + 1,ConvToStr(ourTS));
                        Utils->DoOneToMany(ServerInstance->Config->ServerName,"FMODE",*params);
                }
+               else if (event->GetEventID() == "send_mode_explicit")
+               {
+                       if (params->size() < 2)
+                               return;
+                       Utils->DoOneToMany(ServerInstance->Config->ServerName,"MODE",*params);
+               }
+               else if (event->GetEventID() == "send_opers")
+               {
+                       if (params->size() < 1)
+                               return;
+                       (*params)[0] = ":" + (*params)[0];
+                       Utils->DoOneToMany(ServerInstance->Config->ServerName,"OPERNOTICE",*params);
+               }
                else if (event->GetEventID() == "send_push")
                {
                        if (params->size() < 2)