give more use to GridInfo for gatekeeper url

This commit is contained in:
UbitUmarov
2020-09-23 22:21:57 +01:00
parent d0d1ab9f2a
commit 354c79168b
5 changed files with 26 additions and 89 deletions

View File

@@ -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);

View File

@@ -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>(T x, T min, T max)
where T : IComparable<T>
{

View File

@@ -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<string> m_ThisGateKeeperAlias = new HashSet<string>();
private GridInfo m_ThisGridInfo;
//private string m_ThisGatekeeperURI = string.Empty;
//private string m_ThisGatekeeperHost = string.Empty;
//private string m_ThisGatekeeperIP = string.Empty;
//private HashSet<string> m_ThisGateKeeperAlias = new HashSet<string>();
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<string>(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<string>(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<IGridService>(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
}

View File

@@ -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))

View File

@@ -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<string> m_ThisGateKeeperAlias = new HashSet<string>();
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<string>(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<string>(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");