Merge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensim into presence-refactor
commit
a3f48a7ca6
|
@ -38,6 +38,7 @@ using OpenMetaverse.Packets;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Statistics;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenMetaverse;
|
||||
|
||||
using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket;
|
||||
|
@ -900,6 +901,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
|
||||
if (!m_scene.TryGetClient(agentID, out existingClient))
|
||||
{
|
||||
IHomeUsersSecurityService security = m_scene.RequestModuleInterface<IHomeUsersSecurityService>();
|
||||
if (security != null)
|
||||
{
|
||||
IPEndPoint ep = security.GetEndPoint(sessionID);
|
||||
if (ep != null && ep.ToString() != remoteEndPoint.ToString())
|
||||
{
|
||||
// uh-oh, this is fishy
|
||||
m_log.WarnFormat("[LLUDPSERVER]: Agent {0} with session {1} connecting with unidentified end point. Refusing service.", agentID, sessionID);
|
||||
m_log.WarnFormat("[LLUDPSERVER]: EP was {0}, now is {1}", ep.ToString(), remoteEndPoint.ToString());
|
||||
return;
|
||||
}
|
||||
else if (ep != null)
|
||||
{
|
||||
// ok, you're home, welcome back
|
||||
m_log.InfoFormat("LLUDPSERVER]: Agent {0} is coming back to this grid", agentID);
|
||||
security.RemoveEndPoint(sessionID);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the LLClientView
|
||||
LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
|
||||
client.OnLogout += LogoutHandler;
|
||||
|
|
|
@ -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.
|
||||
|
@ -183,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
|||
sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
|
||||
sp.Teleport(position);
|
||||
}
|
||||
else
|
||||
else // Another region possibly in another simulator
|
||||
{
|
||||
uint x = 0, y = 0;
|
||||
Utils.LongToUInts(regionHandle, out x, out y);
|
||||
|
@ -191,15 +189,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
|||
|
||||
if (reg != null)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}",
|
||||
position, reg.RegionName);
|
||||
|
||||
uint newRegionX = (uint)(reg.RegionHandle >> 40);
|
||||
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
|
||||
uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
|
||||
uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
|
||||
|
||||
GridRegion finalDestination = GetFinalDestination(reg);
|
||||
if (finalDestination == null)
|
||||
{
|
||||
|
@ -207,7 +196,56 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
|||
sp.ControllingClient.SendTeleportFailed("Problem at destination");
|
||||
return;
|
||||
}
|
||||
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", finalDestination.RegionLocX, finalDestination.RegionLocY, finalDestination.RegionID);
|
||||
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}",
|
||||
finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID);
|
||||
|
||||
//
|
||||
// This is it
|
||||
//
|
||||
DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq);
|
||||
//
|
||||
//
|
||||
//
|
||||
}
|
||||
else
|
||||
{
|
||||
// TP to a place that doesn't exist (anymore)
|
||||
// Inform the viewer about that
|
||||
sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
|
||||
|
||||
// and set the map-tile to '(Offline)'
|
||||
uint regX, regY;
|
||||
Utils.LongToUInts(regionHandle, out regX, out regY);
|
||||
|
||||
MapBlockData block = new MapBlockData();
|
||||
block.X = (ushort)(regX / Constants.RegionSize);
|
||||
block.Y = (ushort)(regY / Constants.RegionSize);
|
||||
block.Access = 254; // == not there
|
||||
|
||||
List<MapBlockData> blocks = new List<MapBlockData>();
|
||||
blocks.Add(block);
|
||||
sp.ControllingClient.SendMapBlock(blocks, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace);
|
||||
sp.ControllingClient.SendTeleportFailed("Internal error");
|
||||
}
|
||||
}
|
||||
|
||||
protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
|
||||
{
|
||||
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);
|
||||
|
||||
uint newRegionX = (uint)(reg.RegionHandle >> 40);
|
||||
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
|
||||
uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
|
||||
uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
|
||||
|
||||
ulong destinationHandle = finalDestination.RegionHandle;
|
||||
|
||||
if (eq == null)
|
||||
|
@ -217,13 +255,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
|||
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
|
||||
// it's actually doing a lot of work.
|
||||
IPEndPoint endPoint = finalDestination.ExternalEndPoint;
|
||||
if (endPoint.Address == null)
|
||||
{
|
||||
// Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
|
||||
destRegionUp = false;
|
||||
}
|
||||
|
||||
if (destRegionUp)
|
||||
if (endPoint.Address != null)
|
||||
{
|
||||
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
|
||||
// both regions
|
||||
|
@ -263,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));
|
||||
|
@ -422,35 +454,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
|||
sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TP to a place that doesn't exist (anymore)
|
||||
// Inform the viewer about that
|
||||
sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
|
||||
|
||||
// and set the map-tile to '(Offline)'
|
||||
uint regX, regY;
|
||||
Utils.LongToUInts(regionHandle, out regX, out regY);
|
||||
|
||||
MapBlockData block = new MapBlockData();
|
||||
block.X = (ushort)(regX / Constants.RegionSize);
|
||||
block.Y = (ushort)(regY / Constants.RegionSize);
|
||||
block.Access = 254; // == not there
|
||||
|
||||
List<MapBlockData> blocks = new List<MapBlockData>();
|
||||
blocks.Add(block);
|
||||
sp.ControllingClient.SendMapBlock(blocks, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace);
|
||||
sp.ControllingClient.SendTeleportFailed("Internal error");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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,19 +130,101 @@ 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);
|
||||
}
|
||||
|
||||
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);
|
||||
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
|
||||
|
||||
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;
|
||||
region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
|
||||
return region;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
|
||||
<RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" />
|
||||
<RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
|
||||
<RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \
|
||||
<RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid.HypergridServiceInConnectorModule" /> \
|
||||
<RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \
|
||||
<RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \
|
||||
<RegionModule id="GridInfoServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.GridInfoServiceInConnectorModule" /> \
|
||||
|
|
|
@ -40,7 +40,7 @@ using OpenSim.Server.Handlers.Hypergrid;
|
|||
using OpenSim.Services.Interfaces;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid
|
||||
{
|
||||
public class HypergridServiceInConnectorModule : ISharedRegionModule
|
||||
{
|
||||
|
@ -119,6 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
|
|||
ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
|
||||
m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService);
|
||||
//ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
|
||||
scene.RegisterModuleInterface<IGatekeeperService>(m_HypergridHandler.GateKeeper);
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,12 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IGatekeeperService m_GatekeeperService;
|
||||
public IGatekeeperService GateKeeper
|
||||
{
|
||||
get { return m_GatekeeperService; }
|
||||
}
|
||||
|
||||
private IHypergridService m_HypergridService;
|
||||
|
||||
public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) :
|
||||
base(config, server, String.Empty)
|
||||
|
@ -56,13 +62,19 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
|
||||
Object[] args = new Object[] { config, simService };
|
||||
m_GatekeeperService = ServerUtils.LoadPlugin<IGatekeeperService>(serviceDll, args);
|
||||
|
||||
serviceDll = gridConfig.GetString("HypergridService", string.Empty);
|
||||
m_HypergridService = ServerUtils.LoadPlugin<IHypergridService>(serviceDll, args);
|
||||
|
||||
}
|
||||
if (m_GatekeeperService == null)
|
||||
if (m_GatekeeperService == null || m_HypergridService == null)
|
||||
throw new Exception("Gatekeeper server connector cannot proceed because of missing service");
|
||||
|
||||
HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService);
|
||||
HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService, m_HypergridService);
|
||||
server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false);
|
||||
server.AddXmlRPCHandler("link_region_by_desc", hghandlers.LinkRegionByDescRequest, false);
|
||||
server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false);
|
||||
server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false);
|
||||
|
||||
server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler);
|
||||
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
|
||||
using log4net;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Hypergrid
|
||||
{
|
||||
public class HomeUsersSecurityServerConnector : ServiceConnector
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IHomeUsersSecurityService m_HomeUsersService;
|
||||
|
||||
public HomeUsersSecurityServerConnector(IConfigSource config, IHttpServer server) :
|
||||
base(config, server, String.Empty)
|
||||
{
|
||||
IConfig gridConfig = config.Configs["HomeUsersSecurityService"];
|
||||
if (gridConfig != null)
|
||||
{
|
||||
string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
|
||||
Object[] args = new Object[] { config };
|
||||
m_HomeUsersService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(serviceDll, args);
|
||||
}
|
||||
if (m_HomeUsersService == null)
|
||||
throw new Exception("HomeUsersSecurity server connector cannot proceed because of missing service");
|
||||
|
||||
server.AddXmlRPCHandler("ep_get", GetEndPoint, false);
|
||||
server.AddXmlRPCHandler("ep_set", SetEndPoint, false);
|
||||
server.AddXmlRPCHandler("ep_remove", RemoveEndPoint, false);
|
||||
|
||||
}
|
||||
|
||||
public XmlRpcResponse GetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
//string host = (string)requestData["host"];
|
||||
//string portstr = (string)requestData["port"];
|
||||
string sessionID_str = (string)requestData["sessionID"];
|
||||
UUID sessionID = UUID.Zero;
|
||||
UUID.TryParse(sessionID_str, out sessionID);
|
||||
|
||||
IPEndPoint ep = m_HomeUsersService.GetEndPoint(sessionID);
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
if (ep == null)
|
||||
hash["result"] = "false";
|
||||
else
|
||||
{
|
||||
hash["result"] = "true";
|
||||
hash["ep_addr"] = ep.Address.ToString();
|
||||
hash["ep_port"] = ep.Port.ToString();
|
||||
}
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
response.Value = hash;
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
public XmlRpcResponse SetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
string host = (string)requestData["ep_addr"];
|
||||
string portstr = (string)requestData["ep_port"];
|
||||
string sessionID_str = (string)requestData["sessionID"];
|
||||
UUID sessionID = UUID.Zero;
|
||||
UUID.TryParse(sessionID_str, out sessionID);
|
||||
int port = 0;
|
||||
Int32.TryParse(portstr, out port);
|
||||
|
||||
IPEndPoint ep = null;
|
||||
try
|
||||
{
|
||||
ep = new IPEndPoint(IPAddress.Parse(host), port);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_log.Debug("[HOME USERS SECURITY]: Exception in creating EndPoint");
|
||||
}
|
||||
|
||||
m_HomeUsersService.SetEndPoint(sessionID, ep);
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["result"] = "true";
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
response.Value = hash;
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
public XmlRpcResponse RemoveEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
string sessionID_str = (string)requestData["sessionID"];
|
||||
UUID sessionID = UUID.Zero;
|
||||
UUID.TryParse(sessionID_str, out sessionID);
|
||||
|
||||
m_HomeUsersService.RemoveEndPoint(sessionID);
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["result"] = "true";
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
response.Value = hash;
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -44,10 +44,12 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IGatekeeperService m_GatekeeperService;
|
||||
private IHypergridService m_HypergridService;
|
||||
|
||||
public HypergridHandlers(IGatekeeperService gatekeeper)
|
||||
public HypergridHandlers(IGatekeeperService gatekeeper, IHypergridService hyper)
|
||||
{
|
||||
m_GatekeeperService = gatekeeper;
|
||||
m_HypergridService = hyper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -80,6 +82,36 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A local region wants to establish a grid-wide hyperlink to another region
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public XmlRpcResponse LinkRegionByDescRequest(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
//string host = (string)requestData["host"];
|
||||
//string portstr = (string)requestData["port"];
|
||||
string descriptor = (string)requestData["region_desc"];
|
||||
|
||||
UUID regionID = UUID.Zero;
|
||||
string imageURL = string.Empty;
|
||||
ulong regionHandle = 0;
|
||||
string reason = string.Empty;
|
||||
|
||||
bool success = m_HypergridService.LinkRegion(descriptor, out regionID, out regionHandle, out imageURL, out reason);
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["result"] = success.ToString();
|
||||
hash["uuid"] = regionID.ToString();
|
||||
hash["handle"] = regionHandle.ToString();
|
||||
hash["region_image"] = imageURL;
|
||||
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
response.Value = hash;
|
||||
return response;
|
||||
}
|
||||
|
||||
public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
|
@ -111,5 +143,38 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
|
||||
}
|
||||
|
||||
public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
//string host = (string)requestData["host"];
|
||||
//string portstr = (string)requestData["port"];
|
||||
string userID_str = (string)requestData["userID"];
|
||||
UUID userID = UUID.Zero;
|
||||
UUID.TryParse(userID_str, out userID);
|
||||
|
||||
Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
|
||||
GridRegion regInfo = m_GatekeeperService.GetHomeRegion(userID, out position, out lookAt);
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
if (regInfo == null)
|
||||
hash["result"] = "false";
|
||||
else
|
||||
{
|
||||
hash["result"] = "true";
|
||||
hash["uuid"] = regInfo.RegionID.ToString();
|
||||
hash["x"] = regInfo.RegionLocX.ToString();
|
||||
hash["y"] = regInfo.RegionLocY.ToString();
|
||||
hash["region_name"] = regInfo.RegionName;
|
||||
hash["hostname"] = regInfo.ExternalHostName;
|
||||
hash["http_port"] = regInfo.HttpPort.ToString();
|
||||
hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
|
||||
hash["position"] = position.ToString();
|
||||
hash["lookAt"] = lookAt.ToString();
|
||||
}
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
response.Value = hash;
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
using OpenSim.Services.Interfaces;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
|
||||
using OpenMetaverse;
|
||||
using Nwc.XmlRpc;
|
||||
|
||||
using OpenSim.Services.Connectors.Simulation;
|
||||
|
||||
namespace OpenSim.Services.Connectors.Hypergrid
|
||||
{
|
||||
public class GatekeeperServiceConnector : SimulationServiceConnector
|
||||
{
|
||||
protected override string AgentPath()
|
||||
{
|
||||
return "/foreignagent/";
|
||||
}
|
||||
|
||||
protected override string ObjectPath()
|
||||
{
|
||||
return "/foreignobject/";
|
||||
}
|
||||
|
||||
public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt)
|
||||
{
|
||||
position = Vector3.UnitY; lookAt = Vector3.UnitY;
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["userID"] = userID.ToString();
|
||||
|
||||
IList paramList = new ArrayList();
|
||||
paramList.Add(hash);
|
||||
|
||||
XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList);
|
||||
string uri = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort + "/";
|
||||
XmlRpcResponse response = null;
|
||||
try
|
||||
{
|
||||
response = request.Send(uri, 10000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.IsFault)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
hash = (Hashtable)response.Value;
|
||||
//foreach (Object o in hash)
|
||||
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
|
||||
try
|
||||
{
|
||||
bool success = false;
|
||||
Boolean.TryParse((string)hash["result"], out success);
|
||||
if (success)
|
||||
{
|
||||
GridRegion region = new GridRegion();
|
||||
|
||||
UUID.TryParse((string)hash["uuid"], out region.RegionID);
|
||||
//m_log.Debug(">> HERE, uuid: " + region.RegionID);
|
||||
int n = 0;
|
||||
if (hash["x"] != null)
|
||||
{
|
||||
Int32.TryParse((string)hash["x"], out n);
|
||||
region.RegionLocX = n;
|
||||
//m_log.Debug(">> HERE, x: " + region.RegionLocX);
|
||||
}
|
||||
if (hash["y"] != null)
|
||||
{
|
||||
Int32.TryParse((string)hash["y"], out n);
|
||||
region.RegionLocY = n;
|
||||
//m_log.Debug(">> HERE, y: " + region.RegionLocY);
|
||||
}
|
||||
if (hash["region_name"] != null)
|
||||
{
|
||||
region.RegionName = (string)hash["region_name"];
|
||||
//m_log.Debug(">> HERE, name: " + region.RegionName);
|
||||
}
|
||||
if (hash["hostname"] != null)
|
||||
region.ExternalHostName = (string)hash["hostname"];
|
||||
if (hash["http_port"] != null)
|
||||
{
|
||||
uint p = 0;
|
||||
UInt32.TryParse((string)hash["http_port"], out p);
|
||||
region.HttpPort = p;
|
||||
}
|
||||
if (hash["internal_port"] != null)
|
||||
{
|
||||
int p = 0;
|
||||
Int32.TryParse((string)hash["internal_port"], out p);
|
||||
region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
|
||||
}
|
||||
if (hash["position"] != null)
|
||||
Vector3.TryParse((string)hash["position"], out position);
|
||||
if (hash["lookAt"] != null)
|
||||
Vector3.TryParse((string)hash["lookAt"], out lookAt);
|
||||
|
||||
// Successful return
|
||||
return region;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using Nwc.XmlRpc;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Services.Connectors.Hypergrid
|
||||
{
|
||||
public class HomeUsersSecurityServiceConnector : IHomeUsersSecurityService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
string m_ServerURL;
|
||||
public HomeUsersSecurityServiceConnector(string url)
|
||||
{
|
||||
m_ServerURL = url;
|
||||
}
|
||||
|
||||
public HomeUsersSecurityServiceConnector(IConfigSource config)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetEndPoint(UUID sessionID, IPEndPoint ep)
|
||||
{
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["sessionID"] = sessionID.ToString();
|
||||
hash["ep_addr"] = ep.Address.ToString();
|
||||
hash["ep_port"] = ep.Port.ToString();
|
||||
|
||||
Call("ep_set", hash);
|
||||
}
|
||||
|
||||
public void RemoveEndPoint(UUID sessionID)
|
||||
{
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["sessionID"] = sessionID.ToString();
|
||||
|
||||
Call("ep_remove", hash);
|
||||
}
|
||||
|
||||
public IPEndPoint GetEndPoint(UUID sessionID)
|
||||
{
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["sessionID"] = sessionID.ToString();
|
||||
|
||||
IList paramList = new ArrayList();
|
||||
paramList.Add(hash);
|
||||
|
||||
XmlRpcRequest request = new XmlRpcRequest("ep_get", paramList);
|
||||
//m_log.Debug("[HGrid]: Linking to " + uri);
|
||||
XmlRpcResponse response = null;
|
||||
try
|
||||
{
|
||||
response = request.Send(m_ServerURL, 10000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Debug("[HGrid]: Exception " + e.Message);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.IsFault)
|
||||
{
|
||||
m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
|
||||
return null;
|
||||
}
|
||||
|
||||
hash = (Hashtable)response.Value;
|
||||
//foreach (Object o in hash)
|
||||
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
|
||||
try
|
||||
{
|
||||
bool success = false;
|
||||
Boolean.TryParse((string)hash["result"], out success);
|
||||
if (success)
|
||||
{
|
||||
IPEndPoint ep = null;
|
||||
int port = 0;
|
||||
if (hash["ep_port"] != null)
|
||||
Int32.TryParse((string)hash["ep_port"], out port);
|
||||
if (hash["ep_addr"] != null)
|
||||
ep = new IPEndPoint(IPAddress.Parse((string)hash["ep_addr"]), port);
|
||||
|
||||
return ep;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Call(string method, Hashtable hash)
|
||||
{
|
||||
IList paramList = new ArrayList();
|
||||
paramList.Add(hash);
|
||||
|
||||
XmlRpcRequest request = new XmlRpcRequest(method, paramList);
|
||||
XmlRpcResponse response = null;
|
||||
try
|
||||
{
|
||||
response = request.Send(m_ServerURL, 10000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Debug("[HGrid]: Exception " + e.Message);
|
||||
return ;
|
||||
}
|
||||
|
||||
if (response.IsFault)
|
||||
{
|
||||
m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -41,22 +41,49 @@ using OpenMetaverse;
|
|||
using OpenMetaverse.Imaging;
|
||||
using log4net;
|
||||
using Nwc.XmlRpc;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Services.Connectors.Hypergrid
|
||||
{
|
||||
public class HypergridServiceConnector
|
||||
public class HypergridServiceConnector : IHypergridService
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IAssetService m_AssetService;
|
||||
private string m_ServerURL;
|
||||
|
||||
public HypergridServiceConnector() : this(null) { }
|
||||
public HypergridServiceConnector() { }
|
||||
|
||||
public HypergridServiceConnector(IAssetService assService)
|
||||
{
|
||||
m_AssetService = assService;
|
||||
}
|
||||
|
||||
public HypergridServiceConnector(IConfigSource source)
|
||||
{
|
||||
Initialise(source);
|
||||
}
|
||||
|
||||
public virtual void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig hgConfig = source.Configs["HypergridService"];
|
||||
if (hgConfig == null)
|
||||
{
|
||||
m_log.Error("[HYPERGRID CONNECTOR]: HypergridService missing from OpenSim.ini");
|
||||
throw new Exception("Hypergrid connector init error");
|
||||
}
|
||||
|
||||
string serviceURI = hgConfig.GetString("HypergridServerURI",
|
||||
String.Empty);
|
||||
|
||||
if (serviceURI == String.Empty)
|
||||
{
|
||||
m_log.Error("[HYPERGRID CONNECTOR]: No Server URI named in section HypergridService");
|
||||
throw new Exception("Hypergrid connector init error");
|
||||
}
|
||||
m_ServerURL = serviceURI;
|
||||
}
|
||||
|
||||
public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason)
|
||||
{
|
||||
regionID = UUID.Zero;
|
||||
|
@ -246,5 +273,82 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
#region From local regions to grid-wide hypergrid service
|
||||
|
||||
public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong realHandle, out string imageURL, out string reason)
|
||||
{
|
||||
regionID = UUID.Zero;
|
||||
imageURL = string.Empty;
|
||||
realHandle = 0;
|
||||
reason = string.Empty;
|
||||
|
||||
Hashtable hash = new Hashtable();
|
||||
hash["region_desc"] = regionDescriptor;
|
||||
|
||||
IList paramList = new ArrayList();
|
||||
paramList.Add(hash);
|
||||
|
||||
XmlRpcRequest request = new XmlRpcRequest("link_region_by_desc", paramList);
|
||||
XmlRpcResponse response = null;
|
||||
try
|
||||
{
|
||||
response = request.Send(m_ServerURL, 10000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Debug("[HGrid]: Exception " + e.Message);
|
||||
reason = "Error contacting remote server";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (response.IsFault)
|
||||
{
|
||||
reason = response.FaultString;
|
||||
m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
|
||||
return false;
|
||||
}
|
||||
|
||||
hash = (Hashtable)response.Value;
|
||||
//foreach (Object o in hash)
|
||||
// m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
|
||||
try
|
||||
{
|
||||
bool success = false;
|
||||
Boolean.TryParse((string)hash["result"], out success);
|
||||
if (success)
|
||||
{
|
||||
UUID.TryParse((string)hash["uuid"], out regionID);
|
||||
//m_log.Debug(">> HERE, uuid: " + uuid);
|
||||
if ((string)hash["handle"] != null)
|
||||
{
|
||||
realHandle = Convert.ToUInt64((string)hash["handle"]);
|
||||
//m_log.Debug(">> HERE, realHandle: " + realHandle);
|
||||
}
|
||||
if (hash["region_image"] != null)
|
||||
{
|
||||
imageURL = (string)hash["region_image"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
reason = "Error parsing return arguments";
|
||||
m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO !!!
|
||||
public GridRegion GetRegionByUUID(UUID regionID) { return null; }
|
||||
public GridRegion GetRegionByPosition(int x, int y) { return null; }
|
||||
public GridRegion GetRegionByName(string name) { return null; }
|
||||
public List<GridRegion> GetRegionsByName(string name) { return null; }
|
||||
public List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax) { return null; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
using OpenSim.Framework;
|
||||
|
@ -51,6 +52,7 @@ namespace OpenSim.Services.HypergridService
|
|||
IPresenceService m_PresenceService;
|
||||
IAuthenticationService m_AuthenticationService;
|
||||
IUserAccountService m_UserAccountService;
|
||||
IHomeUsersSecurityService m_HomeUsersSecurityService;
|
||||
ISimulationService m_SimulationService;
|
||||
|
||||
string m_AuthDll;
|
||||
|
@ -66,14 +68,15 @@ namespace OpenSim.Services.HypergridService
|
|||
throw new Exception(String.Format("No section GatekeeperService in config file"));
|
||||
|
||||
string accountService = serverConfig.GetString("UserAccountService", String.Empty);
|
||||
string homeUsersSecurityService = serverConfig.GetString("HomeUsersSecurityService", string.Empty);
|
||||
string gridService = serverConfig.GetString("GridService", String.Empty);
|
||||
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
|
||||
string simulationService = serverConfig.GetString("SimulationService", String.Empty);
|
||||
|
||||
m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty);
|
||||
|
||||
if (accountService == string.Empty || gridService == string.Empty ||
|
||||
presenceService == string.Empty || m_AuthDll == string.Empty)
|
||||
// These 3 are mandatory, the others aren't
|
||||
if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty)
|
||||
throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
|
||||
|
||||
string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString());
|
||||
|
@ -82,16 +85,20 @@ namespace OpenSim.Services.HypergridService
|
|||
m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true);
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
|
||||
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
|
||||
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
|
||||
|
||||
if (accountService != string.Empty)
|
||||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
|
||||
if (homeUsersSecurityService != string.Empty)
|
||||
m_HomeUsersSecurityService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(homeUsersSecurityService, args);
|
||||
|
||||
if (simService != null)
|
||||
m_SimulationService = simService;
|
||||
else if (simulationService != string.Empty)
|
||||
m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
|
||||
|
||||
if (m_UserAccountService == null || m_GridService == null ||
|
||||
m_PresenceService == null || m_SimulationService == null)
|
||||
if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
|
||||
throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
|
||||
|
||||
m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
|
||||
|
@ -164,6 +171,7 @@ namespace OpenSim.Services.HypergridService
|
|||
return region;
|
||||
}
|
||||
|
||||
#region Login Agent
|
||||
public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
|
@ -174,6 +182,9 @@ namespace OpenSim.Services.HypergridService
|
|||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to login foreign agent {0} {1} @ {2} ({3}) at destination {4}",
|
||||
aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName);
|
||||
|
||||
//
|
||||
// Authenticate the user
|
||||
//
|
||||
if (!Authenticate(aCircuit))
|
||||
{
|
||||
reason = "Unable to verify identity";
|
||||
|
@ -182,21 +193,39 @@ namespace OpenSim.Services.HypergridService
|
|||
}
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL);
|
||||
|
||||
//
|
||||
// Check for impersonations
|
||||
//
|
||||
UserAccount account = null;
|
||||
if (m_UserAccountService != null)
|
||||
{
|
||||
// Check to see if we have a local user with that UUID
|
||||
UserAccount account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID);
|
||||
account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID);
|
||||
if (account != null)
|
||||
{
|
||||
// No, sorry; go away
|
||||
reason = "User identifier not allowed on this grid";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has UUID of local user {3}. Refusing service.",
|
||||
aCircuit.firstname, aCircuit.lastname, aCircuit.AgentID);
|
||||
// Make sure this is the user coming home, and not a fake
|
||||
if (m_HomeUsersSecurityService != null)
|
||||
{
|
||||
Object ep = m_HomeUsersSecurityService.GetEndPoint(aCircuit.SessionID);
|
||||
if (ep == null)
|
||||
{
|
||||
// This is a fake, this session never left this grid
|
||||
reason = "Unauthorized";
|
||||
m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.",
|
||||
aCircuit.firstname, aCircuit.lastname);
|
||||
return false;
|
||||
|
||||
}
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: User ID ok");
|
||||
}
|
||||
}
|
||||
}
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok");
|
||||
|
||||
// May want to authorize
|
||||
|
||||
//
|
||||
// Login the presence
|
||||
//
|
||||
if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
|
||||
{
|
||||
reason = "Unable to login presence";
|
||||
|
@ -206,7 +235,9 @@ namespace OpenSim.Services.HypergridService
|
|||
}
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok");
|
||||
|
||||
//
|
||||
// Get the region
|
||||
//
|
||||
destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID);
|
||||
if (destination == null)
|
||||
{
|
||||
|
@ -215,9 +246,23 @@ namespace OpenSim.Services.HypergridService
|
|||
}
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: destination ok: {0}", destination.RegionName);
|
||||
|
||||
// Finally launch the agent at the destination
|
||||
//
|
||||
// Adjust the visible name
|
||||
//
|
||||
if (account != null)
|
||||
{
|
||||
aCircuit.firstname = account.FirstName;
|
||||
aCircuit.lastname = account.LastName;
|
||||
}
|
||||
if (account == null && !aCircuit.lastname.StartsWith("@"))
|
||||
{
|
||||
aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname;
|
||||
aCircuit.lastname = "@" + aCircuit.ServiceURLs["HomeURI"].ToString();
|
||||
}
|
||||
|
||||
//
|
||||
// Finally launch the agent at the destination
|
||||
//
|
||||
return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason);
|
||||
}
|
||||
|
||||
|
@ -250,5 +295,40 @@ namespace OpenSim.Services.HypergridService
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
|
||||
{
|
||||
position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;
|
||||
|
||||
m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID);
|
||||
|
||||
GridRegion home = null;
|
||||
PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() });
|
||||
if (presences != null && presences.Length > 0)
|
||||
{
|
||||
UUID homeID = presences[0].HomeRegionID;
|
||||
if (homeID != UUID.Zero)
|
||||
{
|
||||
home = m_GridService.GetRegionByUUID(m_ScopeID, homeID);
|
||||
position = presences[0].HomePosition;
|
||||
lookAt = presences[0].HomeLookAt;
|
||||
}
|
||||
if (home == null)
|
||||
{
|
||||
List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID);
|
||||
if (defs != null && defs.Count > 0)
|
||||
home = defs[0];
|
||||
}
|
||||
}
|
||||
|
||||
return home;
|
||||
}
|
||||
|
||||
#region Misc
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Services.HypergridService
|
||||
{
|
||||
/// <summary>
|
||||
/// This service is for HG1.5 only, to make up for the fact that clients don't
|
||||
/// keep any private information in themselves, and that their 'home service'
|
||||
/// needs to do it for them.
|
||||
/// Once we have better clients, this shouldn't be needed.
|
||||
/// </summary>
|
||||
public class HomeUsersSecurityService : IHomeUsersSecurityService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
//
|
||||
// This is a persistent storage wannabe for dealing with the
|
||||
// quirks of HG1.5. We don't really want to store this in a table.
|
||||
// But this is the necessary information for securing clients
|
||||
// coming home.
|
||||
//
|
||||
protected static Dictionary<UUID, IPEndPoint> m_ClientEndPoints = new Dictionary<UUID, IPEndPoint>();
|
||||
|
||||
public HomeUsersSecurityService(IConfigSource config)
|
||||
{
|
||||
m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
|
||||
}
|
||||
|
||||
public void SetEndPoint(UUID sessionID, IPEndPoint ep)
|
||||
{
|
||||
m_log.DebugFormat("[HOME USERS SECURITY]: Set EndPoint {0} for session {1}", ep.ToString(), sessionID);
|
||||
|
||||
lock (m_ClientEndPoints)
|
||||
m_ClientEndPoints[sessionID] = ep;
|
||||
}
|
||||
|
||||
public IPEndPoint GetEndPoint(UUID sessionID)
|
||||
{
|
||||
lock (m_ClientEndPoints)
|
||||
if (m_ClientEndPoints.ContainsKey(sessionID))
|
||||
{
|
||||
m_log.DebugFormat("[HOME USERS SECURITY]: Get EndPoint {0} for session {1}", m_ClientEndPoints[sessionID].ToString(), sessionID);
|
||||
return m_ClientEndPoints[sessionID];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void RemoveEndPoint(UUID sessionID)
|
||||
{
|
||||
m_log.DebugFormat("[HOME USERS SECURITY]: Remove EndPoint for session {0}", sessionID);
|
||||
lock (m_ClientEndPoints)
|
||||
if (m_ClientEndPoints.ContainsKey(sessionID))
|
||||
m_ClientEndPoints.Remove(sessionID);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ namespace OpenSim.Services.HypergridService
|
|||
private static HypergridService m_RootInstance = null;
|
||||
protected IConfigSource m_config;
|
||||
|
||||
protected IAuthenticationService m_AuthenticationService = null;
|
||||
protected IPresenceService m_PresenceService = null;
|
||||
protected IGridService m_GridService;
|
||||
protected IAssetService m_AssetService;
|
||||
protected HypergridServiceConnector m_HypergridConnector;
|
||||
|
@ -94,7 +94,7 @@ namespace OpenSim.Services.HypergridService
|
|||
if (gridConfig != null)
|
||||
{
|
||||
string gridService = gridConfig.GetString("GridService", string.Empty);
|
||||
string authService = gridConfig.GetString("AuthenticationService", String.Empty);
|
||||
string presenceService = gridConfig.GetString("PresenceService", String.Empty);
|
||||
string assetService = gridConfig.GetString("AssetService", string.Empty);
|
||||
|
||||
Object[] args = new Object[] { config };
|
||||
|
@ -104,8 +104,8 @@ namespace OpenSim.Services.HypergridService
|
|||
if (m_GridService == null)
|
||||
throw new Exception("HypergridService cannot function without a GridService");
|
||||
|
||||
if (authService != String.Empty)
|
||||
m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
|
||||
if (presenceService != String.Empty)
|
||||
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
|
||||
|
||||
if (assetService != string.Empty)
|
||||
m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using OpenSim.Framework;
|
||||
|
@ -39,5 +40,18 @@ namespace OpenSim.Services.Interfaces
|
|||
GridRegion GetHyperlinkRegion(UUID regionID);
|
||||
|
||||
bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason);
|
||||
|
||||
GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HG1.5 only
|
||||
/// </summary>
|
||||
public interface IHomeUsersSecurityService
|
||||
{
|
||||
void SetEndPoint(UUID sessionID, IPEndPoint ep);
|
||||
IPEndPoint GetEndPoint(UUID sessionID);
|
||||
void RemoveEndPoint(UUID sessionID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace OpenSim.Services.Interfaces
|
|||
GridRegion GetRegionByName(string name);
|
||||
List<GridRegion> GetRegionsByName(string name);
|
||||
List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.S
|
|||
; *
|
||||
[InventoryService]
|
||||
LocalServiceModule = "OpenSim.Services.InventoryService.dll:InventoryService"
|
||||
UserServerURI = "http://127.0.0.1:8002"
|
||||
SessionAuthentication = "false"
|
||||
StorageProvider = "OpenSim.Data.MySQL.dll"
|
||||
ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim123;"
|
||||
|
@ -58,10 +57,12 @@ ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.S
|
|||
Realm = "regions"
|
||||
; AllowDuplicateNames = "True"
|
||||
;; Next, we can specify properties of regions, including default and fallback regions
|
||||
;; The syntax is: Region_<RegioName> = "<flags>"
|
||||
;; The syntax is: Region_<RegionName> = "<flags>"
|
||||
;; or: Region_<RegionID> = "<flags>"
|
||||
;; where <flags> can be DefaultRegion, FallbackRegion, NoDirectLogin, Persistent, LockedOut,Reservation,NoMove,Authenticate
|
||||
;; For example:
|
||||
; Region_Welcome_Area = "DefaultRegion, FallbackRegion"
|
||||
; (replace spaces with underscore)
|
||||
|
||||
; * This is the configuration for the freeswitch server in grid mode
|
||||
[FreeswitchService]
|
||||
|
|
|
@ -17,18 +17,17 @@
|
|||
AvatarServices = "RemoteAvatarServicesConnector"
|
||||
NeighbourServices = "RemoteNeighbourServicesConnector"
|
||||
AuthenticationServices = "RemoteAuthenticationServicesConnector"
|
||||
AuthorizationServices = "LocalAuthorizationServicesConnector"
|
||||
PresenceServices = "RemotePresenceServicesConnector"
|
||||
UserAccountServices = "RemoteUserAccountServicesConnector"
|
||||
SimulationServices = "RemoteSimulationConnectorModule"
|
||||
EntityTransferModule = "BasicEntityTransferModule"
|
||||
EntityTransferModule = "HGEntityTransferModule"
|
||||
LandServiceInConnector = true
|
||||
NeighbourServiceInConnector = true
|
||||
HypergridServiceInConnector = true
|
||||
SimulationServiceInConnector = true
|
||||
LibraryModule = true
|
||||
InventoryServiceInConnector = false
|
||||
AssetServiceInConnector = false
|
||||
LLLoginServiceInConnector = false
|
||||
|
||||
[AssetService]
|
||||
LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector"
|
||||
|
@ -41,12 +40,12 @@
|
|||
[GridService]
|
||||
; for the HGGridServicesConnector to instantiate
|
||||
GridServiceConnectorModule = "OpenSim.Region.CoreModules.dll:RemoteGridServicesConnector"
|
||||
HypergridService = "OpenSim.Services.HypergridService.dll:HypergridService"
|
||||
; RemoteGridServicesConnector instantiates a LocalGridServicesConnector,
|
||||
; which in turn uses this
|
||||
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
|
||||
StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
|
||||
|
||||
[LibraryService]
|
||||
LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService"
|
||||
LibraryName = "OpenSim Library"
|
||||
DefaultLibrary = "./inventory/Libraries.xml"
|
||||
[HypergridService]
|
||||
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||
AssetService = "OpenSim.Services.AssetService.dll:AssetService"
|
||||
|
|
|
@ -82,6 +82,9 @@
|
|||
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||
AuthenticationService = "OpenSim.Services.Connectors.dll:AuthenticationServicesConnector"
|
||||
|
||||
[HGEntityTransferModule]
|
||||
HomeUsersSecurityService = "OpenSim.Services.HypergridService.dll:HomeUsersSecurityService"
|
||||
|
||||
[PresenceService]
|
||||
LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||
|
||||
|
|
Loading…
Reference in New Issue