diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 460 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 118 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | 2 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs (renamed from OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs) | 3 |
5 files changed, 372 insertions, 231 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; | |||
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Statistics; | 39 | using OpenSim.Framework.Statistics; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Services.Interfaces; | ||
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
42 | 43 | ||
43 | using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket; | 44 | using 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 fcc7a85..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. |
@@ -183,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
183 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | 181 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); |
184 | sp.Teleport(position); | 182 | sp.Teleport(position); |
185 | } | 183 | } |
186 | else | 184 | else // Another region possibly in another simulator |
187 | { | 185 | { |
188 | uint x = 0, y = 0; | 186 | uint x = 0, y = 0; |
189 | Utils.LongToUInts(regionHandle, out x, out y); | 187 | Utils.LongToUInts(regionHandle, out x, out y); |
@@ -191,15 +189,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
191 | 189 | ||
192 | if (reg != null) | 190 | if (reg != null) |
193 | { | 191 | { |
194 | m_log.DebugFormat( | ||
195 | "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", | ||
196 | position, reg.RegionName); | ||
197 | |||
198 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | ||
199 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); | ||
200 | uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); | ||
201 | uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); | ||
202 | |||
203 | GridRegion finalDestination = GetFinalDestination(reg); | 192 | GridRegion finalDestination = GetFinalDestination(reg); |
204 | if (finalDestination == null) | 193 | if (finalDestination == null) |
205 | { | 194 | { |
@@ -207,220 +196,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
207 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); | 196 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); |
208 | return; | 197 | return; |
209 | } | 198 | } |
210 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", finalDestination.RegionLocX, finalDestination.RegionLocY, finalDestination.RegionID); | 199 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", |
211 | ulong destinationHandle = finalDestination.RegionHandle; | 200 | finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID); |
212 | 201 | ||
213 | if (eq == null) | 202 | // |
214 | sp.ControllingClient.SendTeleportLocationStart(); | 203 | // This is it |
215 | 204 | // | |
216 | // Let's do DNS resolution only once in this process, please! | 205 | DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq); |
217 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, | 206 | // |
218 | // it's actually doing a lot of work. | 207 | // |
219 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; | 208 | // |
220 | if (endPoint.Address == null) | ||
221 | { | ||
222 | // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. | ||
223 | destRegionUp = false; | ||
224 | } | ||
225 | |||
226 | if (destRegionUp) | ||
227 | { | ||
228 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from | ||
229 | // both regions | ||
230 | if (sp.ParentID != (uint)0) | ||
231 | sp.StandUp(); | ||
232 | |||
233 | if (!sp.ValidateAttachments()) | ||
234 | { | ||
235 | sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); | ||
236 | return; | ||
237 | } | ||
238 | |||
239 | // the avatar.Close below will clear the child region list. We need this below for (possibly) | ||
240 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). | ||
241 | //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList()); | ||
242 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport | ||
243 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail | ||
244 | // once we reach here... | ||
245 | //avatar.Scene.RemoveCapsHandler(avatar.UUID); | ||
246 | |||
247 | string capsPath = String.Empty; | ||
248 | |||
249 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
250 | AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); | ||
251 | agentCircuit.startpos = position; | ||
252 | agentCircuit.child = true; | ||
253 | agentCircuit.Appearance = sp.Appearance; | ||
254 | if (currentAgentCircuit != null) | ||
255 | agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; | ||
256 | |||
257 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
258 | { | ||
259 | // brand new agent, let's create a new caps seed | ||
260 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
261 | } | ||
262 | |||
263 | string reason = String.Empty; | ||
264 | |||
265 | // Let's create an agent there if one doesn't exist yet. | ||
266 | if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason)) | ||
267 | { | ||
268 | sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", | ||
269 | reason)); | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | // OK, it got this agent. Let's close some child agents | ||
274 | sp.CloseChildAgents(newRegionX, newRegionY); | ||
275 | |||
276 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
277 | { | ||
278 | #region IP Translation for NAT | ||
279 | IClientIPEndpoint ipepClient; | ||
280 | if (sp.ClientView.TryGet(out ipepClient)) | ||
281 | { | ||
282 | capsPath | ||
283 | = "http://" | ||
284 | + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName) | ||
285 | + ":" | ||
286 | + finalDestination.HttpPort | ||
287 | + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | capsPath | ||
292 | = "http://" | ||
293 | + finalDestination.ExternalHostName | ||
294 | + ":" | ||
295 | + finalDestination.HttpPort | ||
296 | + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
297 | } | ||
298 | #endregion | ||
299 | |||
300 | if (eq != null) | ||
301 | { | ||
302 | #region IP Translation for NAT | ||
303 | // Uses ipepClient above | ||
304 | if (sp.ClientView.TryGet(out ipepClient)) | ||
305 | { | ||
306 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | ||
307 | } | ||
308 | #endregion | ||
309 | |||
310 | eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); | ||
311 | |||
312 | // ES makes the client send a UseCircuitCode message to the destination, | ||
313 | // which triggers a bunch of things there. | ||
314 | // So let's wait | ||
315 | Thread.Sleep(2000); | ||
316 | |||
317 | eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | ||
318 | |||
319 | } | ||
320 | else | ||
321 | { | ||
322 | sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); | ||
323 | } | ||
324 | } | ||
325 | else | ||
326 | { | ||
327 | agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); | ||
328 | capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort | ||
329 | + "/CAPS/" + agentCircuit.CapsPath + "0000/"; | ||
330 | } | ||
331 | |||
332 | // Expect avatar crossing is a heavy-duty function at the destination. | ||
333 | // That is where MakeRoot is called, which fetches appearance and inventory. | ||
334 | // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. | ||
335 | //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, | ||
336 | // position, false); | ||
337 | |||
338 | //{ | ||
339 | // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); | ||
340 | // // We should close that agent we just created over at destination... | ||
341 | // List<ulong> lst = new List<ulong>(); | ||
342 | // lst.Add(reg.RegionHandle); | ||
343 | // SendCloseChildAgentAsync(avatar.UUID, lst); | ||
344 | // return; | ||
345 | //} | ||
346 | |||
347 | SetInTransit(sp.UUID); | ||
348 | |||
349 | // Let's send a full update of the agent. This is a synchronous call. | ||
350 | AgentData agent = new AgentData(); | ||
351 | sp.CopyTo(agent); | ||
352 | agent.Position = position; | ||
353 | SetCallbackURL(agent, sp.Scene.RegionInfo); | ||
354 | |||
355 | UpdateAgent(reg, finalDestination, agent); | ||
356 | |||
357 | m_log.DebugFormat( | ||
358 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); | ||
359 | |||
360 | |||
361 | if (eq != null) | ||
362 | { | ||
363 | eq.TeleportFinishEvent(destinationHandle, 13, endPoint, | ||
364 | 0, teleportFlags, capsPath, sp.UUID); | ||
365 | } | ||
366 | else | ||
367 | { | ||
368 | sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, | ||
369 | teleportFlags, capsPath); | ||
370 | } | ||
371 | |||
372 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which | ||
373 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation | ||
374 | // that the client contacted the destination before we send the attachments and close things here. | ||
375 | if (!WaitForCallback(sp.UUID)) | ||
376 | { | ||
377 | // Client never contacted destination. Let's restore everything back | ||
378 | sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); | ||
379 | |||
380 | ResetFromTransit(sp.UUID); | ||
381 | |||
382 | // Yikes! We should just have a ref to scene here. | ||
383 | //sp.Scene.InformClientOfNeighbours(sp); | ||
384 | EnableChildAgents(sp); | ||
385 | |||
386 | // Finally, kill the agent we just created at the destination. | ||
387 | m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); | ||
388 | |||
389 | return; | ||
390 | } | ||
391 | |||
392 | KillEntity(sp.Scene, sp.LocalId); | ||
393 | |||
394 | sp.MakeChildAgent(); | ||
395 | |||
396 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it | ||
397 | CrossAttachmentsIntoNewRegion(finalDestination, sp, true); | ||
398 | |||
399 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | ||
400 | |||
401 | if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | ||
402 | { | ||
403 | Thread.Sleep(5000); | ||
404 | sp.Close(); | ||
405 | sp.Scene.IncomingCloseAgent(sp.UUID); | ||
406 | } | ||
407 | else | ||
408 | // now we have a child agent in this region. | ||
409 | sp.Reset(); | ||
410 | |||
411 | |||
412 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | ||
413 | if (sp.Scene.NeedSceneCacheClear(sp.UUID)) | ||
414 | { | ||
415 | m_log.DebugFormat( | ||
416 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", | ||
417 | sp.UUID); | ||
418 | } | ||
419 | } | ||
420 | else | ||
421 | { | ||
422 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | ||
423 | } | ||
424 | } | 209 | } |
425 | else | 210 | else |
426 | { | 211 | { |
@@ -450,7 +235,228 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
450 | } | 235 | } |
451 | } | 236 | } |
452 | 237 | ||
453 | protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) | 238 | protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) |
239 | { | ||
240 | m_log.DebugFormat( | ||
241 | "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}", | ||
242 | reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName); | ||
243 | |||
244 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | ||
245 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); | ||
246 | uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); | ||
247 | uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); | ||
248 | |||
249 | ulong destinationHandle = finalDestination.RegionHandle; | ||
250 | |||
251 | if (eq == null) | ||
252 | sp.ControllingClient.SendTeleportLocationStart(); | ||
253 | |||
254 | // Let's do DNS resolution only once in this process, please! | ||
255 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, | ||
256 | // it's actually doing a lot of work. | ||
257 | IPEndPoint endPoint = finalDestination.ExternalEndPoint; | ||
258 | if (endPoint.Address != null) | ||
259 | { | ||
260 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from | ||
261 | // both regions | ||
262 | if (sp.ParentID != (uint)0) | ||
263 | sp.StandUp(); | ||
264 | |||
265 | if (!sp.ValidateAttachments()) | ||
266 | { | ||
267 | sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); | ||
268 | return; | ||
269 | } | ||
270 | |||
271 | // the avatar.Close below will clear the child region list. We need this below for (possibly) | ||
272 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). | ||
273 | //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList()); | ||
274 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport | ||
275 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail | ||
276 | // once we reach here... | ||
277 | //avatar.Scene.RemoveCapsHandler(avatar.UUID); | ||
278 | |||
279 | string capsPath = String.Empty; | ||
280 | |||
281 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
282 | AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); | ||
283 | agentCircuit.startpos = position; | ||
284 | agentCircuit.child = true; | ||
285 | agentCircuit.Appearance = sp.Appearance; | ||
286 | if (currentAgentCircuit != null) | ||
287 | agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; | ||
288 | |||
289 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
290 | { | ||
291 | // brand new agent, let's create a new caps seed | ||
292 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
293 | } | ||
294 | |||
295 | string reason = String.Empty; | ||
296 | |||
297 | // Let's create an agent there if one doesn't exist yet. | ||
298 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason)) | ||
299 | { | ||
300 | sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", | ||
301 | reason)); | ||
302 | return; | ||
303 | } | ||
304 | |||
305 | // OK, it got this agent. Let's close some child agents | ||
306 | sp.CloseChildAgents(newRegionX, newRegionY); | ||
307 | |||
308 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
309 | { | ||
310 | #region IP Translation for NAT | ||
311 | IClientIPEndpoint ipepClient; | ||
312 | if (sp.ClientView.TryGet(out ipepClient)) | ||
313 | { | ||
314 | capsPath | ||
315 | = "http://" | ||
316 | + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName) | ||
317 | + ":" | ||
318 | + finalDestination.HttpPort | ||
319 | + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | capsPath | ||
324 | = "http://" | ||
325 | + finalDestination.ExternalHostName | ||
326 | + ":" | ||
327 | + finalDestination.HttpPort | ||
328 | + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
329 | } | ||
330 | #endregion | ||
331 | |||
332 | if (eq != null) | ||
333 | { | ||
334 | #region IP Translation for NAT | ||
335 | // Uses ipepClient above | ||
336 | if (sp.ClientView.TryGet(out ipepClient)) | ||
337 | { | ||
338 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | ||
339 | } | ||
340 | #endregion | ||
341 | |||
342 | eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); | ||
343 | |||
344 | // ES makes the client send a UseCircuitCode message to the destination, | ||
345 | // which triggers a bunch of things there. | ||
346 | // So let's wait | ||
347 | Thread.Sleep(2000); | ||
348 | |||
349 | eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | ||
350 | |||
351 | } | ||
352 | else | ||
353 | { | ||
354 | sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); | ||
355 | } | ||
356 | } | ||
357 | else | ||
358 | { | ||
359 | agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); | ||
360 | capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort | ||
361 | + "/CAPS/" + agentCircuit.CapsPath + "0000/"; | ||
362 | } | ||
363 | |||
364 | // Expect avatar crossing is a heavy-duty function at the destination. | ||
365 | // That is where MakeRoot is called, which fetches appearance and inventory. | ||
366 | // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. | ||
367 | //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, | ||
368 | // position, false); | ||
369 | |||
370 | //{ | ||
371 | // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); | ||
372 | // // We should close that agent we just created over at destination... | ||
373 | // List<ulong> lst = new List<ulong>(); | ||
374 | // lst.Add(reg.RegionHandle); | ||
375 | // SendCloseChildAgentAsync(avatar.UUID, lst); | ||
376 | // return; | ||
377 | //} | ||
378 | |||
379 | SetInTransit(sp.UUID); | ||
380 | |||
381 | // Let's send a full update of the agent. This is a synchronous call. | ||
382 | AgentData agent = new AgentData(); | ||
383 | sp.CopyTo(agent); | ||
384 | agent.Position = position; | ||
385 | SetCallbackURL(agent, sp.Scene.RegionInfo); | ||
386 | |||
387 | UpdateAgent(reg, finalDestination, agent); | ||
388 | |||
389 | m_log.DebugFormat( | ||
390 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); | ||
391 | |||
392 | |||
393 | if (eq != null) | ||
394 | { | ||
395 | eq.TeleportFinishEvent(destinationHandle, 13, endPoint, | ||
396 | 0, teleportFlags, capsPath, sp.UUID); | ||
397 | } | ||
398 | else | ||
399 | { | ||
400 | sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, | ||
401 | teleportFlags, capsPath); | ||
402 | } | ||
403 | |||
404 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which | ||
405 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation | ||
406 | // that the client contacted the destination before we send the attachments and close things here. | ||
407 | if (!WaitForCallback(sp.UUID)) | ||
408 | { | ||
409 | // Client never contacted destination. Let's restore everything back | ||
410 | sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); | ||
411 | |||
412 | ResetFromTransit(sp.UUID); | ||
413 | |||
414 | // Yikes! We should just have a ref to scene here. | ||
415 | //sp.Scene.InformClientOfNeighbours(sp); | ||
416 | EnableChildAgents(sp); | ||
417 | |||
418 | // Finally, kill the agent we just created at the destination. | ||
419 | m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); | ||
420 | |||
421 | return; | ||
422 | } | ||
423 | |||
424 | KillEntity(sp.Scene, sp.LocalId); | ||
425 | |||
426 | sp.MakeChildAgent(); | ||
427 | |||
428 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it | ||
429 | CrossAttachmentsIntoNewRegion(finalDestination, sp, true); | ||
430 | |||
431 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | ||
432 | |||
433 | if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | ||
434 | { | ||
435 | Thread.Sleep(5000); | ||
436 | sp.Close(); | ||
437 | sp.Scene.IncomingCloseAgent(sp.UUID); | ||
438 | } | ||
439 | else | ||
440 | // now we have a child agent in this region. | ||
441 | sp.Reset(); | ||
442 | |||
443 | |||
444 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | ||
445 | if (sp.Scene.NeedSceneCacheClear(sp.UUID)) | ||
446 | { | ||
447 | m_log.DebugFormat( | ||
448 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", | ||
449 | sp.UUID); | ||
450 | } | ||
451 | } | ||
452 | else | ||
453 | { | ||
454 | sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | ||
455 | } | ||
456 | } | ||
457 | |||
458 | |||
459 | protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) | ||
454 | { | 460 | { |
455 | return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); | 461 | return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); |
456 | } | 462 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 101aea0..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; | |||
34 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Connectors.Hypergrid; | 35 | using OpenSim.Services.Connectors.Hypergrid; |
36 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
37 | using OpenSim.Server.Base; | ||
37 | 38 | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 39 | using 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,19 +130,101 @@ 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 | ||
111 | return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); | 155 | return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); |
112 | } | 156 | } |
113 | 157 | ||
158 | public override void TeleportHome(UUID id, IClientAPI client) | ||
159 | { | ||
160 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); | ||
161 | |||
162 | // Let's find out if this is a foreign user or a local user | ||
163 | UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, id); | ||
164 | if (account != null) | ||
165 | { | ||
166 | // local grid user | ||
167 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); | ||
168 | base.TeleportHome(id, client); | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | // Foreign user wants to go home | ||
173 | // | ||
174 | AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); | ||
175 | if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI"))) | ||
176 | { | ||
177 | client.SendTeleportFailed("Your information has been lost"); | ||
178 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | GridRegion homeGatekeeper = MakeRegion(aCircuit); | ||
183 | if (homeGatekeeper == null) | ||
184 | { | ||
185 | client.SendTeleportFailed("Your information has been lost"); | ||
186 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed"); | ||
187 | return; | ||
188 | } | ||
189 | |||
190 | Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; | ||
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); | ||
212 | } | ||
114 | #endregion | 213 | #endregion |
214 | |||
215 | private GridRegion MakeRegion(AgentCircuitData aCircuit) | ||
216 | { | ||
217 | GridRegion region = new GridRegion(); | ||
218 | |||
219 | Uri uri = null; | ||
220 | if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri)) | ||
221 | return null; | ||
222 | |||
223 | region.ExternalHostName = uri.Host; | ||
224 | region.HttpPort = (uint)uri.Port; | ||
225 | region.RegionName = string.Empty; | ||
226 | region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); | ||
227 | return region; | ||
228 | } | ||
115 | } | 229 | } |
116 | } | 230 | } |
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; | |||
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | 43 | namespace 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 | ||