From 5dbcb7a99eb4d837973524b28bb4f894ce3398ab Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 10 Jan 2020 01:38:41 +0000 Subject: [PATCH] add config option GatekeeperURIAlias to list other FQDN or ips of same local grid --- .../Grid/RemoteGridServiceConnector.cs | 22 +++++++++++++++++-- .../Services/GridService/HypergridLinker.cs | 22 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index d31c7adfee..faeb7fb6af 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 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; @@ -134,6 +135,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 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].ToLower()); + } + } return true; } @@ -255,7 +269,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string regionHost = ""; if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) return rinfo; // invalid - if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) && !m_ThisGatekeeperIP.Equals(regionHost)) + if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) + && !m_ThisGatekeeperIP.Equals(regionHost) + && !m_ThisGateKeeperAlias.Contains(regionHost.ToLower())) return rinfo; // not local grid } @@ -291,7 +307,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string regionHost = ""; if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName)) return rinfo; // invalid - if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) && !m_ThisGatekeeperIP.Equals(regionHost)) + if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) + && !m_ThisGatekeeperIP.Equals(regionHost) + && !m_ThisGateKeeperAlias.Contains(regionHost.ToLower())) return rinfo; // not local grid } diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 9c66e3dfac..ae419f9db6 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -68,6 +68,7 @@ namespace OpenSim.Services.GridService 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) { @@ -107,6 +108,19 @@ namespace OpenSim.Services.GridService 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].ToLower()); + } + } + m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); @@ -167,7 +181,9 @@ namespace OpenSim.Services.GridService return true; if(m_ThisGatekeeperHost.Equals(UriHost, StringComparison.InvariantCultureIgnoreCase)) return true; - return m_ThisGateKeeperIP.Equals(UriHost); + if (m_ThisGateKeeperIP.Equals(UriHost)) + return true; + return m_ThisGateKeeperAlias.Contains(UriHost.ToLower()); } public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) @@ -248,7 +264,9 @@ namespace OpenSim.Services.GridService // 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)) + 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";