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/EntityTransferModule.cs | 10 ++-- .../EntityTransfer/HGEntityTransferModule.cs | 69 +++++++++++++++++++++- 2 files changed, 71 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index e85f270..ed8c0fd 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -134,8 +134,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) return; - bool destRegionUp = true; - IEventQueue eq = sp.Scene.RequestModuleInterface(); // Reset animations; the viewer does that in teleports. @@ -240,8 +238,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) { m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", - position, reg.RegionName); + "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}", + reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); @@ -297,7 +295,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason = String.Empty; // Let's create an agent there if one doesn't exist yet. - if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason)) + if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason)) { sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", reason)); @@ -458,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } - protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); } 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