aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2010-08-21 00:32:26 +0100
committerMelanie2010-08-21 00:32:26 +0100
commitf8ff98577ef3e576326c6eea28cb12ebb4e0bdc4 (patch)
tree3ef10e646ddda95929142eb2c3774b42d0923b3b /OpenSim/Region/Framework
parentForward-port a small improvement to the land out connector (diff)
parentForward-port a small improvement to the land out connector (diff)
downloadopensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.zip
opensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.gz
opensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.bz2
opensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs95
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs9
3 files changed, 58 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 98c46bd..32211c4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2584,18 +2584,25 @@ namespace OpenSim.Region.Framework.Scenes
2584 /// <param name="client"></param> 2584 /// <param name="client"></param>
2585 public override void AddNewClient(IClientAPI client) 2585 public override void AddNewClient(IClientAPI client)
2586 { 2586 {
2587 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2587 bool vialogin = false; 2588 bool vialogin = false;
2588 2589
2589 m_clientManager.Add(client); 2590 if (aCircuit == null) // no good, didn't pass NewUserConnection successfully
2591 return;
2592
2593 vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 ||
2594 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2590 2595
2591 CheckHeartbeat(); 2596 CheckHeartbeat();
2592 SubscribeToClientEvents(client);
2593 ScenePresence presence; 2597 ScenePresence presence;
2594 2598
2595 if (m_restorePresences.ContainsKey(client.AgentId)) 2599 if (m_restorePresences.ContainsKey(client.AgentId))
2596 { 2600 {
2597 m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName); 2601 m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName);
2598 2602
2603 m_clientManager.Add(client);
2604 SubscribeToClientEvents(client);
2605
2599 presence = m_restorePresences[client.AgentId]; 2606 presence = m_restorePresences[client.AgentId];
2600 m_restorePresences.Remove(client.AgentId); 2607 m_restorePresences.Remove(client.AgentId);
2601 2608
@@ -2618,49 +2625,35 @@ namespace OpenSim.Region.Framework.Scenes
2618 } 2625 }
2619 else 2626 else
2620 { 2627 {
2621 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2628 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2622
2623 // Do the verification here
2624 System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP();
2625 if (aCircuit != null)
2626 { 2629 {
2627 if (!VerifyClient(aCircuit, ep, out vialogin)) 2630 m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2628 {
2629 // uh-oh, this is fishy
2630 m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2631 client.AgentId, client.SessionId, ep.ToString());
2632 try
2633 {
2634 client.Close();
2635 }
2636 catch (Exception e)
2637 {
2638 m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace);
2639 }
2640 return;
2641 }
2642 }
2643 2631
2644 m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2632 m_clientManager.Add(client);
2633 SubscribeToClientEvents(client);
2645 2634
2646 ScenePresence sp = CreateAndAddScenePresence(client); 2635 ScenePresence sp = CreateAndAddScenePresence(client);
2647 if (aCircuit != null) 2636 if (aCircuit != null)
2648 sp.Appearance = aCircuit.Appearance; 2637 sp.Appearance = aCircuit.Appearance;
2649 2638
2650 // HERE!!! Do the initial attachments right here 2639 // HERE!!! Do the initial attachments right here
2651 // first agent upon login is a root agent by design. 2640 // first agent upon login is a root agent by design.
2652 // All other AddNewClient calls find aCircuit.child to be true 2641 // All other AddNewClient calls find aCircuit.child to be true
2653 if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) 2642 if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
2654 { 2643 {
2655 sp.IsChildAgent = false; 2644 sp.IsChildAgent = false;
2656 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); 2645 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
2646 }
2657 } 2647 }
2658 } 2648 }
2659 2649
2660 m_LastLogin = Util.EnvironmentTickCount(); 2650 if (GetScenePresence(client.AgentId) != null)
2661 EventManager.TriggerOnNewClient(client); 2651 {
2662 if (vialogin) 2652 m_LastLogin = Util.EnvironmentTickCount();
2663 EventManager.TriggerOnClientLogin(client); 2653 EventManager.TriggerOnNewClient(client);
2654 if (vialogin)
2655 EventManager.TriggerOnClientLogin(client);
2656 }
2664 } 2657 }
2665 2658
2666 private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin) 2659 private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin)
@@ -2668,16 +2661,14 @@ namespace OpenSim.Region.Framework.Scenes
2668 vialogin = false; 2661 vialogin = false;
2669 2662
2670 // Do the verification here 2663 // Do the verification here
2671 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) 2664 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
2672 { 2665 {
2673 m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 2666 m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2674 vialogin = true; 2667 vialogin = true;
2675 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); 2668 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2676 if (userVerification != null && ep != null) 2669 if (userVerification != null && ep != null)
2677 { 2670 {
2678 System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address); 2671 if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString()))
2679
2680 if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString()))
2681 { 2672 {
2682 // uh-oh, this is fishy 2673 // uh-oh, this is fishy
2683 m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 2674 m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
@@ -2688,6 +2679,13 @@ namespace OpenSim.Region.Framework.Scenes
2688 } 2679 }
2689 } 2680 }
2690 2681
2682 else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2683 {
2684 m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.",
2685 aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2686 vialogin = true;
2687 }
2688
2691 return true; 2689 return true;
2692 } 2690 }
2693 2691
@@ -3343,7 +3341,8 @@ namespace OpenSim.Region.Framework.Scenes
3343 /// also return a reason.</returns> 3341 /// also return a reason.</returns>
3344 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) 3342 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
3345 { 3343 {
3346 TeleportFlags tp = (TeleportFlags)teleportFlags; 3344 bool vialogin = ((teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0 ||
3345 (teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0);
3347 reason = String.Empty; 3346 reason = String.Empty;
3348 3347
3349 //Teleport flags: 3348 //Teleport flags:
@@ -3380,7 +3379,7 @@ namespace OpenSim.Region.Framework.Scenes
3380 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); 3379 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3381 3380
3382 //On login test land permisions 3381 //On login test land permisions
3383 if (tp == TeleportFlags.ViaLogin) 3382 if (vialogin)
3384 { 3383 {
3385 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3384 if (land != null && !TestLandRestrictions(agent, land, out reason))
3386 { 3385 {
@@ -3440,7 +3439,7 @@ namespace OpenSim.Region.Framework.Scenes
3440 agent.teleportFlags = teleportFlags; 3439 agent.teleportFlags = teleportFlags;
3441 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3440 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3442 3441
3443 if (tp == TeleportFlags.ViaLogin) 3442 if (vialogin)
3444 { 3443 {
3445 if (TestBorderCross(agent.startpos, Cardinals.E)) 3444 if (TestBorderCross(agent.startpos, Cardinals.E))
3446 { 3445 {
@@ -3561,7 +3560,7 @@ namespace OpenSim.Region.Framework.Scenes
3561 IPresenceService presence = RequestModuleInterface<IPresenceService>(); 3560 IPresenceService presence = RequestModuleInterface<IPresenceService>();
3562 if (presence == null) 3561 if (presence == null)
3563 { 3562 {
3564 reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); 3563 reason = String.Format("Failed to verify user presence in the grid for {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3565 return false; 3564 return false;
3566 } 3565 }
3567 3566
@@ -3569,7 +3568,7 @@ namespace OpenSim.Region.Framework.Scenes
3569 3568
3570 if (pinfo == null) 3569 if (pinfo == null)
3571 { 3570 {
3572 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); 3571 reason = String.Format("Failed to verify user presence in the grid for {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3573 return false; 3572 return false;
3574 } 3573 }
3575 3574
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index d4f9f18..54b3260 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -130,11 +130,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
130 { 130 {
131 TestHelper.InMethod(); 131 TestHelper.InMethod();
132 //log4net.Config.XmlConfigurator.Configure(); 132 //log4net.Config.XmlConfigurator.Configure();
133 133
134 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 134 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
135 135
136 TestScene scene = SceneSetupHelpers.SetupScene(); 136 TestScene scene = SceneSetupHelpers.SetupScene();
137 137
138 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 138 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
139 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 139 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
140 sogd.Enabled = false; 140 sogd.Enabled = false;
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
147 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 147 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
148 148
149 Assert.That(retrievedPart, Is.Not.Null); 149 Assert.That(retrievedPart, Is.Not.Null);
150 150
151 sogd.InventoryDeQueueAndDelete(); 151 sogd.InventoryDeQueueAndDelete();
152 152
153 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 153 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index 501207e..e39a362 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -104,8 +104,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
104 agent.AgentID = agent1; 104 agent.AgentID = agent1;
105 agent.firstname = firstName; 105 agent.firstname = firstName;
106 agent.lastname = "testlastname"; 106 agent.lastname = "testlastname";
107 agent.SessionID = UUID.Zero; 107 agent.SessionID = UUID.Random();
108 agent.SecureSessionID = UUID.Zero; 108 agent.SecureSessionID = UUID.Random();
109 agent.circuitcode = 123; 109 agent.circuitcode = 123;
110 agent.BaseFolder = UUID.Zero; 110 agent.BaseFolder = UUID.Zero;
111 agent.InventoryFolder = UUID.Zero; 111 agent.InventoryFolder = UUID.Zero;
@@ -114,6 +114,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
114 agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); 114 agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
115 agent.child = true; 115 agent.child = true;
116 116
117 if (scene.PresenceService == null)
118 Console.WriteLine("Presence Service is null");
119
120 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
121
117 string reason; 122 string reason;
118 scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); 123 scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
119 testclient = new TestClient(agent, scene); 124 testclient = new TestClient(agent, scene);