aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2010-01-18 16:34:23 -0800
committerDiva Canto2010-01-18 16:34:23 -0800
commit3d536944153d4931cf891d6a788a47484f3e6f4d (patch)
tree53802c5f051e8fbb089aeed02e0b9de760fabd8a /OpenSim
parent* Added missing GatekeeperServiceConnector (diff)
downloadopensim-SC-3d536944153d4931cf891d6a788a47484f3e6f4d.zip
opensim-SC-3d536944153d4931cf891d6a788a47484f3e6f4d.tar.gz
opensim-SC-3d536944153d4931cf891d6a788a47484f3e6f4d.tar.bz2
opensim-SC-3d536944153d4931cf891d6a788a47484f3e6f4d.tar.xz
Go Home works. With security!!
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs20
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs69
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs)3
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs4
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs122
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs132
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs53
-rw-r--r--OpenSim/Services/HypergridService/HomeUsersSecurityService.cs67
-rw-r--r--OpenSim/Services/Interfaces/IGatekeeperService.cs11
-rw-r--r--OpenSim/Services/Interfaces/IHypergridService.cs1
12 files changed, 468 insertions, 26 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 3c4fa72..ffd2546 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -38,6 +38,7 @@ using OpenMetaverse.Packets;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Statistics; 39using OpenSim.Framework.Statistics;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Services.Interfaces;
41using OpenMetaverse; 42using OpenMetaverse;
42 43
43using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket; 44using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket;
@@ -900,6 +901,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
900 901
901 if (!m_scene.TryGetClient(agentID, out existingClient)) 902 if (!m_scene.TryGetClient(agentID, out existingClient))
902 { 903 {
904 IHomeUsersSecurityService security = m_scene.RequestModuleInterface<IHomeUsersSecurityService>();
905 if (security != null)
906 {
907 IPEndPoint ep = security.GetEndPoint(sessionID);
908 if (ep != null && ep.ToString() != remoteEndPoint.ToString())
909 {
910 // uh-oh, this is fishy
911 m_log.WarnFormat("[LLUDPSERVER]: Agent {0} with session {1} connecting with unidentified end point. Refusing service.", agentID, sessionID);
912 m_log.WarnFormat("[LLUDPSERVER]: EP was {0}, now is {1}", ep.ToString(), remoteEndPoint.ToString());
913 return;
914 }
915 else if (ep != null)
916 {
917 // ok, you're home, welcome back
918 m_log.InfoFormat("LLUDPSERVER]: Agent {0} is coming back to this grid", agentID);
919 security.RemoveEndPoint(sessionID);
920 }
921 }
922
903 // Create the LLClientView 923 // Create the LLClientView
904 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); 924 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
905 client.OnLogout += LogoutHandler; 925 client.OnLogout += LogoutHandler;
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
134 if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) 134 if (!sp.Scene.Permissions.CanTeleport(sp.UUID))
135 return; 135 return;
136 136
137 bool destRegionUp = true;
138
139 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); 137 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
140 138
141 // Reset animations; the viewer does that in teleports. 139 // Reset animations; the viewer does that in teleports.
@@ -240,8 +238,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
240 protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) 238 protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
241 { 239 {
242 m_log.DebugFormat( 240 m_log.DebugFormat(
243 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", 241 "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}",
244 position, reg.RegionName); 242 reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName);
245 243
246 uint newRegionX = (uint)(reg.RegionHandle >> 40); 244 uint newRegionX = (uint)(reg.RegionHandle >> 40);
247 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); 245 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
@@ -297,7 +295,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
297 string reason = String.Empty; 295 string reason = String.Empty;
298 296
299 // Let's create an agent there if one doesn't exist yet. 297 // Let's create an agent there if one doesn't exist yet.
300 if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason)) 298 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason))
301 { 299 {
302 sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", 300 sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}",
303 reason)); 301 reason));
@@ -458,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
458 } 456 }
459 457
460 458
461 protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) 459 protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
462 { 460 {
463 return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); 461 return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
464 } 462 }
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;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid; 35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base;
37 38
38using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
@@ -59,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
59 } 60 }
60 61
61 private GatekeeperServiceConnector m_GatekeeperConnector; 62 private GatekeeperServiceConnector m_GatekeeperConnector;
63 private IHomeUsersSecurityService m_Security;
62 64
63 #region ISharedRegionModule 65 #region ISharedRegionModule
64 66
@@ -77,12 +79,42 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
77 { 79 {
78 m_agentsInTransit = new List<UUID>(); 80 m_agentsInTransit = new List<UUID>();
79 m_GatekeeperConnector = new GatekeeperServiceConnector(); 81 m_GatekeeperConnector = new GatekeeperServiceConnector();
82
83 IConfig config = source.Configs["HGEntityTransferModule"];
84 if (config != null)
85 {
86 string dll = config.GetString("HomeUsersSecurityService", string.Empty);
87 if (dll != string.Empty)
88 {
89 Object[] args = new Object[] { source };
90 m_Security = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(dll, args);
91 if (m_Security == null)
92 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Unable to load Home Users Security service");
93 else
94 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Home Users Security service loaded");
95 }
96 }
97
80 m_Enabled = true; 98 m_Enabled = true;
81 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); 99 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
82 } 100 }
83 } 101 }
84 } 102 }
85 103
104 public override void AddRegion(Scene scene)
105 {
106 base.AddRegion(scene);
107 if (m_Enabled)
108 scene.RegisterModuleInterface<IHomeUsersSecurityService>(m_Security);
109 }
110
111 public override void RemoveRegion(Scene scene)
112 {
113 base.AddRegion(scene);
114 if (m_Enabled)
115 scene.UnregisterModuleInterface<IHomeUsersSecurityService>(m_Security);
116 }
117
86 118
87 #endregion 119 #endregion
88 120
@@ -98,13 +130,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
98 return true; 130 return true;
99 } 131 }
100 132
101 protected override bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) 133 protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
102 { 134 {
103 reason = string.Empty; 135 reason = string.Empty;
104 if (reg.RegionLocX != finalDestination.RegionLocX && reg.RegionLocY != finalDestination.RegionLocY) 136 if (reg.RegionLocX != finalDestination.RegionLocX || reg.RegionLocY != finalDestination.RegionLocY)
105 { 137 {
106 // this user is going to another grid 138 // this user is going to another grid
107 reg.RegionName = finalDestination.RegionName; 139 reg.RegionName = finalDestination.RegionName;
140 reg.RegionID = finalDestination.RegionID;
141 reg.RegionLocX = finalDestination.RegionLocX;
142 reg.RegionLocY = finalDestination.RegionLocY;
143
144 // Log their session and remote endpoint in the home users security service
145 IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface<IHomeUsersSecurityService>();
146 if (security != null)
147 security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint);
148
149 // Log them out of this grid
150 sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
151
108 return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 152 return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
109 } 153 }
110 154
@@ -145,6 +189,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
145 189
146 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; 190 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
147 GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); 191 GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt);
192 if (finalDestination == null)
193 {
194 client.SendTeleportFailed("Your home region could not be found");
195 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
196 return;
197 }
198
199 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);
200 if (sp == null)
201 {
202 client.SendTeleportFailed("Internal error");
203 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
204 return;
205 }
206
207 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}",
208 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
209
210 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
211 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
148 } 212 }
149 #endregion 213 #endregion
150 214
@@ -159,6 +223,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
159 region.ExternalHostName = uri.Host; 223 region.ExternalHostName = uri.Host;
160 region.HttpPort = (uint)uri.Port; 224 region.HttpPort = (uint)uri.Port;
161 region.RegionName = string.Empty; 225 region.RegionName = string.Empty;
226 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
162 return region; 227 return region;
163 } 228 }
164 } 229 }
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index c61198d..0e3739a 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -62,7 +62,7 @@
62 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> 62 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
63 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> 63 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" />
64 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ 64 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
65 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \ 65 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid.HypergridServiceInConnectorModule" /> \
66 <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \ 66 <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \
67 <RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \ 67 <RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \
68 <RegionModule id="GridInfoServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.GridInfoServiceInConnectorModule" /> \ 68 <RegionModule id="GridInfoServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.GridInfoServiceInConnectorModule" /> \
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
index 6ec0fcf..6e6946c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
@@ -40,7 +40,7 @@ using OpenSim.Server.Handlers.Hypergrid;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42 42
43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid 43namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid
44{ 44{
45 public class HypergridServiceInConnectorModule : ISharedRegionModule 45 public class HypergridServiceInConnectorModule : ISharedRegionModule
46 { 46 {
@@ -119,6 +119,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
119 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); 119 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
120 m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); 120 m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService);
121 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); 121 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
122 scene.RegisterModuleInterface<IGatekeeperService>(m_HypergridHandler.GateKeeper);
122 } 123 }
123 } 124 }
124 125
diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
index f03d33a..15b29d2 100644
--- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
@@ -46,6 +46,10 @@ namespace OpenSim.Server.Handlers.Hypergrid
46 MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private IGatekeeperService m_GatekeeperService; 48 private IGatekeeperService m_GatekeeperService;
49 public IGatekeeperService GateKeeper
50 {
51 get { return m_GatekeeperService; }
52 }
49 53
50 public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : 54 public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) :
51 base(config, server, String.Empty) 55 base(config, server, String.Empty)
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs
new file mode 100644
index 0000000..5379784
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs
@@ -0,0 +1,122 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Reflection;
6
7using Nini.Config;
8using OpenSim.Framework;
9using OpenSim.Server.Base;
10using OpenSim.Services.Interfaces;
11using OpenSim.Framework.Servers.HttpServer;
12using OpenSim.Server.Handlers.Base;
13
14using log4net;
15using Nwc.XmlRpc;
16using OpenMetaverse;
17
18namespace OpenSim.Server.Handlers.Hypergrid
19{
20 public class HomeUsersSecurityServerConnector : ServiceConnector
21 {
22 private static readonly ILog m_log =
23 LogManager.GetLogger(
24 MethodBase.GetCurrentMethod().DeclaringType);
25
26 private IHomeUsersSecurityService m_HomeUsersService;
27
28 public HomeUsersSecurityServerConnector(IConfigSource config, IHttpServer server) :
29 base(config, server, String.Empty)
30 {
31 IConfig gridConfig = config.Configs["HomeUsersSecurityService"];
32 if (gridConfig != null)
33 {
34 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
35 Object[] args = new Object[] { config };
36 m_HomeUsersService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(serviceDll, args);
37 }
38 if (m_HomeUsersService == null)
39 throw new Exception("HomeUsersSecurity server connector cannot proceed because of missing service");
40
41 server.AddXmlRPCHandler("ep_get", GetEndPoint, false);
42 server.AddXmlRPCHandler("ep_set", SetEndPoint, false);
43 server.AddXmlRPCHandler("ep_remove", RemoveEndPoint, false);
44
45 }
46
47 public XmlRpcResponse GetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
48 {
49 Hashtable requestData = (Hashtable)request.Params[0];
50 //string host = (string)requestData["host"];
51 //string portstr = (string)requestData["port"];
52 string sessionID_str = (string)requestData["sessionID"];
53 UUID sessionID = UUID.Zero;
54 UUID.TryParse(sessionID_str, out sessionID);
55
56 IPEndPoint ep = m_HomeUsersService.GetEndPoint(sessionID);
57
58 Hashtable hash = new Hashtable();
59 if (ep == null)
60 hash["result"] = "false";
61 else
62 {
63 hash["result"] = "true";
64 hash["ep_addr"] = ep.Address.ToString();
65 hash["ep_port"] = ep.Port.ToString();
66 }
67 XmlRpcResponse response = new XmlRpcResponse();
68 response.Value = hash;
69 return response;
70
71 }
72
73 public XmlRpcResponse SetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
74 {
75 Hashtable requestData = (Hashtable)request.Params[0];
76 string host = (string)requestData["ep_addr"];
77 string portstr = (string)requestData["ep_port"];
78 string sessionID_str = (string)requestData["sessionID"];
79 UUID sessionID = UUID.Zero;
80 UUID.TryParse(sessionID_str, out sessionID);
81 int port = 0;
82 Int32.TryParse(portstr, out port);
83
84 IPEndPoint ep = null;
85 try
86 {
87 ep = new IPEndPoint(IPAddress.Parse(host), port);
88 }
89 catch
90 {
91 m_log.Debug("[HOME USERS SECURITY]: Exception in creating EndPoint");
92 }
93
94 m_HomeUsersService.SetEndPoint(sessionID, ep);
95
96 Hashtable hash = new Hashtable();
97 hash["result"] = "true";
98 XmlRpcResponse response = new XmlRpcResponse();
99 response.Value = hash;
100 return response;
101
102 }
103
104 public XmlRpcResponse RemoveEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
105 {
106 Hashtable requestData = (Hashtable)request.Params[0];
107 string sessionID_str = (string)requestData["sessionID"];
108 UUID sessionID = UUID.Zero;
109 UUID.TryParse(sessionID_str, out sessionID);
110
111 m_HomeUsersService.RemoveEndPoint(sessionID);
112
113 Hashtable hash = new Hashtable();
114 hash["result"] = "true";
115 XmlRpcResponse response = new XmlRpcResponse();
116 response.Value = hash;
117 return response;
118
119 }
120
121 }
122}
diff --git a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
new file mode 100644
index 0000000..150690b
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
@@ -0,0 +1,132 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Reflection;
6
7using OpenSim.Services.Interfaces;
8
9using OpenMetaverse;
10using log4net;
11using Nwc.XmlRpc;
12using Nini.Config;
13
14namespace OpenSim.Services.Connectors.Hypergrid
15{
16 public class HomeUsersSecurityServiceConnector : IHomeUsersSecurityService
17 {
18 private static readonly ILog m_log =
19 LogManager.GetLogger(
20 MethodBase.GetCurrentMethod().DeclaringType);
21
22 string m_ServerURL;
23 public HomeUsersSecurityServiceConnector(string url)
24 {
25 m_ServerURL = url;
26 }
27
28 public HomeUsersSecurityServiceConnector(IConfigSource config)
29 {
30 }
31
32 public void SetEndPoint(UUID sessionID, IPEndPoint ep)
33 {
34 Hashtable hash = new Hashtable();
35 hash["sessionID"] = sessionID.ToString();
36 hash["ep_addr"] = ep.Address.ToString();
37 hash["ep_port"] = ep.Port.ToString();
38
39 Call("ep_set", hash);
40 }
41
42 public void RemoveEndPoint(UUID sessionID)
43 {
44 Hashtable hash = new Hashtable();
45 hash["sessionID"] = sessionID.ToString();
46
47 Call("ep_remove", hash);
48 }
49
50 public IPEndPoint GetEndPoint(UUID sessionID)
51 {
52 Hashtable hash = new Hashtable();
53 hash["sessionID"] = sessionID.ToString();
54
55 IList paramList = new ArrayList();
56 paramList.Add(hash);
57
58 XmlRpcRequest request = new XmlRpcRequest("ep_get", paramList);
59 //m_log.Debug("[HGrid]: Linking to " + uri);
60 XmlRpcResponse response = null;
61 try
62 {
63 response = request.Send(m_ServerURL, 10000);
64 }
65 catch (Exception e)
66 {
67 m_log.Debug("[HGrid]: Exception " + e.Message);
68 return null;
69 }
70
71 if (response.IsFault)
72 {
73 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
74 return null;
75 }
76
77 hash = (Hashtable)response.Value;
78 //foreach (Object o in hash)
79 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
80 try
81 {
82 bool success = false;
83 Boolean.TryParse((string)hash["result"], out success);
84 if (success)
85 {
86 IPEndPoint ep = null;
87 int port = 0;
88 if (hash["ep_port"] != null)
89 Int32.TryParse((string)hash["ep_port"], out port);
90 if (hash["ep_addr"] != null)
91 ep = new IPEndPoint(IPAddress.Parse((string)hash["ep_addr"]), port);
92
93 return ep;
94 }
95
96 }
97 catch (Exception e)
98 {
99 m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace);
100 return null;
101 }
102
103 return null;
104 }
105
106 private void Call(string method, Hashtable hash)
107 {
108 IList paramList = new ArrayList();
109 paramList.Add(hash);
110
111 XmlRpcRequest request = new XmlRpcRequest(method, paramList);
112 XmlRpcResponse response = null;
113 try
114 {
115 response = request.Send(m_ServerURL, 10000);
116 }
117 catch (Exception e)
118 {
119 m_log.Debug("[HGrid]: Exception " + e.Message);
120 return ;
121 }
122
123 if (response.IsFault)
124 {
125 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
126 return ;
127 }
128
129 }
130
131 }
132}
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 55d9ce1..169cfa3 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
30using System.Reflection; 31using System.Reflection;
31 32
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -51,6 +52,7 @@ namespace OpenSim.Services.HypergridService
51 IPresenceService m_PresenceService; 52 IPresenceService m_PresenceService;
52 IAuthenticationService m_AuthenticationService; 53 IAuthenticationService m_AuthenticationService;
53 IUserAccountService m_UserAccountService; 54 IUserAccountService m_UserAccountService;
55 IHomeUsersSecurityService m_HomeUsersSecurityService;
54 ISimulationService m_SimulationService; 56 ISimulationService m_SimulationService;
55 57
56 string m_AuthDll; 58 string m_AuthDll;
@@ -66,14 +68,15 @@ namespace OpenSim.Services.HypergridService
66 throw new Exception(String.Format("No section GatekeeperService in config file")); 68 throw new Exception(String.Format("No section GatekeeperService in config file"));
67 69
68 string accountService = serverConfig.GetString("UserAccountService", String.Empty); 70 string accountService = serverConfig.GetString("UserAccountService", String.Empty);
71 string homeUsersSecurityService = serverConfig.GetString("HomeUsersSecurityService", string.Empty);
69 string gridService = serverConfig.GetString("GridService", String.Empty); 72 string gridService = serverConfig.GetString("GridService", String.Empty);
70 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 73 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
71 string simulationService = serverConfig.GetString("SimulationService", String.Empty); 74 string simulationService = serverConfig.GetString("SimulationService", String.Empty);
72 75
73 m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); 76 m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty);
74 77
75 if (accountService == string.Empty || gridService == string.Empty || 78 // These 3 are mandatory, the others aren't
76 presenceService == string.Empty || m_AuthDll == string.Empty) 79 if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty)
77 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); 80 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
78 81
79 string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString()); 82 string scope = serverConfig.GetString("ScopeID", UUID.Zero.ToString());
@@ -82,16 +85,20 @@ namespace OpenSim.Services.HypergridService
82 m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true); 85 m_AllowTeleportsToAnyRegion = serverConfig.GetBoolean("AllowTeleportsToAnyRegion", true);
83 86
84 Object[] args = new Object[] { config }; 87 Object[] args = new Object[] { config };
85 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
86 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 88 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
87 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 89 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
90
91 if (accountService != string.Empty)
92 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
93 if (homeUsersSecurityService != string.Empty)
94 m_HomeUsersSecurityService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(homeUsersSecurityService, args);
95
88 if (simService != null) 96 if (simService != null)
89 m_SimulationService = simService; 97 m_SimulationService = simService;
90 else if (simulationService != string.Empty) 98 else if (simulationService != string.Empty)
91 m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); 99 m_SimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
92 100
93 if (m_UserAccountService == null || m_GridService == null || 101 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
94 m_PresenceService == null || m_SimulationService == null)
95 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 102 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
96 103
97 m_log.Debug("[GATEKEEPER SERVICE]: Starting..."); 104 m_log.Debug("[GATEKEEPER SERVICE]: Starting...");
@@ -183,17 +190,31 @@ namespace OpenSim.Services.HypergridService
183 } 190 }
184 m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL); 191 m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL);
185 192
186 // Check to see if we have a local user with that UUID 193 //if (m_UserAccountService != null && m_HomeUsersSecurityService != null)
187 UserAccount account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); 194 //{
188 if (account != null) 195 // // Check to see if we have a local user with that UUID
189 { 196 // UserAccount account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID);
190 // No, sorry; go away 197
191 reason = "User identifier not allowed on this grid"; 198 // // See if that user went out of this home grid
192 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has UUID of local user {3}. Refusing service.", 199 // IPEndPoint ep = m_HomeUsersSecurityService.GetEndPoint(aCircuit.AgentID);
193 aCircuit.firstname, aCircuit.lastname, aCircuit.AgentID); 200
194 return false; 201 // if (account != null)
195 } 202 // {
196 m_log.DebugFormat("[GATEKEEPER SERVICE]: User ID ok"); 203 // if ((ep == null) || // there's no memory of this agent going out
204 // (ep != null && (ep.Address != aCircuit.ClientEndPoint.Address || ep.Port != aCircuit.ClientEndPoint.Port))) // fake agent
205 // {
206 // // No, sorry; go away
207 // reason = "User identifier not allowed on this grid";
208 // m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has UUID of local user {2}. Refusing service.",
209 // aCircuit.firstname, aCircuit.lastname, aCircuit.AgentID);
210 // return false;
211 // }
212 // else
213 // {
214 // }
215 // }
216 // m_log.DebugFormat("[GATEKEEPER SERVICE]: User ID ok");
217 //}
197 218
198 // May want to authorize 219 // May want to authorize
199 220
diff --git a/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs b/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs
new file mode 100644
index 0000000..a7adfc1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs
@@ -0,0 +1,67 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Reflection;
5
6using OpenSim.Services.Interfaces;
7
8using OpenMetaverse;
9using log4net;
10using Nini.Config;
11
12namespace OpenSim.Services.HypergridService
13{
14 /// <summary>
15 /// This service is for HG1.5 only, to make up for the fact that clients don't
16 /// keep any private information in themselves, and that their 'home service'
17 /// needs to do it for them.
18 /// Once we have better clients, this shouldn't be needed.
19 /// </summary>
20 public class HomeUsersSecurityService : IHomeUsersSecurityService
21 {
22 private static readonly ILog m_log =
23 LogManager.GetLogger(
24 MethodBase.GetCurrentMethod().DeclaringType);
25
26 //
27 // This is a persistent storage wannabe for dealing with the
28 // quirks of HG1.5. We don't really want to store this in a table.
29 // But this is the necessary information for securing clients
30 // coming home.
31 //
32 protected static Dictionary<UUID, IPEndPoint> m_ClientEndPoints = new Dictionary<UUID, IPEndPoint>();
33
34 public HomeUsersSecurityService(IConfigSource config)
35 {
36 m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
37 }
38
39 public void SetEndPoint(UUID sessionID, IPEndPoint ep)
40 {
41 m_log.DebugFormat("[HOME USERS SECURITY]: Set EndPoint {0} for session {1}", ep.ToString(), sessionID);
42
43 lock (m_ClientEndPoints)
44 m_ClientEndPoints[sessionID] = ep;
45 }
46
47 public IPEndPoint GetEndPoint(UUID sessionID)
48 {
49 lock (m_ClientEndPoints)
50 if (m_ClientEndPoints.ContainsKey(sessionID))
51 {
52 m_log.DebugFormat("[HOME USERS SECURITY]: Get EndPoint {0} for session {1}", m_ClientEndPoints[sessionID].ToString(), sessionID);
53 return m_ClientEndPoints[sessionID];
54 }
55
56 return null;
57 }
58
59 public void RemoveEndPoint(UUID sessionID)
60 {
61 m_log.DebugFormat("[HOME USERS SECURITY]: Remove EndPoint for session {0}", sessionID);
62 lock (m_ClientEndPoints)
63 if (m_ClientEndPoints.ContainsKey(sessionID))
64 m_ClientEndPoints.Remove(sessionID);
65 }
66 }
67}
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs
index 59e0f82..5b5c9d1 100644
--- a/OpenSim/Services/Interfaces/IGatekeeperService.cs
+++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Net;
29using System.Collections.Generic; 30using System.Collections.Generic;
30 31
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -43,4 +44,14 @@ namespace OpenSim.Services.Interfaces
43 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); 44 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
44 45
45 } 46 }
47
48 /// <summary>
49 /// HG1.5 only
50 /// </summary>
51 public interface IHomeUsersSecurityService
52 {
53 void SetEndPoint(UUID sessionID, IPEndPoint ep);
54 IPEndPoint GetEndPoint(UUID sessionID);
55 void RemoveEndPoint(UUID sessionID);
56 }
46} 57}
diff --git a/OpenSim/Services/Interfaces/IHypergridService.cs b/OpenSim/Services/Interfaces/IHypergridService.cs
index dd3c053..86ef1b4 100644
--- a/OpenSim/Services/Interfaces/IHypergridService.cs
+++ b/OpenSim/Services/Interfaces/IHypergridService.cs
@@ -43,6 +43,7 @@ namespace OpenSim.Services.Interfaces
43 GridRegion GetRegionByName(string name); 43 GridRegion GetRegionByName(string name);
44 List<GridRegion> GetRegionsByName(string name); 44 List<GridRegion> GetRegionsByName(string name);
45 List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax); 45 List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax);
46
46 } 47 }
47 48
48} 49}