Go Home works. With security!!

This commit is contained in:
Diva Canto
2010-01-18 16:34:23 -08:00
parent fd64823466
commit 3d53694415
13 changed files with 471 additions and 26 deletions

View File

@@ -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<IEventQueue>();
// 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);
}

View File

@@ -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<UUID>();
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<IHomeUsersSecurityService>(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<IHomeUsersSecurityService>(m_Security);
}
public override void RemoveRegion(Scene scene)
{
base.AddRegion(scene);
if (m_Enabled)
scene.UnregisterModuleInterface<IHomeUsersSecurityService>(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<IHomeUsersSecurityService>();
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<IEventQueue>();
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;
}
}