Moved all HG1 operations to HGGridConnector.cs and HypergridServerConnector.cs/HypergridServiceConnector.cs, away from Region.Communications and HGNetworkServersInfo.

Fixed small bugs with hyperlinked regions' map positions.
0.6.8-post-fixes
Diva Canto 2009-09-26 21:00:51 -07:00
parent dcfd08b8dd
commit f4bf581b96
14 changed files with 538 additions and 101 deletions

View File

@ -144,7 +144,6 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager
// We are in grid mode // We are in grid mode
InitialiseHGGridServices(libraryRootFolder); InitialiseHGGridServices(libraryRootFolder);
} }
HGCommands.HGServices = HGServices;
} }
protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder) protected void InitialiseStandardServices(LibraryRootFolder libraryRootFolder)

View File

@ -1203,6 +1203,32 @@ namespace OpenSim.Framework
return found.ToArray(); return found.ToArray();
} }
public static string ServerURI(string uri)
{
if (uri == string.Empty)
return string.Empty;
// Get rid of eventual slashes at the end
uri = uri.TrimEnd('/');
IPAddress ipaddr1 = null;
string port1 = "";
try
{
ipaddr1 = Util.GetHostFromURL(uri);
}
catch { }
try
{
port1 = uri.Split(new char[] { ':' })[2];
}
catch { }
// We tried our best to convert the domain names to IP addresses
return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
}
#region FireAndForget Threading Pattern #region FireAndForget Threading Pattern
public static void FireAndForget(System.Threading.WaitCallback callback) public static void FireAndForget(System.Threading.WaitCallback callback)

View File

@ -43,12 +43,11 @@ namespace OpenSim
public class HGCommands public class HGCommands
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static IHyperlink HGServices = null;
public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
{ {
HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);
return return
new HGScene( new HGScene(

View File

@ -596,16 +596,16 @@ namespace OpenSim.Region.Communications.Hypergrid
//m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); //m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
//m_log.Debug(" --------- ---------------- -------"); //m_log.Debug(" --------- ---------------- -------");
string serverURI = ""; //string serverURI = "";
if (u.UserProfile is ForeignUserProfileData) //if (u.UserProfile is ForeignUserProfileData)
serverURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI); // serverURI = Util.ServerURI(((ForeignUserProfileData)u.UserProfile).UserServerURI);
loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI; //loginParams["userserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalUserServerURI : serverURI;
serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI); //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserAssetURI);
loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI; //loginParams["assetserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalAssetServerURI : serverURI;
serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI); //serverURI = HGNetworkServersInfo.ServerURI(u.UserProfile.UserInventoryURI);
loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI; //loginParams["inventoryserver_id"] = (serverURI == "") || (serverURI == null) ? HGNetworkServersInfo.Singleton.LocalInventoryServerURI : serverURI;
loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID; loginParams["root_folder_id"] = u.UserProfile.RootInventoryFolderID;
@ -949,33 +949,35 @@ namespace OpenSim.Region.Communications.Hypergrid
protected bool IsComingHome(ForeignUserProfileData userData) protected bool IsComingHome(ForeignUserProfileData userData)
{ {
return (userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI); return false; //(userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI);
} }
protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo) protected bool IsGoingHome(CachedUserInfo uinfo, RegionInfo rinfo)
{ {
if (uinfo.UserProfile == null) return false;
return false; //if (uinfo.UserProfile == null)
// return false;
string userUserServerURI = String.Empty; //string userUserServerURI = String.Empty;
if (uinfo.UserProfile is ForeignUserProfileData) //if (uinfo.UserProfile is ForeignUserProfileData)
{ //{
userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); // userUserServerURI = HGNetworkServersInfo.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
} //}
return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) && //return ((uinfo.UserProfile.HomeRegionID == rinfo.RegionID) &&
(userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI)); // (userUserServerURI != HGNetworkServersInfo.Singleton.LocalUserServerURI));
} }
protected bool IsLocalUser(CachedUserInfo uinfo) protected bool IsLocalUser(CachedUserInfo uinfo)
{ {
if (uinfo == null) return true;
return true; //if (uinfo == null)
// return true;
if (uinfo.UserProfile is ForeignUserProfileData) //if (uinfo.UserProfile is ForeignUserProfileData)
return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); // return HGNetworkServersInfo.Singleton.IsLocalUser(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
else //else
return true; // return true;
} }

