From 9b9f93c4b2f65e85129e50587a2ee63dd1d4f374 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Dec 2016 20:31:07 +0000 Subject: [PATCH] and yes HG uri again --- OpenSim/Framework/Util.cs | 20 ++++++++++++ .../Grid/RemoteGridServiceConnector.cs | 32 +++++++++++++++---- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 5d8a5e0142..b6225232db 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -414,6 +414,26 @@ namespace OpenSim.Framework return regionCoord << 8; } + public static bool checkServiceURI(string uristr, out string serviceURI) + { + serviceURI = string.Empty; + try + { + Uri uri = new Uri(uristr); + serviceURI = uri.AbsoluteUri; + if(uri.Port == 80) + serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":80/"; + else if(uri.Port == 443) + serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":443/"; + return true; + } + catch + { + serviceURI = string.Empty; + } + return false; + } + public static bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) { serverURI = string.Empty; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index f9ce5e1091..50e4c8a5ed 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid MethodBase.GetCurrentMethod().DeclaringType); private bool m_Enabled = false; + private string m_ThisGatekeeper = string.Empty; private IGridService m_LocalGridService; private IGridService m_RemoteGridService; @@ -118,13 +119,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_LocalGridService = new LocalGridServicesConnector(source, m_RegionInfoCache); if (m_LocalGridService == null) { - m_log.Error("[REMOTE GRID CONNECTOR]: failed to loar local connector"); + m_log.Error("[REMOTE GRID CONNECTOR]: failed to load local connector"); return false; } if(m_RegionInfoCache == null) m_RegionInfoCache = new RegionInfoCache(); + m_ThisGatekeeper = Util.GetConfigVarFromSections(source, "GatekeeperURI", + new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); + // Legacy. Remove soon! + m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); + + Util.checkServiceURI(m_ThisGatekeeper, out m_ThisGatekeeper); + return true; } @@ -233,13 +241,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (rinfo != null) return rinfo; - // HG urls should not get here, strip them + // HG urls should not get here, strip them + // side effect is that local regions with same name as HG may also be found + // this mb good or bad string regionName = name; if(name.Contains(".")) { + if(string.IsNullOrWhiteSpace(m_ThisGatekeeper)) + return rinfo; // no HG + string regionURI = ""; - if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) - return rinfo; + if(!Util.buildHGRegionURI(name, out regionURI, out regionName) || string.IsNullOrWhiteSpace(regionName)) + return rinfo; // invalid + if(m_ThisGatekeeper != regionURI) + return rinfo; // not local grid } rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); @@ -258,9 +273,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string regionName = name; if(name.Contains(".")) { + if(string.IsNullOrWhiteSpace(m_ThisGatekeeper)) + return rinfo; // no HG + string regionURI = ""; - if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) - return rinfo; + if(!Util.buildHGRegionURI(name, out regionURI, out regionName) || string.IsNullOrWhiteSpace(regionName)) + return rinfo; // invalid + if(m_ThisGatekeeper != regionURI) + return rinfo; // not local grid } List grinfo = m_RemoteGridService.GetRegionsByName(scopeID, regionName, maxNumber);