mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 01:35:46 +08:00
add HomeURI to GridInfo
This commit is contained in:
@@ -177,8 +177,8 @@ namespace OpenSim.Framework
|
||||
private OSHostURL m_gateKeeperURL;
|
||||
private HashSet<OSHostURL> m_gateKeeperAlias;
|
||||
|
||||
//private OSHostURL m_homeURL;
|
||||
//private HashSet<OSHostURL> m_homeURLAlias;
|
||||
private OSHostURL m_homeURL;
|
||||
private HashSet<OSHostURL> m_homeURLAlias;
|
||||
|
||||
public GridInfo (IConfigSource config, string defaultHost = "")
|
||||
{
|
||||
@@ -218,10 +218,45 @@ namespace OpenSim.Framework
|
||||
for (int i = 0; i < alias.Length; ++i)
|
||||
{
|
||||
OSHostURL tmp = new OSHostURL(alias[i].Trim(), false);
|
||||
if(m_gateKeeperAlias == null)
|
||||
m_gateKeeperAlias = new HashSet<OSHostURL>();
|
||||
if (tmp.URLType != UriHostNameType.Unknown)
|
||||
{
|
||||
if (m_gateKeeperAlias == null)
|
||||
m_gateKeeperAlias = new HashSet<OSHostURL>();
|
||||
m_gateKeeperAlias.Add(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string home = Util.GetConfigVarFromSections<string>(config, "HomeURI", sections, string.Empty);
|
||||
|
||||
if (string.IsNullOrEmpty(home))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(gatekeeper))
|
||||
m_homeURL = m_gateKeeperURL;
|
||||
else if (!string.IsNullOrEmpty(defaultHost))
|
||||
m_homeURL = new OSHostURL(defaultHost, true);
|
||||
}
|
||||
else
|
||||
m_homeURL = new OSHostURL(home, true);
|
||||
|
||||
if (m_homeURL.URLType == UriHostNameType.Unknown)
|
||||
throw new Exception(String.Format("could not find home(UserAgentsService) URL"));
|
||||
if (m_homeURL.IP == null)
|
||||
throw new Exception(String.Format("could not resolve home(UserAgentsService) hostname"));
|
||||
|
||||
string homeAlias = Util.GetConfigVarFromSections<string>(config, "HomeURIAlias", sections, String.Empty);
|
||||
if (!string.IsNullOrWhiteSpace(homeAlias))
|
||||
{
|
||||
string[] alias = homeAlias.Split(',');
|
||||
for (int i = 0; i < alias.Length; ++i)
|
||||
{
|
||||
OSHostURL tmp = new OSHostURL(alias[i].Trim(), false);
|
||||
if (tmp.URLType != UriHostNameType.Unknown)
|
||||
{
|
||||
if (m_homeURLAlias == null)
|
||||
m_homeURLAlias = new HashSet<OSHostURL>();
|
||||
m_homeURLAlias.Add(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,6 +271,16 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
public string HomeURL
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_homeURL.URLType != UriHostNameType.Unknown)
|
||||
return m_homeURL.URL;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int IsLocalGrid(string gatekeeper)
|
||||
{
|
||||
OSHostURL tmp = new OSHostURL(gatekeeper, false);
|
||||
@@ -247,5 +292,18 @@ namespace OpenSim.Framework
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int IsLocalHome(string home)
|
||||
{
|
||||
OSHostURL tmp = new OSHostURL(home, false);
|
||||
if (tmp.URLType == UriHostNameType.Unknown)
|
||||
return -1;
|
||||
if (tmp.Equals(m_homeURL))
|
||||
return 1;
|
||||
if (m_homeURLAlias != null && m_homeURLAlias.Contains(tmp))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
protected IServiceThrottleModule m_ServiceThrottle;
|
||||
protected IUserAccountService m_userAccountService = null;
|
||||
protected IGridUserService m_gridUserService = null;
|
||||
string m_ThisGatekeeperHost;
|
||||
HashSet<string> m_ThisGateKeeperAlias = new HashSet<string>();
|
||||
|
||||
protected GridInfo m_thisGridInfo;
|
||||
|
||||
// The cache
|
||||
protected ExpiringCacheOS<UUID, UserData> m_userCacheByID = new ExpiringCacheOS<UUID, UserData>(60000);
|
||||
@@ -126,7 +126,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
{
|
||||
m_Scenes.Add(scene);
|
||||
}
|
||||
|
||||
if(m_thisGridInfo == null)
|
||||
m_thisGridInfo = scene.SceneGridInfo;
|
||||
scene.RegisterModuleInterface<IUserManagement>(this);
|
||||
scene.RegisterModuleInterface<IPeople>(this);
|
||||
scene.EventManager.OnNewClient += EventManager_OnNewClient;
|
||||
@@ -171,7 +172,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
{
|
||||
m_Scenes.Clear();
|
||||
}
|
||||
|
||||
m_thisGridInfo = null;
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
@@ -267,10 +268,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
|
||||
string host = uri.DnsSafeHost.ToLower();
|
||||
|
||||
if (m_ThisGatekeeperHost.Equals(host))
|
||||
islocal = true;
|
||||
else if (m_ThisGateKeeperAlias.Contains(host))
|
||||
islocal = true;
|
||||
islocal = m_thisGridInfo.IsLocalHome(host) == 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -944,38 +942,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
||||
|
||||
protected virtual void Init(IConfigSource config)
|
||||
{
|
||||
m_ThisGatekeeperHost = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
|
||||
new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
|
||||
m_ThisGatekeeperHost = Util.GetConfigVarFromSections<string>(config, "Gatekeeper",
|
||||
new string[] { "Startup", "Hypergrid", "GridService" }, m_ThisGatekeeperHost);
|
||||
|
||||
string gatekeeperURIAlias = Util.GetConfigVarFromSections<string>(config, "GatekeeperURIAlias",
|
||||
new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(m_ThisGatekeeperHost))
|
||||
{
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(m_ThisGatekeeperHost, UriKind.Absolute);
|
||||
m_ThisGatekeeperHost = uri.DnsSafeHost.ToLower();
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_log.Error("[UserManagementModule] Invalid grid gatekeeper");
|
||||
m_ThisGatekeeperHost = 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());
|
||||
}
|
||||
}
|
||||
|
||||
AddUser(UUID.Zero, "Unknown", "User", false, int.MaxValue / 16);
|
||||
AddUser(Constants.m_MrOpenSimID, "Mr", "Opensim", false, int.MaxValue / 16);
|
||||
RegisterConsoleCmds();
|
||||
|
||||
Reference in New Issue
Block a user