View File

@ -37,6 +37,7 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base; using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base; using OpenSim.Server.Handlers.Base;
using OpenSim.Server.Handlers.Grid; using OpenSim.Server.Handlers.Grid;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
@ -95,20 +96,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
if (!m_Enabled) if (!m_Enabled)
return; return;
if (!m_Registered)
{
m_Registered = true;
m_log.Info("[HypergridService]: Starting...");
Object[] args = new Object[] { m_Config, MainServer.Instance };
m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
//ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
}
GridRegion rinfo = new GridRegion(scene.RegionInfo);
m_HypergridHandler.AddRegion(rinfo);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -122,6 +109,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
if (!m_Registered)
{
m_Registered = true;
m_log.Info("[HypergridService]: Starting...");
Object[] args = new Object[] { m_Config, MainServer.Instance };
m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface<IHyperlinkService>());
//ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
}
GridRegion rinfo = new GridRegion(scene.RegionInfo);
m_HypergridHandler.AddRegion(rinfo);
} }
#endregion #endregion

View File

@ -31,6 +31,7 @@ using System.Net;
using System.Reflection; using System.Reflection;
using System.Xml; using System.Xml;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -52,10 +53,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI;
private bool m_Enabled = false; private bool m_Enabled = false;
private bool m_Initialized = false; private bool m_Initialized = false;
private Scene m_aScene;
private Dictionary<ulong, Scene> m_LocalScenes = new Dictionary<ulong, Scene>();
private IGridService m_GridServiceConnector; private IGridService m_GridServiceConnector;
private HypergridServiceConnector m_HypergridServiceConnector; private HypergridServiceConnector m_HypergridServiceConnector;
@ -141,6 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (!m_Enabled) if (!m_Enabled)
return; return;
m_LocalScenes[scene.RegionInfo.RegionHandle] = scene;
scene.RegisterModuleInterface<IGridService>(this); scene.RegisterModuleInterface<IGridService>(this);
scene.RegisterModuleInterface<IHyperlinkService>(this); scene.RegisterModuleInterface<IHyperlinkService>(this);
@ -148,6 +154,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{ {
m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
} }
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
@ -157,7 +164,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (!m_Initialized) if (!m_Initialized)
{ {
m_aScene = scene;
LocalAssetServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
LocalInventoryServerURI = m_aScene.CommsManager.NetworkServersInfo.InventoryURL;
LocalUserServerURI = m_aScene.CommsManager.NetworkServersInfo.UserURL;
m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
HGCommands hgCommands = new HGCommands(this, scene); HGCommands hgCommands = new HGCommands(this, scene);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region", MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region",
"link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
@ -167,6 +180,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
"Unlink a hypergrid region", hgCommands.RunCommand); "Unlink a hypergrid region", hgCommands.RunCommand);
MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>", MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
"Set local coordinate to map HG regions to", hgCommands.RunCommand); "Set local coordinate to map HG regions to", hgCommands.RunCommand);
// Yikes!! Remove this as soon as user services get refactored
HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI);
m_Initialized = true; m_Initialized = true;
} }
} }
@ -240,7 +257,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// Try the foreign users home collection // Try the foreign users home collection
foreach (GridRegion r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
if (r.RegionID == regionID) if (r.RegionID == regionID)
return m_knownRegions[regionID]; return r;
// Finally, try the normal route // Finally, try the normal route
return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
@ -261,7 +278,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
foreach (GridRegion r in m_knownRegions.Values) foreach (GridRegion r in m_knownRegions.Values)
{ {
if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
{
return r; return r;
}
} }
// Finally, try the normal route // Finally, try the normal route
@ -328,8 +347,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
{ {
m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); m_HyperlinkRegions[regionInfo.RegionID] = regionInfo;
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
} }
private void RemoveHyperlinkRegion(UUID regionID) private void RemoveHyperlinkRegion(UUID regionID)
@ -340,8 +359,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
{ {
m_knownRegions.Add(userID, regionInfo); m_knownRegions[userID] = regionInfo;
m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); m_HyperlinkHandles[regionInfo.RegionID] = regionHandle;
} }
private void RemoveHyperlinkHomeRegion(UUID regionID) private void RemoveHyperlinkHomeRegion(UUID regionID)
@ -412,7 +431,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// From the map search and secondlife://blah // From the map search and secondlife://blah
public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
{ {
int xloc = random.Next(0, Int16.MaxValue); int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize;
return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
} }
@ -563,10 +582,206 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
foreach (GridRegion r in m_HyperlinkRegions.Values) foreach (GridRegion r in m_HyperlinkRegions.Values)
if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
return m_HyperlinkHandles[r.RegionID]; return m_HyperlinkHandles[r.RegionID];
foreach (GridRegion r in m_knownRegions.Values)
if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID)))
return m_HyperlinkHandles[r.RegionID];
return handle; return handle;
} }
public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
(!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
{
m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere");
// Set the position of the region on the remote grid
ulong realHandle = FindRegionHandle(regInfo.RegionHandle);
uint x = 0, y = 0;
Utils.LongToUInts(regInfo.RegionHandle, out x, out y);
GridRegion clonedRegion = new GridRegion(regInfo);
clonedRegion.RegionLocX = (int)x;
clonedRegion.RegionLocY = (int)y;
// Get the user's home region information
GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
// Get the user's service URLs
string serverURI = "";
if (uinfo.UserProfile is ForeignUserProfileData)
serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI);
string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI;
string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI);
if ((assetServer == null) || (assetServer == ""))
assetServer = LocalAssetServerURI;
string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((inventoryServer == null) || (inventoryServer == ""))
inventoryServer = LocalInventoryServerURI;
if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer))
{
m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
return false;
}
}
//if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
//{
// m_log.Info("[HGrid]: User seems to be going to foreign region.");
// if (!InformRegionOfUser(regInfo, agentData))
// {
// m_log.Warn("[HGrid]: Could not inform remote region of transferring user.");
// return false;
// }
//}
//else
// m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
// May need to change agent's name
if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null))
{
agentData.firstname = agentData.firstname + "." + agentData.lastname;
agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
}
return true;
}
public void AdjustUserInformation(AgentCircuitData agentData)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
if ((uinfo != null) && (uinfo.UserProfile != null) &&
(IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData)))
{
//m_log.Debug("---------------> Local User!");
string[] parts = agentData.firstname.Split(new char[] { '.' });
if (parts.Length == 2)
{
agentData.firstname = parts[0];
agentData.lastname = parts[1];
}
}
//else
// m_log.Debug("---------------> Foreign User!");
}
// Check if a local user exists with the same UUID as the incoming foreign user
public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome)
{
comingHome = false;
if (!m_aScene.SceneGridService.RegionLoginsEnabled)
return false;
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
if (uinfo != null)
{
// uh-oh we have a potential intruder
if (uinfo.SessionID != sessionID)
// can't have a foreigner with a local UUID
return false;
else
// oh, so it's you! welcome back
comingHome = true;
}
// OK, user can come in
return true;
}
public void AcceptUser(ForeignUserProfileData user, GridRegion home)
{
m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
ulong realHandle = home.RegionHandle;
// Change the local coordinates
// X=0 on the map
home.RegionLocX = 0;
home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
AddHyperlinkHomeRegion(user.ID, home, realHandle);
DumpUserData(user);
DumpRegionData(home);
}
public bool IsLocalUser(UUID userID)
{
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
return IsLocalUser(uinfo);
}
#endregion #endregion
#region IHyperlink Misc
protected bool IsComingHome(ForeignUserProfileData userData)
{
return (userData.UserServerURI == LocalUserServerURI);
}
// Is the user going back to the home region or the home grid?
protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
{
if (uinfo.UserProfile == null)
return false;
if (!(uinfo.UserProfile is ForeignUserProfileData))
// it's a home user, can't be outside to return home
return false;
// OK, it's a foreign user with a ForeignUserProfileData
// and is going back to exactly the home region.
// We can't check if it's going back to a non-home region
// of the home grid. That will be dealt with in the
// receiving end
return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID);
}
protected bool IsLocalUser(CachedUserInfo uinfo)
{
if (uinfo == null)
return false;
return !(uinfo.UserProfile is ForeignUserProfileData);
}
protected bool IsLocalRegion(ulong handle)
{
return m_LocalScenes.ContainsKey(handle);
}
private void DumpUserData(ForeignUserProfileData userData)
{
m_log.Info(" ------------ User Data Dump ----------");
m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName);
m_log.Info(" >> HomeID: " + userData.HomeRegionID);
m_log.Info(" >> UserServer: " + userData.UserServerURI);
m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
m_log.Info(" ------------ -------------- ----------");
}
private void DumpRegionData(GridRegion rinfo)
{
m_log.Info(" ------------ Region Data Dump ----------");
m_log.Info(" >> handle: " + rinfo.RegionHandle);
m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY);
m_log.Info(" >> external host name: " + rinfo.ExternalHostName);
m_log.Info(" >> http port: " + rinfo.HttpPort);
m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address);
m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port);
m_log.Info(" ------------ -------------- ----------");
}
#endregion
} }
} }

