From 80c42b2f461c661a378b1eed0350b0fdbdd19889 Mon Sep 17 00:00:00 2001 From: w00t Date: Tue, 8 Apr 2008 19:23:18 +0000 Subject: [PATCH] Changes needed to get open-linking working. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9431 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/treesocket2.cpp | 7 +++- src/modules/m_spanningtree/utils.cpp | 39 +++++++++++++--------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 476b7900e..3d4f70c5e 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -691,8 +691,13 @@ int TreeSocket::OnIncomingConnection(int newsock, char* ip) if (!found) { for (std::vector::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++) - if (irc::sockets::MatchCIDR(ip, (*i).c_str())) + { + if ((*i) == "*" || irc::sockets::MatchCIDR(ip, (*i).c_str())) + { found = true; + break; + } + } if (!found) { diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index bc295766f..e6827d524 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -484,19 +484,19 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) /* Bugfix by brain, do not allow people to enter bad configurations */ if (L.Name != ServerInstance->Config->ServerName) { - if ((!L.IPAddr.empty()) && (!L.RecvPass.empty()) && (!L.SendPass.empty()) && (!L.Name.empty()) && (L.Port)) - { - if (L.Name.find('.') == std::string::npos) - throw CoreException("The link name '"+assign(L.Name)+"' is invalid and must contain at least one '.' character"); + if (L.Name.find('.') == std::string::npos) + throw CoreException("The link name '"+assign(L.Name)+"' is invalid and must contain at least one '.' character"); - if (L.Name.length() > 64) - throw CoreException("The link name '"+assign(L.Name)+"' is longer than 64 characters!"); - - ValidIPs.push_back(L.IPAddr); + if (L.Name.length() > 64) + throw CoreException("The link name '"+assign(L.Name)+"' is longer than 64 characters!"); + if ((!L.IPAddr.empty()) && (!L.RecvPass.empty()) && (!L.SendPass.empty()) && (!L.Name.empty()) && (L.Port)) + { if (Allow.length()) ValidIPs.push_back(Allow); + ValidIPs.push_back(L.IPAddr); + /* Needs resolving */ bool ipvalid = true; QueryType start_type = DNS_QUERY_A; @@ -532,32 +532,39 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) { } } - - LinkBlocks.push_back(L); } else { if (L.IPAddr.empty()) { - throw CoreException("Invalid configuration for server '"+assign(L.Name)+"', IP address not defined!"); + L.IPAddr = "*"; + ValidIPs.push_back("*"); + ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Configuration warning: Link block " + assign(L.Name) + " has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want."); } - else if (L.RecvPass.empty()) + + if (L.RecvPass.empty()) { throw CoreException("Invalid configuration for server '"+assign(L.Name)+"', recvpass not defined!"); } - else if (L.SendPass.empty()) + + if (L.SendPass.empty()) { throw CoreException("Invalid configuration for server '"+assign(L.Name)+"', sendpass not defined!"); } - else if (L.Name.empty()) + + if (L.Name.empty()) { throw CoreException("Invalid configuration, link tag without a name! IP address: "+L.IPAddr); } - else if (!L.Port) + + if (!L.Port) { - throw CoreException("Invalid configuration for server '"+assign(L.Name)+"', no port specified!"); + ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Configuration warning: Link block " + assign(L.Name) + " has no port defined, you will not be able to /connect it."); } } + + + LinkBlocks.push_back(L); } else { -- 2.39.5