]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add support for <link:hidden> fixes feature request documented in bug #247 reported...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 5 Apr 2007 22:17:23 +0000 (22:17 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 5 Apr 2007 22:17:23 +0000 (22:17 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6738 e03df62e-2008-0410-955e-edbf42e46eb7

docs/inspircd.conf.example
src/modules/m_spanningtree/link.h
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treeserver.h
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/utils.cpp

index 2259858b0742499e4efe4608c96be2ff6dc81ec0..011cc29ab593a0209cb05cc76f9e559d53af38d6 100644 (file)
 #                 looking for the error 'Could not assign requested   #
 #                 address' in your log when connecting to servers.    #
 #                                                                     #
+# hidden        - If this is set to true, yes, or 1, then the server  #
+#                 is completely hidden from non-opers. It does not    #
+#                 show in LINKS and it does not show in MAP. Also,    #
+#                 any servers which are child servers of this one     #
+#                 in the network will *also* be hidden. Use with      #
+#                 care! You can use this to 'mask off' sections of    #
+#                 the network so that users only see a small portion  #
+#                 of a much larger net. It should NOT be relied upon  #
+#                 as a security tool, unless it is being used for     #
+#                 example to hide a non-client hub, for which clients #
+#                 do not have an IP address or resolvable hostname.   #
+#                                                                     #
 # to u:line a server (give it extra privilages required for running   #
 # services, Q, etc) you must include the <uline server> tag as shown  #
 # in the example below. You can have as many of these as you like.    #
       timeout="15"
       transport="gnutls"
       bind="1.2.3.4"
+      hidden="no"
       sendpass="outgoing!password"
       recvpass="incoming!password">
 
index 9941939eb0f54f6b0db0e1c1c7321a7c0e886f92..5d15e58984b09c6cd37357eb9a57e623bc7de937 100644 (file)
@@ -22,6 +22,7 @@ class Link : public classbase
        std::string Hook;
        int Timeout;
        std::string Bind;
+       bool Hidden;
 };
 
 #endif
index 673c2cda1ee0670a5545a9d35990861d03f00560..ed2d73efa217df68a441b4dfa6621fb5119b934e 100644 (file)
@@ -61,7 +61,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, userrec* user, int hops)
        }
        for (unsigned int q = 0; q < Current->ChildCount(); q++)
        {
-               if ((Utils->HideULines) && (ServerInstance->ULine(Current->GetChild(q)->GetName().c_str())))
+               if ((Current->GetChild(q)->Hidden) || ((Utils->HideULines) && (ServerInstance->ULine(Current->GetChild(q)->GetName().c_str()))))
                {
                        if (*user->oper)
                        {
@@ -74,9 +74,16 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, userrec* user, int hops)
                }
        }
        /* Don't display the line if its a uline, hide ulines is on, and the user isnt an oper */
-       if ((Utils->HideULines) && (ServerInstance->ULine(Current->GetName().c_str())) && (!*user->oper))
+       if ((Utils->HideULines) && (ServerInstance->ULine(Current->GetName().c_str())) && (!IS_OPER(user)))
                return;
-       user->WriteServ("364 %s %s %s :%d %s",user->nick,Current->GetName().c_str(),(Utils->FlatLinks && (!*user->oper)) ? ServerInstance->Config->ServerName : Parent.c_str(),(Utils->FlatLinks && (!*user->oper)) ? 0 : hops,Current->GetDesc().c_str());
+       /* Or if the server is hidden and they're not an oper */
+       else if ((Current->Hidden) && (!IS_OPER(user)))
+               return;
+
+       user->WriteServ("364 %s %s %s :%d %s",  user->nick,Current->GetName().c_str(),
+                       (Utils->FlatLinks && (!IS_OPER(user))) ? ServerInstance->Config->ServerName : Parent.c_str(),
+                       (Utils->FlatLinks && (!IS_OPER(user))) ? 0 : hops,
+                       Current->GetDesc().c_str());
 }
 
 int ModuleSpanningTree::CountLocalServs()
@@ -190,7 +197,7 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, userrec* user, int depth,
                line++;
                for (unsigned int q = 0; q < Current->ChildCount(); q++)
                {
-                       if ((Utils->HideULines) && (ServerInstance->ULine(Current->GetChild(q)->GetName().c_str())))
+                       if ((Current->GetChild(q)->Hidden) || ((Utils->HideULines) && (ServerInstance->ULine(Current->GetChild(q)->GetName().c_str()))))
                        {
                                if (*user->oper)
                                {
index f53e88395161be6420ec69584be5ff811d9ba4ec..adcaf9d7d1936fac7ba5c6ee4a6a9bf7791f3660 100644 (file)
@@ -23,6 +23,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance) : Server
        VersionString = "";
        UserCount = OperCount = 0;
        rtt = LastPing = 0;
+       Hidden = false;
        VersionString = ServerInstance->GetVersionString();
 }
 
@@ -40,6 +41,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
        Route = NULL;
        Socket = NULL; /* Fix by brain */
        rtt = LastPing = 0;
+       Hidden = false;
        AddHashEntry();
 }
 
@@ -47,8 +49,8 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
  * This constructor initializes the server's Route and Parent, and sets up
  * its ping counters so that it will be pinged one minute from now.
  */
-TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock)
-       : ServerInstance(Instance), Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util)
+TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock, bool Hide)
+       : ServerInstance(Instance), Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), Hidden(Hide)
 {
        VersionString = "";
        UserCount = OperCount = 0;
index 1d053112db127ba8c30efda0e625d82f089c391c..381ed928f678ed139a5a94ab20a862e35a445fba 100644 (file)
@@ -48,7 +48,7 @@ class TreeServer : public classbase
         * This constructor initializes the server's Route and Parent, and sets up
         * its ping counters so that it will be pinged one minute from now.
         */
-       TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock);
+       TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock, bool Hide);
 
        int QuitUsers(const std::string &reason);
 
@@ -98,6 +98,10 @@ class TreeServer : public classbase
         */
        time_t rtt;
 
+       /** True if this server is hidden
+        */
+       bool Hidden;
+
        /** True if the server answered their last ping
         */
        bool AnsweredLastPing();
index 7d1e3d99b7cb4cf8e6fc84188e7d7407a13f6721..21f2b2b16cd2ee7e60ffe926545494ac49a12795 100644 (file)
@@ -791,7 +791,8 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string>
                this->Instance->SNO->WriteToSnoMask('l',"Server \2"+servername+"\2 being introduced from \2" + prefix + "\2 denied, already exists. Closing link with " + prefix);
                return false;
        }
-       TreeServer* Node = new TreeServer(this->Utils,this->Instance,servername,description,ParentOfThis,NULL);
+       Link* lnk = Utils->FindLink(servername);
+       TreeServer* Node = new TreeServer(this->Utils,this->Instance,servername,description,ParentOfThis,NULL, lnk ? lnk->Hidden : false);
        ParentOfThis->AddChild(Node);
        params[3] = ":" + params[3];
        Utils->DoOneToAllButSender(prefix,"SERVER",params,prefix);
@@ -835,7 +836,7 @@ bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
                        // we should add the details of this server now
                        // to the servers tree, as a child of the root
                        // node.
-                       TreeServer* Node = new TreeServer(this->Utils,this->Instance,sname,description,Utils->TreeRoot,this);
+                       TreeServer* Node = new TreeServer(this->Utils,this->Instance,sname,description,Utils->TreeRoot,this,x->Hidden);
                        Utils->TreeRoot->AddChild(Node);
                        params[3] = ":" + params[3];
                        Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,sname);
@@ -1014,7 +1015,8 @@ bool TreeSocket::ProcessLine(std::string &line)
                                        }
                                }
                                this->LinkState = CONNECTED;
-                               Node = new TreeServer(this->Utils,this->Instance,InboundServerName,InboundDescription,Utils->TreeRoot,this);
+                               Link* lnk = Utils->FindLink(InboundServerName);
+                               Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, Utils->TreeRoot, this, lnk ? lnk->Hidden : false);
                                Utils->TreeRoot->AddChild(Node);
                                params.clear();
                                params.push_back(InboundServerName);
index c03839a1919a30b7a6e58024e0fbb47a19e3692d..03203a97dadb3793ad16b278a7855ae5f741ea28 100644 (file)
@@ -384,18 +384,19 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
        for (int j =0; j < Conf->Enumerate("link"); j++)
        {
                Link L;
-               std::string Allow = Conf->ReadValue("link","allowmask",j);
-               L.Name = (Conf->ReadValue("link","name",j)).c_str();
-               L.IPAddr = Conf->ReadValue("link","ipaddr",j);
-               L.FailOver = Conf->ReadValue("link","failover",j).c_str();
-               L.Port = Conf->ReadInteger("link","port",j,true);
-               L.SendPass = Conf->ReadValue("link","sendpass",j);
-               L.RecvPass = Conf->ReadValue("link","recvpass",j);
-               L.AutoConnect = Conf->ReadInteger("link","autoconnect",j,true);
-               L.HiddenFromStats = Conf->ReadFlag("link","hidden",j);
-               L.Timeout = Conf->ReadInteger("link","timeout",j,true);
+               std::string Allow = Conf->ReadValue("link", "allowmask", j);
+               L.Name = (Conf->ReadValue("link", "name", j)).c_str();
+               L.IPAddr = Conf->ReadValue("link", "ipaddr", j);
+               L.FailOver = Conf->ReadValue("link", "failover", j).c_str();
+               L.Port = Conf->ReadInteger("link", "port", j, true);
+               L.SendPass = Conf->ReadValue("link", "sendpass", j);
+               L.RecvPass = Conf->ReadValue("link", "recvpass", j);
+               L.AutoConnect = Conf->ReadInteger("link", "autoconnect", j, true);
+               L.HiddenFromStats = Conf->ReadFlag("link", "hidden", j);
+               L.Timeout = Conf->ReadInteger("link", "timeout", j, true);
                L.Hook = Conf->ReadValue("link", "transport", j);
                L.Bind = Conf->ReadValue("link", "bind", j);
+               L.Hidden = Conf->ReadFlag("link", "hidden", j);
 
                if ((!L.Hook.empty()) && (hooks.find(L.Hook.c_str()) ==  hooks.end()))
                {