View File

@ -824,29 +824,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit)
{ {
try if (m_hyperlinkService != null)
{ m_hyperlinkService.SendUserInformation(regInfo, aCircuit);
if (m_aScene.SceneGridService is HGSceneCommunicationService)
{
// big hack for now
RegionInfo r = new RegionInfo();
r.ExternalHostName = regInfo.ExternalHostName;
r.HttpPort = regInfo.HttpPort;
r.RegionID = regInfo.RegionID;
r.RegionLocX = (uint)regInfo.RegionLocX;
r.RegionLocY = (uint)regInfo.RegionLocY;
((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(r, aCircuit);
}
}
catch // Bad cast
{ }
} }
public override void AdjustUserInformation(AgentCircuitData aCircuit) public override void AdjustUserInformation(AgentCircuitData aCircuit)
{ {
if (m_aScene.SceneGridService is HGSceneCommunicationService) if (m_hyperlinkService != null)
((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit); m_hyperlinkService.AdjustUserInformation(aCircuit);
} }
} }

View File

@ -525,7 +525,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return true; return true;
} }
string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == ""))
// this happens in standalone profiles, apparently
return true;
string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
string uri = m_LocalGridInventoryURI.TrimEnd('/'); string uri = m_LocalGridInventoryURI.TrimEnd('/');
if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) if ((userInventoryServerURI == uri) || (userInventoryServerURI == ""))
@ -544,7 +549,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if ((uinfo == null) || (uinfo.UserProfile == null)) if ((uinfo == null) || (uinfo.UserProfile == null))
return invURI; return invURI;
string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI);
if ((userInventoryServerURI != null) && if ((userInventoryServerURI != null) &&
(userInventoryServerURI != "")) (userInventoryServerURI != ""))

