mantis 8580: make some changes on regions find code. (only gatekeeper

host is used on local grid detection, not its port)
0.9.1.0-post-fixes
UbitUmarov 2019-09-02 22:48:06 +01:00
parent 38dbc03288
commit ae130d9f25
3 changed files with 62 additions and 41 deletions

View File

@ -52,7 +52,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
MethodBase.GetCurrentMethod().DeclaringType);
private bool m_Enabled = false;
private string m_ThisGatekeeper = string.Empty;
private string m_ThisGatekeeperURI = string.Empty;
private string m_ThisGatekeeperHost = string.Empty;
private string m_ThisGatekeeperIP = string.Empty;
private IGridService m_LocalGridService;
private IGridService m_RemoteGridService;
@ -126,13 +128,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if(m_RegionInfoCache == null)
m_RegionInfoCache = new RegionInfoCache();
m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(source, "GatekeeperURI",
m_ThisGatekeeperURI = Util.GetConfigVarFromSections<string>(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);
m_ThisGatekeeperURI = gridConfig.GetString("Gatekeeper", m_ThisGatekeeperURI);
Util.checkServiceURI(m_ThisGatekeeperURI, out m_ThisGatekeeperURI, out m_ThisGatekeeperHost, out m_ThisGatekeeperIP);
return true;
}
@ -247,14 +248,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
string regionName = name;
if(name.Contains("."))
{
if(string.IsNullOrWhiteSpace(m_ThisGatekeeper))
if(string.IsNullOrWhiteSpace(m_ThisGatekeeperIP))
return rinfo; // no HG
string regionURI = "";
if(!Util.buildHGRegionURI(name, out regionURI, out regionName) || string.IsNullOrWhiteSpace(regionName))
string regionHost = "";
if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName))
return rinfo; // invalid
if(m_ThisGatekeeper != regionURI)
if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) && !m_ThisGatekeeperIP.Equals(regionHost))
return rinfo; // not local grid
if (String.IsNullOrEmpty(regionName))
return m_RemoteGridService.GetDefaultRegions(scopeID)[0];
}
rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
@ -273,17 +277,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
string regionName = name;
if(name.Contains("."))
{
if(string.IsNullOrWhiteSpace(m_ThisGatekeeper))
if(string.IsNullOrWhiteSpace(m_ThisGatekeeperURI))
return rinfo; // no HG
string regionURI = "";
if(!Util.buildHGRegionURI(name, out regionURI, out regionName) || string.IsNullOrWhiteSpace(regionName))
string regionHost = "";
if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName))
return rinfo; // invalid
if(m_ThisGatekeeper != regionURI)
if (!m_ThisGatekeeperHost.Equals(regionHost, StringComparison.InvariantCultureIgnoreCase) && !m_ThisGatekeeperIP.Equals(regionHost))
return rinfo; // not local grid
}
List<GridRegion> grinfo = m_RemoteGridService.GetRegionsByName(scopeID, regionName, maxNumber);
List<GridRegion> grinfo = null;
if (String.IsNullOrEmpty(regionName))
grinfo = m_RemoteGridService.GetDefaultRegions(scopeID);
else
grinfo = m_RemoteGridService.GetRegionsByName(scopeID, regionName, maxNumber);
if (grinfo != null)
{

View File

@ -502,14 +502,19 @@ namespace OpenSim.Services.GridService
if (count < maxNumber && m_AllowHypergridMapSearch && name.Contains("."))
{
string regionURI = "";
string regionHost = "";
string regionName = "";
if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName))
return null;
string mapname;
bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
bool localGrid = m_HypergridLinker.IsLocalGrid(regionHost);
if (localGrid)
{
if (String.IsNullOrWhiteSpace(regionName))
return GetDefaultRegions(scopeID);
mapname = regionName;
}
else
mapname = regionURI + regionName;
@ -595,13 +600,23 @@ namespace OpenSim.Services.GridService
{
string regionURI = "";
string regionName = "";
if(!Util.buildHGRegionURI(name, out regionURI, out regionName))
string regionHost = "";
if (!Util.buildHGRegionURI(name, out regionURI, out regionHost, out regionName))
return null;
string mapname;
bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
bool localGrid = m_HypergridLinker.IsLocalGrid(regionHost);
if (localGrid)
{
if (String.IsNullOrWhiteSpace(regionName))
{
List< GridRegion> defregs = GetDefaultRegions(scopeID);
if(defregs == null)
return null;
return defregs[0];
}
mapname = regionName;
}
else
mapname = regionURI + regionName;

View File

@ -65,8 +65,9 @@ namespace OpenSim.Services.GridService
protected UUID m_ScopeID = UUID.Zero;
// protected bool m_Check4096 = true;
protected string m_MapTileDirectory = string.Empty;
protected string m_ThisGatekeeper = string.Empty;
protected Uri m_ThisGatekeeperURI = null;
protected string m_ThisGatekeeperURI = string.Empty;
protected string m_ThisGatekeeperHost = string.Empty;
protected string m_ThisGateKeeperIP = string.Empty;
protected GridRegion m_DefaultRegion;
protected GridRegion DefaultRegion
@ -124,24 +125,15 @@ namespace OpenSim.Services.GridService
m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");
m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
m_ThisGatekeeperURI = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
// Legacy. Remove soon!
m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper);
try
{
m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper);
}
catch
{
m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
}
m_ThisGatekeeperURI = gridConfig.GetString("Gatekeeper", m_ThisGatekeeperURI);
m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
if(m_ThisGatekeeperURI.Port == 80)
m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/";
else if(m_ThisGatekeeperURI.Port == 443)
m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/";
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");
}
m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
@ -197,9 +189,13 @@ namespace OpenSim.Services.GridService
return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
}
public bool IsLocalGrid(string serverURI)
public bool IsLocalGrid(string UriHost)
{
return serverURI == m_ThisGatekeeper;
if(String.IsNullOrEmpty(UriHost))
return true;
if(m_ThisGatekeeperHost.Equals(UriHost, StringComparison.InvariantCultureIgnoreCase))
return true;
return m_ThisGateKeeperIP.Equals(UriHost);
}
public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
@ -208,9 +204,10 @@ 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 regionName))
if (!Util.buildHGRegionURI(mapName, out serverURI, out regionHost, out regionName))
{
reason = "Wrong URI format for link-region";
return null;
@ -277,9 +274,9 @@ namespace OpenSim.Services.GridService
regInfo.EstateOwner = ownerID;
// Make sure we're not hyperlinking to regions on this grid!
if (m_ThisGatekeeperURI != null)
if (String.IsNullOrWhiteSpace(m_ThisGateKeeperIP))
{
if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port)
if (m_ThisGatekeeperHost.Equals(regInfo.ExternalHostName, StringComparison.InvariantCultureIgnoreCase) || m_ThisGateKeeperIP.Equals(regInfo.ExternalHostName))
{
m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
reason = "Cannot hyperlink to regions on the same grid";