aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-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.cs112
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs33
6 files changed, 108 insertions, 76 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index ffd2546..3c4fa72 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -38,7 +38,6 @@ 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;
42using OpenMetaverse; 41using OpenMetaverse;
43 42
44using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket; 43using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket;
@@ -901,25 +900,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
901 900
902 if (!m_scene.TryGetClient(agentID, out existingClient)) 901 if (!m_scene.TryGetClient(agentID, out existingClient))
903 { 902 {
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
923 // Create the LLClientView 903 // Create the LLClientView
924 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); 904 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
925 client.OnLogout += LogoutHandler; 905 client.OnLogout += LogoutHandler;
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index ed8c0fd..44f1191 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -237,9 +237,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
237 237
238 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)
239 { 239 {
240 if (reg == null || finalDestination == null)
241 {
242 sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
243 return;
244 }
245
240 m_log.DebugFormat( 246 m_log.DebugFormat(
241 "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}", 247 "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}",
242 reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName); 248 reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position);
243 249
244 uint newRegionX = (uint)(reg.RegionHandle >> 40); 250 uint newRegionX = (uint)(reg.RegionHandle >> 40);
245 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); 251 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 4d5844c..85c2742 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -44,14 +44,13 @@ using Nini.Config;
44 44
45namespace OpenSim.Region.CoreModules.Framework.EntityTransfer 45namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
46{ 46{
47 public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule 47 public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private bool m_Initialized = false; 51 private bool m_Initialized = false;
52 52
53 private GatekeeperServiceConnector m_GatekeeperConnector; 53 private GatekeeperServiceConnector m_GatekeeperConnector;
54 private IHomeUsersSecurityService m_Security;
55 54
56 #region ISharedRegionModule 55 #region ISharedRegionModule
57 56
@@ -69,21 +68,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
69 if (name == Name) 68 if (name == Name)
70 { 69 {
71 m_agentsInTransit = new List<UUID>(); 70 m_agentsInTransit = new List<UUID>();
72
73 IConfig config = source.Configs["HGEntityTransferModule"];
74 if (config != null)
75 {
76 string dll = config.GetString("HomeUsersSecurityService", string.Empty);
77 if (dll != string.Empty)
78 {
79 Object[] args = new Object[] { source };
80 m_Security = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(dll, args);
81 if (m_Security == null)
82 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Unable to load Home Users Security service");
83 else
84 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Home Users Security service loaded");
85 }
86 }
87 71
88 m_Enabled = true; 72 m_Enabled = true;
89 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); 73 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
@@ -95,7 +79,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
95 { 79 {
96 base.AddRegion(scene); 80 base.AddRegion(scene);
97 if (m_Enabled) 81 if (m_Enabled)
98 scene.RegisterModuleInterface<IHomeUsersSecurityService>(m_Security); 82 {
83 scene.RegisterModuleInterface<IUserAgentVerificationModule>(this);
84 scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(OnNewClient);
85 }
86 }
87
88 void OnNewClient(IClientAPI client)
89 {
90 client.OnLogout += new Action<IClientAPI>(OnLogout);
99 } 91 }
100 92
101 public override void RegionLoaded(Scene scene) 93 public override void RegionLoaded(Scene scene)
@@ -113,13 +105,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
113 { 105 {
114 base.AddRegion(scene); 106 base.AddRegion(scene);
115 if (m_Enabled) 107 if (m_Enabled)
116 scene.UnregisterModuleInterface<IHomeUsersSecurityService>(m_Security); 108 {
109 scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this);
110 }
117 } 111 }
118 112
119 113
120 #endregion 114 #endregion
121 115
122 #region HG overrides 116 #region HG overrides of IEntiryTransferModule
123 117
124 protected override GridRegion GetFinalDestination(GridRegion region) 118 protected override GridRegion GetFinalDestination(GridRegion region)
125 { 119 {
@@ -142,26 +136,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
142 { 136 {
143 reason = string.Empty; 137 reason = string.Empty;
144 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
145 if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) 139 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
146 { 140 {
147 // this user is going to another grid 141 // this user is going to another grid
148 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination 142 string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
149 GridRegion region = new GridRegion(reg); 143 IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver);
150 region.RegionName = finalDestination.RegionName; 144 bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
151 region.RegionID = finalDestination.RegionID; 145 if (success)
152 region.RegionLocX = finalDestination.RegionLocX; 146 // Log them out of this grid
153 region.RegionLocY = finalDestination.RegionLocY; 147 m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
154 148
155 // Log their session and remote endpoint in the home users security service 149 return success;
156 IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface<IHomeUsersSecurityService>();
157 if (security != null)
158 security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint);
159
160 //string token = sp.Scene.AuthenticationService.MakeToken(sp.UUID, reg.ExternalHostName + ":" + reg.HttpPort, 30);
161 // Log them out of this grid
162 sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
163
164 return m_GatekeeperConnector.CreateAgent(region, agentCircuit, teleportFlags, out reason);
165 } 150 }
166 151
167 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 152 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
@@ -184,23 +169,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
184 // Foreign user wants to go home 169 // Foreign user wants to go home
185 // 170 //
186 AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); 171 AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
187 if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI"))) 172 if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI")))
188 { 173 {
189 client.SendTeleportFailed("Your information has been lost"); 174 client.SendTeleportFailed("Your information has been lost");
190 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); 175 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
191 return; 176 return;
192 } 177 }
193 178
194 GridRegion homeGatekeeper = MakeRegion(aCircuit); 179 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
195 if (homeGatekeeper == null)
196 {
197 client.SendTeleportFailed("Your information has been lost");
198 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed");
199 return;
200 }
201
202 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; 180 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
203 GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); 181 GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt);
204 if (finalDestination == null) 182 if (finalDestination == null)
205 { 183 {
206 client.SendTeleportFailed("Your home region could not be found"); 184 client.SendTeleportFailed("Your home region could not be found");
@@ -216,20 +194,52 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
216 return; 194 return;
217 } 195 }
218 196
219 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", 197 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
198 GridRegion homeGatekeeper = MakeRegion(aCircuit);
199
200 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}",
220 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); 201 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
221 202
222 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
223 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); 203 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
224 } 204 }
225 #endregion 205 #endregion
226 206
207 #region IUserAgentVerificationModule
208
209 public bool VerifyClient(AgentCircuitData aCircuit, string token)
210 {
211 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
212 {
213 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
214 IUserAgentService security = new UserAgentServiceConnector(url);
215 return security.VerifyClient(aCircuit.SessionID, token);
216 }
217
218 return false;
219 }
220
221 void OnLogout(IClientAPI obj)
222 {
223 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
224
225 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
226 {
227 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
228 IUserAgentService security = new UserAgentServiceConnector(url);
229 security.LogoutAgent(obj.AgentId, obj.SessionId);
230 }
231
232 }
233
234 #endregion
235
227 private GridRegion MakeRegion(AgentCircuitData aCircuit) 236 private GridRegion MakeRegion(AgentCircuitData aCircuit)
228 { 237 {
229 GridRegion region = new GridRegion(); 238 GridRegion region = new GridRegion();
230 239
231 Uri uri = null; 240 Uri uri = null;
232 if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri)) 241 if (!aCircuit.ServiceURLs.ContainsKey("HomeURI") ||
242 (aCircuit.ServiceURLs.ContainsKey("HomeURI") && !Uri.TryCreate(aCircuit.ServiceURLs["HomeURI"].ToString(), UriKind.Absolute, out uri)))
233 return null; 243 return null;
234 244
235 region.ExternalHostName = uri.Host; 245 region.ExternalHostName = uri.Host;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
index 6e6946c..c737f8b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
@@ -115,11 +115,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid
115 115
116 m_log.Info("[HypergridService]: Starting..."); 116 m_log.Info("[HypergridService]: Starting...");
117 117
118// Object[] args = new Object[] { m_Config, MainServer.Instance };
119 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); 118 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
120 m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); 119 m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService);
121 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
122 scene.RegisterModuleInterface<IGatekeeperService>(m_HypergridHandler.GateKeeper); 120 scene.RegisterModuleInterface<IGatekeeperService>(m_HypergridHandler.GateKeeper);
121
122 new UserAgentServerConnector(m_Config, MainServer.Instance);
123 } 123 }
124 } 124 }
125 125
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 73c68f1..e8738c4 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -52,4 +52,9 @@ namespace OpenSim.Region.Framework.Interfaces
52 52
53 void Cross(SceneObjectGroup sog, Vector3 position, bool silent); 53 void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
54 } 54 }
55
56 public interface IUserAgentVerificationModule
57 {
58 bool VerifyClient(AgentCircuitData aCircuit, string token);
59 }
55} 60}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 3cfb236..f800d5f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2416,6 +2416,37 @@ namespace OpenSim.Region.Framework.Scenes
2416 { 2416 {
2417 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2417 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2418 2418
2419 // Do the verification here
2420 System.Net.EndPoint ep = client.GetClientEP();
2421 if (aCircuit != null)
2422 {
2423 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2424 {
2425 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2426 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2427 if (userVerification != null)
2428 {
2429 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2430 {
2431 // uh-oh, this is fishy
2432 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2433 client.AgentId, client.SessionId, ep.ToString());
2434 try
2435 {
2436 client.Close();
2437 }
2438 catch (Exception e)
2439 {
2440 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2441 }
2442 return;
2443 }
2444 else
2445 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2446 }
2447 }
2448 }
2449
2419 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2450 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2420 /* 2451 /*
2421 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2452 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}",
@@ -2426,7 +2457,6 @@ namespace OpenSim.Region.Framework.Scenes
2426 */ 2457 */
2427 2458
2428 //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2459 //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
2429
2430 ScenePresence sp = CreateAndAddScenePresence(client); 2460 ScenePresence sp = CreateAndAddScenePresence(client);
2431 sp.Appearance = aCircuit.Appearance; 2461 sp.Appearance = aCircuit.Appearance;
2432 2462
@@ -3243,6 +3273,7 @@ namespace OpenSim.Region.Framework.Scenes
3243 } 3273 }
3244 } 3274 }
3245 3275
3276 agent.teleportFlags = teleportFlags;
3246 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3277 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3247 3278
3248 return true; 3279 return true;