diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-05 22:17:23 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-05 22:17:23 +0000 |
commit | 37c77c74a0c18d7c2ea57650d1f518697db75a8a (patch) | |
tree | c6c485da9a1d8cd239495ef6a09b8fc2c3b31e9a /src/modules | |
parent | aec772bdc98bdcfe35c2fc8e74942403c9efcc4d (diff) |
Add support for <link:hidden> 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
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree/link.h | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 21 |
6 files changed, 37 insertions, 20 deletions
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<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> ¶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())) { |