aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Simulation/AgentHandlers.cs')
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs110
1 files changed, 76 insertions, 34 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 98c5312..c52a1ab 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -120,6 +120,10 @@ namespace OpenSim.Server.Handlers.Simulation
120 120
121 protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID agentID, UUID regionID) 121 protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID agentID, UUID regionID)
122 { 122 {
123 Culture.SetCurrentCulture();
124
125 EntityTransferContext ctx = new EntityTransferContext();
126
123 if (m_SimulationService == null) 127 if (m_SimulationService == null)
124 { 128 {
125 m_log.Debug("[AGENT HANDLER]: Agent QUERY called. Harmless but useless."); 129 m_log.Debug("[AGENT HANDLER]: Agent QUERY called. Harmless but useless.");
@@ -155,6 +159,9 @@ namespace OpenSim.Server.Handlers.Simulation
155 theirVersion = float.Parse(parts[1]); 159 theirVersion = float.Parse(parts[1]);
156 } 160 }
157 161
162 if (args.ContainsKey("context"))
163 ctx.Unpack((OSDMap)args["context"]);
164
158 // Decode the new versioning data 165 // Decode the new versioning data
159 float minVersionRequired = 0f; 166 float minVersionRequired = 0f;
160 float maxVersionRequired = 0f; 167 float maxVersionRequired = 0f;
@@ -183,7 +190,7 @@ namespace OpenSim.Server.Handlers.Simulation
183 { 190 {
184 // If there is no version in the packet at all we're looking at 0.6 or 191 // If there is no version in the packet at all we're looking at 0.6 or
185 // even more ancient. Refuse it. 192 // even more ancient. Refuse it.
186 if(theirVersion == 0f) 193 if(theirVersion == 0f)
187 { 194 {
188 resp["success"] = OSD.FromBoolean(false); 195 resp["success"] = OSD.FromBoolean(false);
189 resp["reason"] = OSD.FromString("Your region is running a old version of opensim no longer supported. Consider updating it"); 196 resp["reason"] = OSD.FromString("Your region is running a old version of opensim no longer supported. Consider updating it");
@@ -192,8 +199,8 @@ namespace OpenSim.Server.Handlers.Simulation
192 } 199 }
193 200
194 version = theirVersion; 201 version = theirVersion;
195 202
196 if (version < VersionInfo.SimulationServiceVersionAcceptedMin || 203 if (version < VersionInfo.SimulationServiceVersionAcceptedMin ||
197 version > VersionInfo.SimulationServiceVersionAcceptedMax ) 204 version > VersionInfo.SimulationServiceVersionAcceptedMax )
198 { 205 {
199 resp["success"] = OSD.FromBoolean(false); 206 resp["success"] = OSD.FromBoolean(false);
@@ -245,7 +252,6 @@ namespace OpenSim.Server.Handlers.Simulation
245 252
246 string reason; 253 string reason;
247 // We're sending the version numbers down to the local connector to do the varregion check. 254 // We're sending the version numbers down to the local connector to do the varregion check.
248 EntityTransferContext ctx = new EntityTransferContext();
249 ctx.InboundVersion = inboundVersion; 255 ctx.InboundVersion = inboundVersion;
250 ctx.OutboundVersion = outboundVersion; 256 ctx.OutboundVersion = outboundVersion;
251 if (minVersionProvided == 0f) 257 if (minVersionProvided == 0f)
@@ -255,6 +261,8 @@ namespace OpenSim.Server.Handlers.Simulation
255 } 261 }
256 262
257 bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, features, ctx, out reason); 263 bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, features, ctx, out reason);
264 m_log.DebugFormat("[AGENT HANDLER]: QueryAccess returned {0} ({1}). Version={2}, {3}/{4}",
265 result, reason, version, inboundVersion, outboundVersion);
258 266
259 resp["success"] = OSD.FromBoolean(result); 267 resp["success"] = OSD.FromBoolean(result);
260 resp["reason"] = OSD.FromString(reason); 268 resp["reason"] = OSD.FromString(reason);
@@ -262,12 +270,11 @@ namespace OpenSim.Server.Handlers.Simulation
262 resp["version"] = OSD.FromString(legacyVersion); 270 resp["version"] = OSD.FromString(legacyVersion);
263 resp["negotiated_inbound_version"] = OSD.FromReal(inboundVersion); 271 resp["negotiated_inbound_version"] = OSD.FromReal(inboundVersion);
264 resp["negotiated_outbound_version"] = OSD.FromReal(outboundVersion); 272 resp["negotiated_outbound_version"] = OSD.FromReal(outboundVersion);
265 resp["variable_wearables_count_supported"] = OSD.FromBoolean(true);
266 273
267 OSDArray featuresWanted = new OSDArray(); 274 OSDArray featuresWanted = new OSDArray();
268 foreach (UUID feature in features) 275 foreach (UUID feature in features)
269 featuresWanted.Add(OSD.FromString(feature.ToString())); 276 featuresWanted.Add(OSD.FromString(feature.ToString()));
270 277
271 resp["features"] = featuresWanted; 278 resp["features"] = featuresWanted;
272 279
273 // We must preserve defaults here, otherwise a false "success" will not be put into the JSON map! 280 // We must preserve defaults here, otherwise a false "success" will not be put into the JSON map!
@@ -407,6 +414,8 @@ namespace OpenSim.Server.Handlers.Simulation
407 414
408 protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) 415 protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
409 { 416 {
417 EntityTransferContext ctx = new EntityTransferContext();
418
410 OSDMap args = Utils.GetOSDMap((string)request["body"]); 419 OSDMap args = Utils.GetOSDMap((string)request["body"]);
411 if (args == null) 420 if (args == null)
412 { 421 {
@@ -415,6 +424,9 @@ namespace OpenSim.Server.Handlers.Simulation
415 return; 424 return;
416 } 425 }
417 426
427 if (args.ContainsKey("context"))
428 ctx.Unpack((OSDMap)args["context"]);
429
418 AgentDestinationData data = CreateAgentDestinationData(); 430 AgentDestinationData data = CreateAgentDestinationData();
419 UnpackData(args, data, request); 431 UnpackData(args, data, request);
420 432
@@ -448,7 +460,7 @@ namespace OpenSim.Server.Handlers.Simulation
448 source.RegionLocY = Int32.Parse(args["source_y"].AsString()); 460 source.RegionLocY = Int32.Parse(args["source_y"].AsString());
449 source.RegionName = args["source_name"].AsString(); 461 source.RegionName = args["source_name"].AsString();
450 source.RegionID = UUID.Parse(args["source_uuid"].AsString()); 462 source.RegionID = UUID.Parse(args["source_uuid"].AsString());
451 463
452 if (args.ContainsKey("source_server_uri")) 464 if (args.ContainsKey("source_server_uri"))
453 source.RawServerURI = args["source_server_uri"].AsString(); 465 source.RawServerURI = args["source_server_uri"].AsString();
454 else 466 else
@@ -461,7 +473,8 @@ namespace OpenSim.Server.Handlers.Simulation
461 // This is the meaning of POST agent 473 // This is the meaning of POST agent
462 //m_regionClient.AdjustUserInformation(aCircuit); 474 //m_regionClient.AdjustUserInformation(aCircuit);
463 //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); 475 //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);
464 bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason); 476
477 bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, ctx, out reason);
465 478
466 resp["reason"] = OSD.FromString(reason); 479 resp["reason"] = OSD.FromString(reason);
467 resp["success"] = OSD.FromBoolean(result); 480 resp["success"] = OSD.FromBoolean(result);
@@ -504,41 +517,62 @@ namespace OpenSim.Server.Handlers.Simulation
504 517
505 protected string GetCallerIP(Hashtable request) 518 protected string GetCallerIP(Hashtable request)
506 { 519 {
507 if (!m_Proxy) 520 if (request.ContainsKey("headers"))
508 return Util.GetCallerIP(request); 521 {
509 522 Hashtable headers = (Hashtable)request["headers"];
510 // We're behind a proxy
511 Hashtable headers = (Hashtable)request["headers"];
512 523
513 //// DEBUG 524 //// DEBUG
514 //foreach (object o in headers.Keys) 525 //foreach (object o in headers.Keys)
515 // m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString())); 526 // m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString()));
516 527
517 string xff = "X-Forwarded-For"; 528 string xff = "X-Forwarded-For";
518 if (headers.ContainsKey(xff.ToLower())) 529 if (!headers.ContainsKey(xff))
519 xff = xff.ToLower(); 530 xff = xff.ToLower();
520 531
521 if (!headers.ContainsKey(xff) || headers[xff] == null) 532 if (!headers.ContainsKey(xff) || headers[xff] == null)
522 { 533 {
523 m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); 534// m_log.WarnFormat("[AGENT HANDLER]: No XFF header");
524 return Util.GetCallerIP(request); 535 return Util.GetCallerIP(request);
525 } 536 }
526
527 m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]);
528 537
529 IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]); 538// m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]);
530 if (ep != null)
531 return ep.Address.ToString();
532 539
540 IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]);
541 if (ep != null)
542 return ep.Address.ToString();
543 }
533 // Oops 544 // Oops
534 return Util.GetCallerIP(request); 545 return Util.GetCallerIP(request);
535 } 546 }
536 547
537 // subclasses can override this 548 // subclasses can override this
538 protected virtual bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination, 549 protected virtual bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination,
539 AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason) 550 AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, EntityTransferContext ctx, out string reason)
540 { 551 {
541 return m_SimulationService.CreateAgent(source, destination, aCircuit, teleportFlags, out reason); 552 reason = String.Empty;
553 // The data and protocols are already defined so this is just a dummy to satisfy the interface
554 // TODO: make this end-to-end
555
556/* this needs to be sync
557 if ((teleportFlags & (uint)TeleportFlags.ViaLogin) == 0)
558 {
559 Util.FireAndForget(x =>
560 {
561 string r;
562 m_SimulationService.CreateAgent(source, destination, aCircuit, teleportFlags, ctx, out r);
563 m_log.DebugFormat("[AGENT HANDLER]: ASYNC CreateAgent {0}", r);
564 });
565
566 return true;
567 }
568 else
569 {
570*/
571
572 bool ret = m_SimulationService.CreateAgent(source, destination, aCircuit, teleportFlags, ctx, out reason);
573// m_log.DebugFormat("[AGENT HANDLER]: SYNC CreateAgent {0} {1}", ret.ToString(), reason);
574 return ret;
575// }
542 } 576 }
543 } 577 }
544 578
@@ -639,6 +673,9 @@ namespace OpenSim.Server.Handlers.Simulation
639 673
640 protected void DoAgentPut(Hashtable request, Hashtable responsedata) 674 protected void DoAgentPut(Hashtable request, Hashtable responsedata)
641 { 675 {
676 // TODO: Encode the ENtityTransferContext
677 EntityTransferContext ctx = new EntityTransferContext();
678
642 OSDMap args = Utils.GetOSDMap((string)request["body"]); 679 OSDMap args = Utils.GetOSDMap((string)request["body"]);
643 if (args == null) 680 if (args == null)
644 { 681 {
@@ -659,6 +696,8 @@ namespace OpenSim.Server.Handlers.Simulation
659 UUID.TryParse(args["destination_uuid"].AsString(), out uuid); 696 UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
660 if (args.ContainsKey("destination_name") && args["destination_name"] != null) 697 if (args.ContainsKey("destination_name") && args["destination_name"] != null)
661 regionname = args["destination_name"].ToString(); 698 regionname = args["destination_name"].ToString();
699 if (args.ContainsKey("context"))
700 ctx.Unpack((OSDMap)args["context"]);
662 701
663 GridRegion destination = new GridRegion(); 702 GridRegion destination = new GridRegion();
664 destination.RegionID = uuid; 703 destination.RegionID = uuid;
@@ -681,7 +720,7 @@ namespace OpenSim.Server.Handlers.Simulation
681 AgentData agent = new AgentData(); 720 AgentData agent = new AgentData();
682 try 721 try
683 { 722 {
684 agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID)); 723 agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID), ctx);
685 } 724 }
686 catch (Exception ex) 725 catch (Exception ex)
687 { 726 {
@@ -700,7 +739,7 @@ namespace OpenSim.Server.Handlers.Simulation
700 AgentPosition agent = new AgentPosition(); 739 AgentPosition agent = new AgentPosition();
701 try 740 try
702 { 741 {
703 agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID)); 742 agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID), ctx);
704 } 743 }
705 catch (Exception ex) 744 catch (Exception ex)
706 { 745 {
@@ -721,7 +760,10 @@ namespace OpenSim.Server.Handlers.Simulation
721 // subclasses can override this 760 // subclasses can override this
722 protected virtual bool UpdateAgent(GridRegion destination, AgentData agent) 761 protected virtual bool UpdateAgent(GridRegion destination, AgentData agent)
723 { 762 {
724 return m_SimulationService.UpdateAgent(destination, agent); 763 // The data and protocols are already defined so this is just a dummy to satisfy the interface
764 // TODO: make this end-to-end
765 EntityTransferContext ctx = new EntityTransferContext();
766 return m_SimulationService.UpdateAgent(destination, agent, ctx);
725 } 767 }
726 } 768 }
727 769