diff --git a/OpenSim/Framework/GridInfo.cs b/OpenSim/Framework/GridInfo.cs index 5af26d95bc..689a6880ab 100644 --- a/OpenSim/Framework/GridInfo.cs +++ b/OpenSim/Framework/GridInfo.cs @@ -192,6 +192,12 @@ namespace OpenSim.Framework gatekeeper = serverConfig.GetString("ExternalName", string.Empty); } if (string.IsNullOrEmpty(gatekeeper)) + { + IConfig gridConfig = config.Configs["GridService"]; + if (gridConfig != null) + gatekeeper = gridConfig.GetString("Gatekeeper", string.Empty); + } + if (string.IsNullOrEmpty(gatekeeper)) { if(!string.IsNullOrEmpty(defaultHost)) m_gateKeeperURL = new OSHostURL(defaultHost, true); diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index db4232e700..99c3405355 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -475,10 +475,9 @@ namespace OpenSim.Framework return false; } - public static bool buildHGRegionURI(string inputName, out string serverURI, out string serverHost, out string regionName) + public static bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) { serverURI = string.Empty; - serverHost = string.Empty; regionName = string.Empty; inputName = inputName.Trim(); @@ -587,10 +586,10 @@ namespace OpenSim.Framework serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/"; else if(uri.Port == 443) serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/"; - serverHost = uri.Host; return true; } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public static T Clamp(T x, T min, T max) where T : IComparable { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index f59e656764..ee81193631 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -52,10 +52,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid MethodBase.GetCurrentMethod().DeclaringType); private bool m_Enabled = false; - private string m_ThisGatekeeperURI = string.Empty; - private string m_ThisGatekeeperHost = string.Empty; - private string m_ThisGatekeeperIP = string.Empty; - private HashSet m_ThisGateKeeperAlias = new HashSet(); + private GridInfo m_ThisGridInfo; + //private string m_ThisGatekeeperURI = string.Empty; + //private string m_ThisGatekeeperHost = string.Empty; + //private string m_ThisGatekeeperIP = string.Empty; + //private HashSet m_ThisGateKeeperAlias = new HashSet(); private IGridService m_LocalGridService; private IGridService m_RemoteGridService; @@ -129,25 +130,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if(m_RegionInfoCache == null) m_RegionInfoCache = new RegionInfoCache(); - m_ThisGatekeeperURI = Util.GetConfigVarFromSections(source, "GatekeeperURI", - new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); - // Legacy. Remove soon! - m_ThisGatekeeperURI = gridConfig.GetString("Gatekeeper", m_ThisGatekeeperURI); - - Util.checkServiceURI(m_ThisGatekeeperURI, out m_ThisGatekeeperURI, out m_ThisGatekeeperHost, out m_ThisGatekeeperIP); - - string gatekeeperURIAlias = Util.GetConfigVarFromSections(source, "GatekeeperURIAlias", - new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); - - if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias)) - { - string[] alias = gatekeeperURIAlias.Split(','); - for (int i = 0; i < alias.Length; ++i) - { - if (!string.IsNullOrWhiteSpace(alias[i])) - m_ThisGateKeeperAlias.Add(alias[i].Trim().ToLower()); - } - } return true; } @@ -159,6 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void Close() { + m_ThisGridInfo = null; } public void AddRegion(Scene scene) @@ -166,6 +149,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_Enabled) { scene.RegisterModuleInterface(this); + if(m_ThisGridInfo == null) + m_ThisGridInfo = scene.SceneGridInfo; ((ISharedRegionModule)m_LocalGridService).AddRegion(scene); } } @@ -273,16 +258,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string regionName = name; if(name.Contains(".")) { - if(string.IsNullOrWhiteSpace(m_ThisGatekeeperIP)) + if(string.IsNullOrWhiteSpace(m_ThisGridInfo.GateKeeperURL)) return rinfo; // no HG string regionURI = ""; - string regionHost = ""; - if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) + if (!Util.buildHGRegionURI(name, out regionURI, out regionName)) return rinfo; // invalid - if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) - && !m_ThisGatekeeperIP.Equals(regionHost) - && !m_ThisGateKeeperAlias.Contains(regionHost.ToLower())) + if (m_ThisGridInfo.IsLocalGrid(regionURI) != 1) return rinfo; // not local grid } @@ -311,16 +293,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string regionName = name; if(name.Contains(".")) { - if(string.IsNullOrWhiteSpace(m_ThisGatekeeperURI)) + if(string.IsNullOrWhiteSpace(m_ThisGridInfo.GateKeeperURL)) return rinfo; // no HG string regionURI = ""; - string regionHost = ""; - if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) + if (!Util.buildHGRegionURI(name, out regionURI, out regionName)) return rinfo; // invalid - if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) - && !m_ThisGatekeeperIP.Equals(regionHost) - && !m_ThisGateKeeperAlias.Contains(regionHost.ToLower())) + if (m_ThisGridInfo.IsLocalGrid(regionURI) != 1) return rinfo; // not local grid } diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 5b39491b1b..c7be76ac8d 100755 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -509,9 +509,8 @@ namespace OpenSim.Services.GridService if (m_AllowHypergridMapSearch && name.Contains(".")) { string regionURI = ""; - string regionHost = ""; string regionName = ""; - if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) + if (!Util.buildHGRegionURI(name, out regionURI, out regionName)) return null; string mapname; @@ -616,12 +615,11 @@ namespace OpenSim.Services.GridService { string regionURI = ""; string regionName = ""; - string regionHost = ""; - if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) + if (!Util.buildHGRegionURI(name, out regionURI, out regionName)) return null; string mapname; - bool localGrid = m_HypergridLinker.IsLocalGrid(regionHost); + bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI); if (localGrid) { if (String.IsNullOrWhiteSpace(regionName)) diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index c7082749fc..19585de1d9 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -67,10 +67,6 @@ namespace OpenSim.Services.GridService protected string m_MapTileDirectory = string.Empty; protected GridInfo m_ThisGridInfo; - //protected string m_ThisGatekeeperURI = string.Empty; - //protected string m_ThisGatekeeperHost = string.Empty; - //protected string m_ThisGateKeeperIP = string.Empty; - //protected HashSet m_ThisGateKeeperAlias = new HashSet(); public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db) { @@ -100,31 +96,6 @@ namespace OpenSim.Services.GridService m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles"); - /* - m_ThisGatekeeperURI = Util.GetConfigVarFromSections(config, "GatekeeperURI", - new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); - m_ThisGatekeeperURI = gridConfig.GetString("Gatekeeper", m_ThisGatekeeperURI); - - if(!Util.checkServiceURI(m_ThisGatekeeperURI, out m_ThisGatekeeperURI, out m_ThisGatekeeperHost, out m_ThisGateKeeperIP)) - { - m_log.ErrorFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeperURI); - throw new Exception("Failed to resolve gatekeeper external IP, please check GatekeeperURI configuration"); - } - - string gatekeeperURIAlias = Util.GetConfigVarFromSections(config, "GatekeeperURIAlias", - new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); - - if(!string.IsNullOrWhiteSpace(gatekeeperURIAlias)) - { - string[] alias = gatekeeperURIAlias.Split(','); - for(int i = 0; i < alias.Length; ++i) - { - if(!string.IsNullOrWhiteSpace(alias[i])) - m_ThisGateKeeperAlias.Add(alias[i].Trim().ToLower()); - } - } - */ - m_ThisGridInfo = new GridInfo(config); m_log.DebugFormat("[HYPERGRID LINKER]: Local Gatekeeper: {0}", m_ThisGridInfo.GateKeeperURL); @@ -193,10 +164,9 @@ namespace OpenSim.Services.GridService GridRegion regInfo = null; string serverURI = string.Empty; - string regionHost = string.Empty; string regionName = string.Empty; - if (!Util.buildHGRegionURI(mapName, out serverURI, out regionHost, out regionName)) + if (!Util.buildHGRegionURI(mapName, out serverURI, out regionName)) { reason = "Wrong URI format for link-region"; return null; @@ -262,21 +232,6 @@ namespace OpenSim.Services.GridService regInfo.ScopeID = scopeID; regInfo.EstateOwner = ownerID; - // Make sure we're not hyperlinking to regions on this grid! - /* - if (!String.IsNullOrWhiteSpace(m_ThisGateKeeperIP)) - { - if (m_ThisGatekeeperHost.Equals(regInfo.ExternalHostName, StringComparison.InvariantCultureIgnoreCase) - || m_ThisGateKeeperIP.Equals(regInfo.ExternalHostName) - || m_ThisGateKeeperAlias.Contains(regInfo.ExternalHostName.ToLower())) - { - m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid"); - reason = "Cannot hyperlink to regions on the same grid"; - return false; - } - } - */ - if(IsLocalGrid(regInfo.ServerURI)) { m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");