From: brain Date: Thu, 5 Apr 2007 22:17:23 +0000 (+0000) Subject: Add support for fixes feature request documented in bug #247 reported... X-Git-Tag: v2.0.23~5659 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=37c77c74a0c18d7c2ea57650d1f518697db75a8a;p=user%2Fhenk%2Fcode%2Finspircd.git Add support for fixes feature request documented in bug #247 reported by owine git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6738 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example index 2259858b0..011cc29ab 100644 --- a/docs/inspircd.conf.example +++ b/docs/inspircd.conf.example @@ -479,6 +479,18 @@ # 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 tag as shown # # in the example below. You can have as many of these as you like. # @@ -526,6 +538,7 @@ timeout="15" transport="gnutls" bind="1.2.3.4" + hidden="no" sendpass="outgoing!password" recvpass="incoming!password"> diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h index 9941939eb..5d15e5898 100644 --- a/src/modules/m_spanningtree/link.h +++ b/src/modules/m_spanningtree/link.h @@ -22,6 +22,7 @@ class Link : public classbase std::string Hook; int Timeout; std::string Bind; + bool Hidden; }; #endif diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 673c2cda1..ed2d73efa 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -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) { diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index f53e88395..adcaf9d7d 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -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; diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 1d053112d..381ed928f 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -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(); diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 7d1e3d99b..21f2b2b16 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -791,7 +791,8 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque 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 ¶ms) // 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); diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index c03839a19..03203a97d 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -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())) {