View File

@ -137,8 +137,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
data.Name = info.RegionName; data.Name = info.RegionName;
data.RegionFlags = 0; // TODO not used? data.RegionFlags = 0; // TODO not used?
data.WaterHeight = 0; // not used data.WaterHeight = 0; // not used
data.X = (ushort)info.RegionLocX; data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
data.Y = (ushort)info.RegionLocY; data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
blocks.Add(data); blocks.Add(data);
} }
} }

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Clients; using OpenSim.Framework.Communications.Clients;
using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Services.Interfaces;
//using HyperGrid.Framework; //using HyperGrid.Framework;
//using OpenSim.Region.Communications.Hypergrid; //using OpenSim.Region.Communications.Hypergrid;
@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
private Scene m_scene; private Scene m_scene;
private IHyperlinkService m_hyper;
IHyperlinkService HyperlinkService
{
get
{
if (m_hyper == null)
m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>();
return m_hyper;
}
}
#endregion #endregion
#region Constructor #region Constructor
@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
// return null; // return null;
// } // }
private bool IsLocalUser(UUID userID)
{
CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
if (uinfo != null)
{
if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
{
m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
return true;
}
}
m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
return false;
}
public AssetBase FetchAsset(string url, UUID assetID) public AssetBase FetchAsset(string url, UUID assetID)
{ {
@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public void Get(UUID assetID, UUID ownerID) public void Get(UUID assetID, UUID ownerID)
{ {
if (!IsLocalUser(ownerID)) if (!HyperlinkService.IsLocalUser(ownerID))
{ {
// Get the item from the remote asset server onto the local AssetCache // Get the item from the remote asset server onto the local AssetCache
// and place an entry in m_assetMap // and place an entry in m_assetMap
@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public void Post(UUID assetID, UUID ownerID) public void Post(UUID assetID, UUID ownerID)
{ {
if (!IsLocalUser(ownerID)) if (!HyperlinkService.IsLocalUser(ownerID))
{ {
// Post the item from the local AssetCache onto the remote asset server // Post the item from the local AssetCache onto the remote asset server
// and place an entry in m_assetMap // and place an entry in m_assetMap

View File

@ -38,6 +38,7 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities; using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid namespace OpenSim.Region.Framework.Scenes.Hypergrid
@ -46,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public readonly IHyperlink m_hg; private IHyperlinkService m_hg;
IHyperlinkService HyperlinkService
public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) {
get
{
if (m_hg == null)
m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
return m_hg;
}
}
public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
{ {
m_hg = hg;
} }
@ -129,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
/// Hypergrid mod start /// Hypergrid mod start
/// ///
/// ///
bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
bool isHomeUser = true; bool isHomeUser = true;
ulong realHandle = regionHandle; ulong realHandle = regionHandle;
CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
if (uinfo != null) if (uinfo != null)
{ {
isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile); isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
realHandle = m_hg.FindRegionHandle(regionHandle); realHandle = m_hg.FindRegionHandle(regionHandle);
m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
} }

View File

@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base; using OpenSim.Server.Handlers.Base;
using GridRegion = OpenSim.Services.Interfaces.GridRegion; using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using log4net; using log4net;
using Nwc.XmlRpc; using Nwc.XmlRpc;
@ -50,11 +51,25 @@ namespace OpenSim.Server.Handlers.Grid
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private List<GridRegion> m_RegionsOnSim = new List<GridRegion>(); private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
private IHyperlinkService m_HyperlinkService;
public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
base(config, server) base(config, server)
{ {
m_HyperlinkService = hyperService;
server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
}
public void AddRegion(GridRegion rinfo)
{
m_RegionsOnSim.Add(rinfo);
}
public void RemoveRegion(GridRegion rinfo)
{
if (m_RegionsOnSim.Contains(rinfo))
m_RegionsOnSim.Remove(rinfo);
} }
/// <summary> /// <summary>
@ -99,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid
return response; return response;
} }
public void AddRegion(GridRegion rinfo) /// <summary>
/// Received from other HGrid nodes when a user wants to teleport here. This call allows
/// the region to prepare for direct communication from the client. Sends back an empty
/// xmlrpc response on completion.
/// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
/// registering the user in the local user cache.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
{ {
m_RegionsOnSim.Add(rinfo); Hashtable requestData = (Hashtable)request.Params[0];
ForeignUserProfileData userData = new ForeignUserProfileData();
userData.FirstName = (string)requestData["firstname"];
userData.SurName = (string)requestData["lastname"];
userData.ID = new UUID((string)requestData["agent_id"]);
UUID sessionID = new UUID((string)requestData["session_id"]);
userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
(float)Convert.ToDecimal((string)requestData["startpos_y"]),
(float)Convert.ToDecimal((string)requestData["startpos_z"]));
userData.UserServerURI = (string)requestData["userserver_id"];
userData.UserAssetURI = (string)requestData["assetserver_id"];
userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
ulong userRegionHandle = 0;
int userhomeinternalport = 0;
if (requestData.ContainsKey("region_uuid"))
{
UUID uuid = UUID.Zero;
UUID.TryParse((string)requestData["region_uuid"], out uuid);
userData.HomeRegionID = uuid;
userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
userData.UserHomeAddress = (string)requestData["home_address"];
userData.UserHomePort = (string)requestData["home_port"];
userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
"; home_port: " + userData.UserHomePort);
}
else
m_log.WarnFormat("[HGrid]: User has no home region information");
XmlRpcResponse resp = new XmlRpcResponse();
// Let's check if someone is trying to get in with a stolen local identity.
// The need for this test is a consequence of not having truly global names :-/
bool comingHome = false;
if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
{
m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
Hashtable respdata = new Hashtable();
respdata["success"] = "FALSE";
respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
resp.Value = respdata;
return resp;
}
// Finally, everything looks ok
//m_log.Debug("XXX---- EVERYTHING OK ---XXX");
if (!comingHome)
{
// We don't do this if the user is coming to the home grid
GridRegion home = new GridRegion();
home.RegionID = userData.HomeRegionID;
home.ExternalHostName = userData.UserHomeAddress;
home.HttpPort = Convert.ToUInt32(userData.UserHomePort);
uint x = 0, y = 0;
Utils.LongToUInts(userRegionHandle, out x, out y);
home.RegionLocX = (int)x;
home.RegionLocY = (int)y;
home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
m_HyperlinkService.AcceptUser(userData, home);
}
// else the user is coming to a non-home region of the home grid
// We simply drop this user information altogether
Hashtable respdata2 = new Hashtable();
respdata2["success"] = "TRUE";
resp.Value = respdata2;
return resp;
} }
public void RemoveRegion(GridRegion rinfo)
{
if (m_RegionsOnSim.Contains(rinfo))
m_RegionsOnSim.Remove(rinfo);
}
} }
} }

