From a39ea07158756a76757d4b616c60cbcedf06f268 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 19 Aug 2010 19:54:40 -0700 Subject: Finished implementing ViaLogin vs ViaHGLogin. Removed lookup on myipaddress.com. Also removed client IP verification upon UDP connection that had been left there -- we can't do that in general. --- OpenSim/Region/Framework/Scenes/Scene.cs | 52 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 18705a8..e742b55 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2507,26 +2507,26 @@ namespace OpenSim.Region.Framework.Scenes { AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); - // Do the verification here - System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); - if (aCircuit != null) - { - if (!VerifyClient(aCircuit, ep, out vialogin)) - { - // uh-oh, this is fishy - m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", - client.AgentId, client.SessionId, ep.ToString()); - try - { - client.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); - } - return; - } - } + //// Do the verification here -- No, really don't do this here. This is UDP address, let it go. + //System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); + //if (aCircuit != null) + //{ + // if (!VerifyClient(aCircuit, ep, out vialogin)) + // { + // // uh-oh, this is fishy + // m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", + // client.AgentId, client.SessionId, ep.ToString()); + // try + // { + // client.Close(); + // } + // catch (Exception e) + // { + // m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); + // } + // return; + // } + //} m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); @@ -2555,16 +2555,14 @@ namespace OpenSim.Region.Framework.Scenes vialogin = false; // Do the verification here - if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) + if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) { - m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); + m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); vialogin = true; IUserAgentVerificationModule userVerification = RequestModuleInterface(); if (userVerification != null && ep != null) { - System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address); - - if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString())) + if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) { // uh-oh, this is fishy m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); @@ -2575,6 +2573,10 @@ namespace OpenSim.Region.Framework.Scenes } } + else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) + m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.", + aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); + return true; } -- cgit v1.1 From ae554a48d0cea61d05dc931c04f336d83de4834b Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 20 Aug 2010 08:36:23 +0100 Subject: Add some maptile options, change maptile generation from OpenSimBase to Scene to make it more configurable. --- OpenSim/Region/Framework/Scenes/Scene.cs | 63 +++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 18705a8..2890ecd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -396,6 +396,9 @@ namespace OpenSim.Region.Framework.Scenes private double m_rootReprioritizationDistance = 10.0; private double m_childReprioritizationDistance = 20.0; + private Timer m_mapGenerationTimer = new Timer(); + bool m_generateMaptiles = false; + #endregion #region Properties @@ -646,6 +649,29 @@ namespace OpenSim.Region.Framework.Scenes } m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); + + m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); + if (m_generateMaptiles) + { + int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); + if (maptileRefresh != 0) + { + m_mapGenerationTimer.Interval = maptileRefresh * 1000; + m_mapGenerationTimer.Elapsed += RegenerateMaptile; + m_mapGenerationTimer.AutoReset = true; + m_mapGenerationTimer.Start(); + } + } + else + { + string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); + UUID tileID; + + if (UUID.TryParse(tile, out tileID)) + { + RegionInfo.RegionSettings.TerrainImageID = tileID; + } + } } catch { @@ -1662,16 +1688,21 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.SetScene(this); - // These two 'commands' *must be* next to each other or sim rebooting fails. - //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); - - GridRegion region = new GridRegion(RegionInfo); - string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); - if (error != String.Empty) + // If we generate maptiles internally at all, the maptile generator + // will register the region. If not, do it here + if (m_generateMaptiles) { - throw new Exception(error); + RegenerateMaptile(null, null); + } + else + { + GridRegion region = new GridRegion(RegionInfo); + string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); + if (error != String.Empty) + { + throw new Exception(error); + } } - } #endregion @@ -4878,5 +4909,19 @@ namespace OpenSim.Region.Framework.Scenes return offsets.ToArray(); } + + public void RegenerateMaptile(object sender, ElapsedEventArgs e) + { + IWorldMapModule mapModule = RequestModuleInterface(); + if (mapModule != null) + { + mapModule.GenerateMaptile(); + + string error = GridService.RegisterRegion(RegionInfo.ScopeID, new GridRegion(RegionInfo)); + + if (error != String.Empty) + throw new Exception(error); + } + } } -} \ No newline at end of file +} -- cgit v1.1 From 6f83b0ee4625ae6b94a7ca0525f7d8369da7e126 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 20 Aug 2010 09:02:05 -0700 Subject: Cleaned up a few more things related to incoming agents. --- OpenSim/Region/Framework/Scenes/Scene.cs | 87 +++++++++++++++----------------- 1 file changed, 42 insertions(+), 45 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2f862ea..a147628 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2502,18 +2502,25 @@ namespace OpenSim.Region.Framework.Scenes /// public override void AddNewClient(IClientAPI client) { + AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); bool vialogin = false; - m_clientManager.Add(client); + if (aCircuit == null) // no good, didn't pass NewUserConnection successfully + return; + + vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || + (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; CheckHeartbeat(); - SubscribeToClientEvents(client); ScenePresence presence; if (m_restorePresences.ContainsKey(client.AgentId)) { m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName); + m_clientManager.Add(client); + SubscribeToClientEvents(client); + presence = m_restorePresences[client.AgentId]; m_restorePresences.Remove(client.AgentId); @@ -2536,49 +2543,35 @@ namespace OpenSim.Region.Framework.Scenes } else { - AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); - - //// Do the verification here -- No, really don't do this here. This is UDP address, let it go. - //System.Net.IPEndPoint ep = (System.Net.IPEndPoint)client.GetClientEP(); - //if (aCircuit != null) - //{ - // if (!VerifyClient(aCircuit, ep, out vialogin)) - // { - // // uh-oh, this is fishy - // m_log.WarnFormat("[SCENE]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", - // client.AgentId, client.SessionId, ep.ToString()); - // try - // { - // client.Close(); - // } - // catch (Exception e) - // { - // m_log.DebugFormat("[SCENE]: Exception while closing aborted client: {0}", e.StackTrace); - // } - // return; - // } - //} + if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here + { + m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); - m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); + m_clientManager.Add(client); + SubscribeToClientEvents(client); - ScenePresence sp = CreateAndAddScenePresence(client); - if (aCircuit != null) - sp.Appearance = aCircuit.Appearance; + ScenePresence sp = CreateAndAddScenePresence(client); + if (aCircuit != null) + sp.Appearance = aCircuit.Appearance; - // HERE!!! Do the initial attachments right here - // first agent upon login is a root agent by design. - // All other AddNewClient calls find aCircuit.child to be true - if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) - { - sp.IsChildAgent = false; - Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); + // HERE!!! Do the initial attachments right here + // first agent upon login is a root agent by design. + // All other AddNewClient calls find aCircuit.child to be true + if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) + { + sp.IsChildAgent = false; + Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); + } } } - m_LastLogin = Util.EnvironmentTickCount(); - EventManager.TriggerOnNewClient(client); - if (vialogin) - EventManager.TriggerOnClientLogin(client); + if (GetScenePresence(client.AgentId) != null) + { + m_LastLogin = Util.EnvironmentTickCount(); + EventManager.TriggerOnNewClient(client); + if (vialogin) + EventManager.TriggerOnClientLogin(client); + } } private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin) @@ -2605,8 +2598,11 @@ namespace OpenSim.Region.Framework.Scenes } else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) - m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.", + { + m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); + vialogin = true; + } return true; } @@ -3245,7 +3241,8 @@ namespace OpenSim.Region.Framework.Scenes /// also return a reason. public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) { - TeleportFlags tp = (TeleportFlags)teleportFlags; + bool vialogin = ((teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0 || + (teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0); reason = String.Empty; //Teleport flags: @@ -3282,7 +3279,7 @@ namespace OpenSim.Region.Framework.Scenes ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); //On login test land permisions - if (tp == TeleportFlags.ViaLogin) + if (vialogin) { if (land != null && !TestLandRestrictions(agent, land, out reason)) { @@ -3341,7 +3338,7 @@ namespace OpenSim.Region.Framework.Scenes agent.teleportFlags = teleportFlags; m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); - if (tp == TeleportFlags.ViaLogin) + if (vialogin) { if (TestBorderCross(agent.startpos, Cardinals.E)) { @@ -3459,7 +3456,7 @@ namespace OpenSim.Region.Framework.Scenes IPresenceService presence = RequestModuleInterface(); if (presence == null) { - reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); + 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); return false; } @@ -3467,7 +3464,7 @@ namespace OpenSim.Region.Framework.Scenes if (pinfo == null) { - reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); + 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); return false; } -- cgit v1.1