aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs456
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs49
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs1
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs33
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs119
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs38
-rw-r--r--OpenSim/Services/HypergridService/HypergridService.cs8
-rw-r--r--OpenSim/Services/Interfaces/IGatekeeperService.cs3
8 files changed, 478 insertions, 229 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index fcc7a85..e85f270 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
183 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); 183 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
184 sp.Teleport(position); 184 sp.Teleport(position);
185 } 185 }
186 else 186 else // Another region possibly in another simulator
187 { 187 {
188 uint x = 0, y = 0; 188 uint x = 0, y = 0;
189 Utils.LongToUInts(regionHandle, out x, out y); 189 Utils.LongToUInts(regionHandle, out x, out y);
@@ -191,15 +191,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
191 191
192 if (reg != null) 192 if (reg != null)
193 { 193 {
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); 194 GridRegion finalDestination = GetFinalDestination(reg);
204 if (finalDestination == null) 195 if (finalDestination == null)
205 { 196 {
@@ -207,220 +198,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
207 sp.ControllingClient.SendTeleportFailed("Problem at destination"); 198 sp.ControllingClient.SendTeleportFailed("Problem at destination");
208 return; 199 return;
209 } 200 }
210 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", finalDestination.RegionLocX, finalDestination.RegionLocY, finalDestination.RegionID); 201 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}",
211 ulong destinationHandle = finalDestination.RegionHandle; 202 finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID);
212 203
213 if (eq == null) 204 //
214 sp.ControllingClient.SendTeleportLocationStart(); 205 // This is it
215 206 //
216 // Let's do DNS resolution only once in this process, please! 207 DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq);
217 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, 208 //
218 // it's actually doing a lot of work. 209 //
219 IPEndPoint endPoint = finalDestination.ExternalEndPoint; 210 //
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 } 211 }
425 else 212 else
426 { 213 {
@@ -450,6 +237,227 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
450 } 237 }
451 } 238 }
452 239
240 protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
241 {
242 m_log.DebugFormat(
243 "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}",
244 position, reg.RegionName);
245
246 uint newRegionX = (uint)(reg.RegionHandle >> 40);
247 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
248 uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
249 uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
250
251 ulong destinationHandle = finalDestination.RegionHandle;
252
253 if (eq == null)
254 sp.ControllingClient.SendTeleportLocationStart();
255
256 // Let's do DNS resolution only once in this process, please!
257 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
258 // it's actually doing a lot of work.
259 IPEndPoint endPoint = finalDestination.ExternalEndPoint;
260 if (endPoint.Address != null)
261 {
262 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
263 // both regions
264 if (sp.ParentID != (uint)0)
265 sp.StandUp();
266
267 if (!sp.ValidateAttachments())
268 {
269 sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
270 return;
271 }
272
273 // the avatar.Close below will clear the child region list. We need this below for (possibly)
274 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
275 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
276 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
277 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
278 // once we reach here...
279 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
280
281 string capsPath = String.Empty;
282
283 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
284 AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
285 agentCircuit.startpos = position;
286 agentCircuit.child = true;
287 agentCircuit.Appearance = sp.Appearance;
288 if (currentAgentCircuit != null)
289 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
290
291 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
292 {
293 // brand new agent, let's create a new caps seed
294 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
295 }
296
297 string reason = String.Empty;
298
299 // Let's create an agent there if one doesn't exist yet.
300 if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason))
301 {
302 sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}",
303 reason));
304 return;
305 }
306
307 // OK, it got this agent. Let's close some child agents
308 sp.CloseChildAgents(newRegionX, newRegionY);
309
310 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
311 {
312 #region IP Translation for NAT
313 IClientIPEndpoint ipepClient;
314 if (sp.ClientView.TryGet(out ipepClient))
315 {
316 capsPath
317 = "http://"
318 + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName)
319 + ":"
320 + finalDestination.HttpPort
321 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
322 }
323 else
324 {
325 capsPath
326 = "http://"
327 + finalDestination.ExternalHostName
328 + ":"
329 + finalDestination.HttpPort
330 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
331 }
332 #endregion
333
334 if (eq != null)
335 {
336 #region IP Translation for NAT
337 // Uses ipepClient above
338 if (sp.ClientView.TryGet(out ipepClient))
339 {
340 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
341 }
342 #endregion
343
344 eq.EnableSimulator(destinationHandle, endPoint, sp.UUID);
345
346 // ES makes the client send a UseCircuitCode message to the destination,
347 // which triggers a bunch of things there.
348 // So let's wait
349 Thread.Sleep(2000);
350
351 eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
352
353 }
354 else
355 {
356 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
357 }
358 }
359 else
360 {
361 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
362 capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort
363 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
364 }
365
366 // Expect avatar crossing is a heavy-duty function at the destination.
367 // That is where MakeRoot is called, which fetches appearance and inventory.
368 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
369 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
370 // position, false);
371
372 //{
373 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
374 // // We should close that agent we just created over at destination...
375 // List<ulong> lst = new List<ulong>();
376 // lst.Add(reg.RegionHandle);
377 // SendCloseChildAgentAsync(avatar.UUID, lst);
378 // return;
379 //}
380
381 SetInTransit(sp.UUID);
382
383 // Let's send a full update of the agent. This is a synchronous call.
384 AgentData agent = new AgentData();
385 sp.CopyTo(agent);
386 agent.Position = position;
387 SetCallbackURL(agent, sp.Scene.RegionInfo);
388
389 UpdateAgent(reg, finalDestination, agent);
390
391 m_log.DebugFormat(
392 "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID);
393
394
395 if (eq != null)
396 {
397 eq.TeleportFinishEvent(destinationHandle, 13, endPoint,
398 0, teleportFlags, capsPath, sp.UUID);
399 }
400 else
401 {
402 sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4,
403 teleportFlags, capsPath);
404 }
405
406 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
407 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
408 // that the client contacted the destination before we send the attachments and close things here.
409 if (!WaitForCallback(sp.UUID))
410 {
411 // Client never contacted destination. Let's restore everything back
412 sp.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
413
414 ResetFromTransit(sp.UUID);
415
416 // Yikes! We should just have a ref to scene here.
417 //sp.Scene.InformClientOfNeighbours(sp);
418 EnableChildAgents(sp);
419
420 // Finally, kill the agent we just created at the destination.
421 m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID);
422
423 return;
424 }
425
426 KillEntity(sp.Scene, sp.LocalId);
427
428 sp.MakeChildAgent();
429
430 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
431 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
432
433 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
434
435 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
436 {
437 Thread.Sleep(5000);
438 sp.Close();
439 sp.Scene.IncomingCloseAgent(sp.UUID);
440 }
441 else
442 // now we have a child agent in this region.
443 sp.Reset();
444
445
446 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
447 if (sp.Scene.NeedSceneCacheClear(sp.UUID))
448 {
449 m_log.DebugFormat(
450 "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed",
451 sp.UUID);
452 }
453 }
454 else
455 {
456 sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
457 }
458 }
459
460
453 protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) 461 protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
454 { 462 {
455 return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); 463 return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 101aea0..0e6323b 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -111,6 +111,55 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
111 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 111 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
112 } 112 }
113 113
114 public override void TeleportHome(UUID id, IClientAPI client)
115 {
116 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
117
118 // Let's find out if this is a foreign user or a local user
119 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, id);
120 if (account != null)
121 {
122 // local grid user
123 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
124 base.TeleportHome(id, client);
125 return;
126 }
127
128 // Foreign user wants to go home
129 //
130 AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
131 if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI")))
132 {
133 client.SendTeleportFailed("Your information has been lost");
134 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
135 return;
136 }
137
138 GridRegion homeGatekeeper = MakeRegion(aCircuit);
139 if (homeGatekeeper == null)
140 {
141 client.SendTeleportFailed("Your information has been lost");
142 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed");
143 return;
144 }
145
146 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
147 GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt);
148 }
114 #endregion 149 #endregion
150
151 private GridRegion MakeRegion(AgentCircuitData aCircuit)
152 {
153 GridRegion region = new GridRegion();
154
155 Uri uri = null;
156 if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri))
157 return null;
158
159 region.ExternalHostName = uri.Host;
160 region.HttpPort = (uint)uri.Port;
161 region.RegionName = string.Empty;
162 return region;
163 }
115 } 164 }
116} 165}
diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
index c56ea3f..f03d33a 100644
--- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
@@ -63,6 +63,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
63 HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); 63 HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService);
64 server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); 64 server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false);
65 server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); 65 server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false);
66 server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false);
66 67
67 server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler); 68 server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler);
68 69
diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
index baafd7d..846d1c2 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
@@ -111,5 +111,38 @@ namespace OpenSim.Server.Handlers.Hypergrid
111 111
112 } 112 }
113 113
114 public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
115 {
116 Hashtable requestData = (Hashtable)request.Params[0];
117 //string host = (string)requestData["host"];
118 //string portstr = (string)requestData["port"];
119 string userID_str = (string)requestData["userID"];
120 UUID userID = UUID.Zero;
121 UUID.TryParse(userID_str, out userID);
122
123 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
124 GridRegion regInfo = m_GatekeeperService.GetHomeRegion(userID, out position, out lookAt);
125
126 Hashtable hash = new Hashtable();
127 if (regInfo == null)
128 hash["result"] = "false";
129 else
130 {
131 hash["result"] = "true";
132 hash["uuid"] = regInfo.RegionID.ToString();
133 hash["x"] = regInfo.RegionLocX.ToString();
134 hash["y"] = regInfo.RegionLocY.ToString();
135 hash["region_name"] = regInfo.RegionName;
136 hash["hostname"] = regInfo.ExternalHostName;
137 hash["http_port"] = regInfo.HttpPort.ToString();
138 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
139 hash["position"] = position.ToString();
140 hash["lookAt"] = lookAt.ToString();
141 }
142 XmlRpcResponse response = new XmlRpcResponse();
143 response.Value = hash;
144 return response;
145
146 }
114 } 147 }
115} 148}
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
new file mode 100644
index 0000000..a8d9292
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -0,0 +1,119 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5
6using OpenSim.Services.Interfaces;
7using GridRegion = OpenSim.Services.Interfaces.GridRegion;
8
9using OpenMetaverse;
10using Nwc.XmlRpc;
11
12using OpenSim.Services.Connectors.Simulation;
13
14namespace OpenSim.Services.Connectors.Hypergrid
15{
16 public class GatekeeperServiceConnector : SimulationServiceConnector
17 {
18 protected override string AgentPath()
19 {
20 return "/foreignagent/";
21 }
22
23 protected override string ObjectPath()
24 {
25 return "/foreignobject/";
26 }
27
28 public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt)
29 {
30 position = Vector3.UnitY; lookAt = Vector3.UnitY;
31
32 Hashtable hash = new Hashtable();
33 hash["userID"] = userID.ToString();
34
35 IList paramList = new ArrayList();
36 paramList.Add(hash);
37
38 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList);
39 string uri = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort + "/";
40 XmlRpcResponse response = null;
41 try
42 {
43 response = request.Send(uri, 10000);
44 }
45 catch (Exception e)
46 {
47 return null;
48 }
49
50 if (response.IsFault)
51 {
52 return null;
53 }
54
55 hash = (Hashtable)response.Value;
56 //foreach (Object o in hash)
57 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
58 try
59 {
60 bool success = false;
61 Boolean.TryParse((string)hash["result"], out success);
62 if (success)
63 {
64 GridRegion region = new GridRegion();
65
66 UUID.TryParse((string)hash["uuid"], out region.RegionID);
67 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
68 int n = 0;
69 if (hash["x"] != null)
70 {
71 Int32.TryParse((string)hash["x"], out n);
72 region.RegionLocX = n;
73 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
74 }
75 if (hash["y"] != null)
76 {
77 Int32.TryParse((string)hash["y"], out n);
78 region.RegionLocY = n;
79 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
80 }
81 if (hash["region_name"] != null)
82 {
83 region.RegionName = (string)hash["region_name"];
84 //m_log.Debug(">> HERE, name: " + region.RegionName);
85 }
86 if (hash["hostname"] != null)
87 region.ExternalHostName = (string)hash["hostname"];
88 if (hash["http_port"] != null)
89 {
90 uint p = 0;
91 UInt32.TryParse((string)hash["http_port"], out p);
92 region.HttpPort = p;
93 }
94 if (hash["internal_port"] != null)
95 {
96 int p = 0;
97 Int32.TryParse((string)hash["internal_port"], out p);
98 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
99 }
100 if (hash["position"] != null)
101 Vector3.TryParse((string)hash["position"], out position);
102 if (hash["lookAt"] != null)
103 Vector3.TryParse((string)hash["lookAt"], out lookAt);
104
105 // Successful return
106 return region;
107 }
108
109 }
110 catch (Exception e)
111 {
112 return null;
113 }
114
115 return null;
116
117 }
118 }
119}
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 72db93f..55d9ce1 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -164,6 +164,7 @@ namespace OpenSim.Services.HypergridService
164 return region; 164 return region;
165 } 165 }
166 166
167 #region Login Agent
167 public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) 168 public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason)
168 { 169 {
169 reason = string.Empty; 170 reason = string.Empty;
@@ -221,7 +222,7 @@ namespace OpenSim.Services.HypergridService
221 return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); 222 return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason);
222 } 223 }
223 224
224 protected bool Authenticate(AgentCircuitData aCircuit) 225 protected bool Authenticate(AgentCircuitData aCircuit)
225 { 226 {
226 string authURL = string.Empty; 227 string authURL = string.Empty;
227 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 228 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
@@ -250,5 +251,40 @@ namespace OpenSim.Services.HypergridService
250 251
251 return false; 252 return false;
252 } 253 }
254
255 #endregion
256
257 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
258 {
259 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;
260
261 m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID);
262
263 GridRegion home = null;
264 PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() });
265 if (presences != null && presences.Length > 0)
266 {
267 UUID homeID = presences[0].HomeRegionID;
268 if (homeID != UUID.Zero)
269 {
270 home = m_GridService.GetRegionByUUID(m_ScopeID, homeID);
271 position = presences[0].HomePosition;
272 lookAt = presences[0].HomeLookAt;
273 }
274 if (home == null)
275 {
276 List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID);
277 if (defs != null && defs.Count > 0)
278 home = defs[0];
279 }
280 }
281
282 return home;
283 }
284
285 #region Misc
286
287
288 #endregion
253 } 289 }
254} 290}
diff --git a/OpenSim/Services/HypergridService/HypergridService.cs b/OpenSim/Services/HypergridService/HypergridService.cs
index 734931d..ac0f5ac 100644
--- a/OpenSim/Services/HypergridService/HypergridService.cs
+++ b/OpenSim/Services/HypergridService/HypergridService.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Services.HypergridService
51 private static HypergridService m_RootInstance = null; 51 private static HypergridService m_RootInstance = null;
52 protected IConfigSource m_config; 52 protected IConfigSource m_config;
53 53
54 protected IAuthenticationService m_AuthenticationService = null; 54 protected IPresenceService m_PresenceService = null;
55 protected IGridService m_GridService; 55 protected IGridService m_GridService;
56 protected IAssetService m_AssetService; 56 protected IAssetService m_AssetService;
57 protected HypergridServiceConnector m_HypergridConnector; 57 protected HypergridServiceConnector m_HypergridConnector;
@@ -94,7 +94,7 @@ namespace OpenSim.Services.HypergridService
94 if (gridConfig != null) 94 if (gridConfig != null)
95 { 95 {
96 string gridService = gridConfig.GetString("GridService", string.Empty); 96 string gridService = gridConfig.GetString("GridService", string.Empty);
97 string authService = gridConfig.GetString("AuthenticationService", String.Empty); 97 string presenceService = gridConfig.GetString("PresenceService", String.Empty);
98 string assetService = gridConfig.GetString("AssetService", string.Empty); 98 string assetService = gridConfig.GetString("AssetService", string.Empty);
99 99
100 Object[] args = new Object[] { config }; 100 Object[] args = new Object[] { config };
@@ -104,8 +104,8 @@ namespace OpenSim.Services.HypergridService
104 if (m_GridService == null) 104 if (m_GridService == null)
105 throw new Exception("HypergridService cannot function without a GridService"); 105 throw new Exception("HypergridService cannot function without a GridService");
106 106
107 if (authService != String.Empty) 107 if (presenceService != String.Empty)
108 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 108 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
109 109
110 if (assetService != string.Empty) 110 if (assetService != string.Empty)
111 m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args); 111 m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args);
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs
index d41df75..59e0f82 100644
--- a/OpenSim/Services/Interfaces/IGatekeeperService.cs
+++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs
@@ -39,5 +39,8 @@ namespace OpenSim.Services.Interfaces
39 GridRegion GetHyperlinkRegion(UUID regionID); 39 GridRegion GetHyperlinkRegion(UUID regionID);
40 40
41 bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); 41 bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason);
42
43 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
44
42 } 45 }
43} 46}