View File

@ -149,5 +149,94 @@ namespace OpenSim.Services.Connectors.Grid
} }
} }
public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer)
{
string capsPath = agentData.CapsPath;
Hashtable loginParams = new Hashtable();
loginParams["session_id"] = agentData.SessionID.ToString();
loginParams["firstname"] = agentData.firstname;
loginParams["lastname"] = agentData.lastname;
loginParams["agent_id"] = agentData.AgentID.ToString();
loginParams["circuit_code"] = agentData.circuitcode.ToString();
loginParams["startpos_x"] = agentData.startpos.X.ToString();
loginParams["startpos_y"] = agentData.startpos.Y.ToString();
loginParams["startpos_z"] = agentData.startpos.Z.ToString();
loginParams["caps_path"] = capsPath;
if (home != null)
{
loginParams["region_uuid"] = home.RegionID.ToString();
loginParams["regionhandle"] = home.RegionHandle.ToString();
loginParams["home_address"] = home.ExternalHostName;
loginParams["home_port"] = home.HttpPort.ToString();
loginParams["internal_port"] = home.InternalEndPoint.Port.ToString();
m_log.Debug(" --------- Home -------");
m_log.Debug(" >> " + loginParams["home_address"] + " <<");
m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
m_log.Debug(" >> " + loginParams["regionhandle"] + " <<");
m_log.Debug(" >> " + loginParams["home_port"] + " <<");
m_log.Debug(" --------- ------------ -------");
}
else
m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname);
loginParams["userserver_id"] = userServer;
loginParams["assetserver_id"] = assetServer;
loginParams["inventoryserver_id"] = inventoryServer;
ArrayList SendParams = new ArrayList();
SendParams.Add(loginParams);
// Send
string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/";
//m_log.Debug("XXX uri: " + uri);
XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams);
XmlRpcResponse reply;
try
{
reply = request.Send(uri, 6000);
}
catch (Exception e)
{
m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message);
return false;
}
if (!reply.IsFault)
{
bool responseSuccess = true;
if (reply.Value != null)
{
Hashtable resp = (Hashtable)reply.Value;
if (resp.ContainsKey("success"))
{
if ((string)resp["success"] == "FALSE")
{
responseSuccess = false;
}
}
}
if (responseSuccess)
{
m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID);
return true;
}
else
{
m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients");
return false;
}
}
else
{
m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode);
return false;
}
}
} }
} }

View File

@ -191,6 +191,20 @@ namespace OpenSim.Services.Interfaces
Maturity = ConvertFrom.RegionSettings.Maturity; Maturity = ConvertFrom.RegionSettings.Maturity;
} }
public GridRegion(GridRegion ConvertFrom)
{
m_regionName = ConvertFrom.RegionName;
m_regionLocX = ConvertFrom.RegionLocX;
m_regionLocY = ConvertFrom.RegionLocY;
m_internalEndPoint = ConvertFrom.InternalEndPoint;
m_externalHostName = ConvertFrom.ExternalHostName;
m_httpPort = ConvertFrom.HttpPort;
RegionID = ConvertFrom.RegionID;
ServerURI = ConvertFrom.ServerURI;
TerrainImage = ConvertFrom.TerrainImage;
Access = ConvertFrom.Access;
Maturity = ConvertFrom.Maturity;
}
/// <value> /// <value>
/// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.