From 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 28 Jan 2010 19:19:42 -0800 Subject: HG 1.5 is in place. Tested in standalone only. --- .../EntityTransfer/EntityTransferModule.cs | 10 +- .../EntityTransfer/HGEntityTransferModule.cs | 112 +++++++++++---------- 2 files changed, 69 insertions(+), 53 deletions(-) (limited to 'OpenSim/Region/CoreModules/Framework') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ed8c0fd..44f1191 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -237,9 +237,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) { + if (reg == null || finalDestination == null) + { + sp.ControllingClient.SendTeleportFailed("Unable to locate destination"); + return; + } + m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}", - reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName); + "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}", + reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 4d5844c..85c2742 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -44,14 +44,13 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { - public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule + public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Initialized = false; private GatekeeperServiceConnector m_GatekeeperConnector; - private IHomeUsersSecurityService m_Security; #region ISharedRegionModule @@ -69,21 +68,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (name == Name) { m_agentsInTransit = new List(); - - 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); @@ -95,7 +79,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { base.AddRegion(scene); if (m_Enabled) - scene.RegisterModuleInterface(m_Security); + { + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(OnNewClient); + } + } + + void OnNewClient(IClientAPI client) + { + client.OnLogout += new Action(OnLogout); } public override void RegionLoaded(Scene scene) @@ -113,13 +105,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { base.AddRegion(scene); if (m_Enabled) - scene.UnregisterModuleInterface(m_Security); + { + scene.UnregisterModuleInterface(this); + } } #endregion - #region HG overrides + #region HG overrides of IEntiryTransferModule protected override GridRegion GetFinalDestination(GridRegion region) { @@ -142,26 +136,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { reason = string.Empty; int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); - if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) + if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid - // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination - GridRegion region = new GridRegion(reg); - region.RegionName = finalDestination.RegionName; - region.RegionID = finalDestination.RegionID; - region.RegionLocX = finalDestination.RegionLocX; - region.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); - - //string token = sp.Scene.AuthenticationService.MakeToken(sp.UUID, reg.ExternalHostName + ":" + reg.HttpPort, 30); - // Log them out of this grid - sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); - - return m_GatekeeperConnector.CreateAgent(region, agentCircuit, teleportFlags, out reason); + string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver); + bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason); + if (success) + // Log them out of this grid + m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); + + return success; } return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); @@ -184,23 +169,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Foreign user wants to go home // AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); - if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI"))) + if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI"))) { 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; - } - + IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; - GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); + GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt); if (finalDestination == null) { client.SendTeleportFailed("Your home region could not be found"); @@ -216,20 +194,52 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", + IEventQueue eq = sp.Scene.RequestModuleInterface(); + GridRegion homeGatekeeper = MakeRegion(aCircuit); + + 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 + #region IUserAgentVerificationModule + + public bool VerifyClient(AgentCircuitData aCircuit, string token) + { + if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + { + string url = aCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService security = new UserAgentServiceConnector(url); + return security.VerifyClient(aCircuit.SessionID, token); + } + + return false; + } + + void OnLogout(IClientAPI obj) + { + AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); + + if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + { + string url = aCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService security = new UserAgentServiceConnector(url); + security.LogoutAgent(obj.AgentId, obj.SessionId); + } + + } + + #endregion + private GridRegion MakeRegion(AgentCircuitData aCircuit) { GridRegion region = new GridRegion(); Uri uri = null; - if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri)) + if (!aCircuit.ServiceURLs.ContainsKey("HomeURI") || + (aCircuit.ServiceURLs.ContainsKey("HomeURI") && !Uri.TryCreate(aCircuit.ServiceURLs["HomeURI"].ToString(), UriKind.Absolute, out uri))) return null; region.ExternalHostName = uri.Host; -- cgit v1.1