From fd64823466ee667d0d827f95d3001ec8675512b2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 10:37:11 -0800 Subject: * Added missing GatekeeperServiceConnector * Added basic machinery for teleporting users home. Untested. --- .../EntityTransfer/HGEntityTransferModule.cs | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 101aea0..0e6323b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -111,6 +111,55 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); } + public override void TeleportHome(UUID id, IClientAPI client) + { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); + + // Let's find out if this is a foreign user or a local user + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, id); + if (account != null) + { + // local grid user + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); + base.TeleportHome(id, client); + return; + } + + // Foreign user wants to go home + // + AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); + if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI"))) + { + client.SendTeleportFailed("Your information has been lost"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); + return; + } + + GridRegion homeGatekeeper = MakeRegion(aCircuit); + if (homeGatekeeper == null) + { + client.SendTeleportFailed("Your information has been lost"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed"); + return; + } + + Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; + GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); + } #endregion + + private GridRegion MakeRegion(AgentCircuitData aCircuit) + { + GridRegion region = new GridRegion(); + + Uri uri = null; + if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri)) + return null; + + region.ExternalHostName = uri.Host; + region.HttpPort = (uint)uri.Port; + region.RegionName = string.Empty; + return region; + } } } -- cgit v1.1 From 3d536944153d4931cf891d6a788a47484f3e6f4d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 16:34:23 -0800 Subject: Go Home works. With security!! --- .../EntityTransfer/HGEntityTransferModule.cs | 69 +++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 0e6323b..d39537d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -34,6 +34,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Connectors.Hypergrid; using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; using GridRegion = OpenSim.Services.Interfaces.GridRegion; @@ -59,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } private GatekeeperServiceConnector m_GatekeeperConnector; + private IHomeUsersSecurityService m_Security; #region ISharedRegionModule @@ -77,12 +79,42 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_agentsInTransit = new List(); m_GatekeeperConnector = new GatekeeperServiceConnector(); + + IConfig config = source.Configs["HGEntityTransferModule"]; + if (config != null) + { + string dll = config.GetString("HomeUsersSecurityService", string.Empty); + if (dll != string.Empty) + { + Object[] args = new Object[] { source }; + m_Security = ServerUtils.LoadPlugin(dll, args); + if (m_Security == null) + m_log.Debug("[HG ENTITY TRANSFER MODULE]: Unable to load Home Users Security service"); + else + m_log.Debug("[HG ENTITY TRANSFER MODULE]: Home Users Security service loaded"); + } + } + m_Enabled = true; m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); } } } + public override void AddRegion(Scene scene) + { + base.AddRegion(scene); + if (m_Enabled) + scene.RegisterModuleInterface(m_Security); + } + + public override void RemoveRegion(Scene scene) + { + base.AddRegion(scene); + if (m_Enabled) + scene.UnregisterModuleInterface(m_Security); + } + #endregion @@ -98,13 +130,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return true; } - protected override bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { reason = string.Empty; - if (reg.RegionLocX != finalDestination.RegionLocX && reg.RegionLocY != finalDestination.RegionLocY) + if (reg.RegionLocX != finalDestination.RegionLocX || reg.RegionLocY != finalDestination.RegionLocY) { // this user is going to another grid reg.RegionName = finalDestination.RegionName; + reg.RegionID = finalDestination.RegionID; + reg.RegionLocX = finalDestination.RegionLocX; + reg.RegionLocY = finalDestination.RegionLocY; + + // Log their session and remote endpoint in the home users security service + IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface(); + if (security != null) + security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint); + + // Log them out of this grid + sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); + return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason); } @@ -145,6 +189,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); + if (finalDestination == null) + { + client.SendTeleportFailed("Your home region could not be found"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); + return; + } + + ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); + if (sp == null) + { + client.SendTeleportFailed("Internal error"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); + return; + } + + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", + aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); + + IEventQueue eq = sp.Scene.RequestModuleInterface(); + DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); } #endregion @@ -159,6 +223,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer region.ExternalHostName = uri.Host; region.HttpPort = (uint)uri.Port; region.RegionName = string.Empty; + region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); return region; } } -- cgit v1.1