From d9c48e70a9a01f56135ede2cef9ec45c7dddf567 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 18 Jan 2010 17:56:27 +0100 Subject: Fix a major security problem with osSetDynamicTexture which allowed the deletion of /any/ asset. --- .../Scripting/DynamicTexture/DynamicTextureModule.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index f51d0c2..679c871 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -358,11 +358,18 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture // tmptex.DefaultTexture.Fullbright = true; part.UpdateTexture(tmptex); - } - - if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) - { - scene.AssetService.Delete(oldID.ToString()); + } + + if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) + { + if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString()); + if (oldAsset != null) + { + if (oldAsset.Temporary == true) + { + scene.AssetService.Delete(oldID.ToString()); + } + } } } -- cgit v1.1 From cfca9e1e811f6cdea6b7c3338f7f783a07f8e0ac Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 29 Jan 2010 07:20:13 +0000 Subject: Revert "Updates all IRegionModules to the new style region modules." This reverts commit ec3c31e61e5e540f822891110df9bc978655bbaf. --- .../DynamicTexture/DynamicTextureModule.cs | 60 ++++++++-------------- .../Scripting/EMailModules/EmailModule.cs | 32 +++--------- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 36 ++++--------- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 - .../Scripting/LoadImageURL/LoadImageURLModule.cs | 37 +++++-------- .../Scripting/VectorRender/VectorRenderModule.cs | 41 +++++---------- .../Scripting/WorldComm/WorldCommModule.cs | 33 ++++++------ .../CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | 51 ++++-------------- 8 files changed, 89 insertions(+), 203 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 40b7159..679c871 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; -using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenMetaverse.Imaging; @@ -41,8 +40,7 @@ using System.Reflection; namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class DynamicTextureModule : ISharedRegionModule, IDynamicTextureManager + public class DynamicTextureModule : IRegionModule, IDynamicTextureManager { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -212,14 +210,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture #endregion - #region ISharedRegionModule Members + #region IRegionModule Members - public void Initialise(IConfigSource config) - { - - } - - public void AddRegion(Scene scene) + public void Initialise(Scene scene, IConfigSource config) { if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) { @@ -228,24 +221,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } } - public Type ReplaceableInterface - { - get { return null; } - } - - public void RegionLoaded(Scene scene) - { - } - - public void RemoveRegion(Scene scene) - { - if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) - { - RegisteredScenes.Remove(scene.RegionInfo.RegionID); - scene.UnregisterModuleInterface(this); - } - } - public void PostInitialise() { } @@ -259,6 +234,11 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture get { return "DynamicTextureModule"; } } + public bool IsSharedModule + { + get { return true; } + } + #endregion #region Nested type: DynamicTextureUpdater @@ -378,18 +358,18 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture // tmptex.DefaultTexture.Fullbright = true; part.UpdateTexture(tmptex); - } - - if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) - { - if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString()); - if (oldAsset != null) - { - if (oldAsset.Temporary == true) - { - scene.AssetService.Delete(oldID.ToString()); - } - } + } + + if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) + { + if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString()); + if (oldAsset != null) + { + if (oldAsset.Temporary == true) + { + scene.AssetService.Delete(oldID.ToString()); + } + } } } diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index d6ed468..83f004d 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -32,7 +32,6 @@ using System.Text.RegularExpressions; using DotNetOpenMail; using DotNetOpenMail.SmtpAuth; using log4net; -using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -41,7 +40,6 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.EmailModules { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class EmailModule : IEmailModule { // @@ -96,7 +94,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules } } - public void Initialise(IConfigSource config) + public void Initialise(Scene scene, IConfigSource config) { m_Config = config; IConfig SMTPConfig; @@ -138,16 +136,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules m_Enabled = false; return; } - m_log.Info("[EMAIL] Activated DefaultEmailModule"); - } - - public Type ReplaceableInterface - { - get { return null; } - } - public void AddRegion(Scene scene) - { // It's a go! if (m_Enabled) { @@ -166,20 +155,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); } } - } - } - - public void RegionLoaded(Scene scene) - { - } - public void RemoveRegion(Scene scene) - { - scene.UnregisterModuleInterface(this); - - if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle)) - { - m_Scenes.Remove(scene.RegionInfo.RegionHandle); + m_log.Info("[EMAIL] Activated DefaultEmailModule"); } } @@ -196,6 +173,11 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules get { return "DefaultEmailModule"; } } + public bool IsSharedModule + { + get { return true; } + } + /// /// Delay function using thread in seconds /// diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index e331b8d..d78931a 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -31,7 +31,6 @@ using System.IO; using System.Net; using System.Text; using System.Threading; -using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -85,8 +84,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class HttpRequestModule : ISharedRegionModule, IHttpRequestModule + public class HttpRequestModule : IRegionModule, IHttpRequestModule { private object HttpListLock = new object(); private int httpTimeout = 30000; @@ -231,35 +229,18 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest #endregion - #region ISharedRegionModule Members + #region IRegionModule Members - public void Initialise(IConfigSource config) - { - m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); - m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); - - m_pendingRequests = new Dictionary(); - } - - public void AddRegion(Scene scene) + public void Initialise(Scene scene, IConfigSource config) { m_scene = scene; m_scene.RegisterModuleInterface(this); - } - - public Type ReplaceableInterface - { - get { return null; } - } - public void RegionLoaded(Scene scene) - { - } + m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); + m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); - public void RemoveRegion(Scene scene) - { - scene.UnregisterModuleInterface(this); + m_pendingRequests = new Dictionary(); } public void PostInitialise() @@ -275,6 +256,11 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest get { return m_name; } } + public bool IsSharedModule + { + get { return true; } + } + #endregion } diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 6ce55a9..9b565ed 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -126,8 +126,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void RemoveRegion(Scene scene) { - scene.UnregisterModuleInterface(this); - scene.EventManager.OnScriptReset -= OnScriptReset; } public void Close() diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs index 35ce2cb..c23cea5 100644 --- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs @@ -29,7 +29,6 @@ using System; using System.Drawing; using System.IO; using System.Net; -using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenMetaverse.Imaging; @@ -40,8 +39,7 @@ using System.Reflection; namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class LoadImageURLModule : ISharedRegionModule, IDynamicTextureRender + public class LoadImageURLModule : IRegionModule, IDynamicTextureRender { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -99,28 +97,20 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL #endregion - #region ISharedRegionModule Members + #region IRegionModule Members - public void Initialise(IConfigSource config) - { - m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); - m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); - } - - public void AddRegion(Scene scene) + public void Initialise(Scene scene, IConfigSource config) { if (m_scene == null) { m_scene = scene; } + + m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); + m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); } - public Type ReplaceableInterface - { - get { return null; } - } - - public void RegionLoaded(Scene scene) + public void PostInitialise() { m_textureManager = m_scene.RequestModuleInterface(); if (m_textureManager != null) @@ -129,14 +119,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL } } - public void RemoveRegion(Scene scene) - { - } - - public void PostInitialise() - { - } - public void Close() { } @@ -146,6 +128,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL get { return m_name; } } + public bool IsSharedModule + { + get { return true; } + } + #endregion private void MakeHttpRequest(string url, UUID requestID) diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 71b01a1..d57a8e5 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -31,7 +31,6 @@ using System.Drawing.Imaging; using System.Globalization; using System.IO; using System.Net; -using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenMetaverse.Imaging; @@ -44,8 +43,7 @@ using System.Reflection; namespace OpenSim.Region.CoreModules.Scripting.VectorRender { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class VectorRenderModule : ISharedRegionModule, IDynamicTextureRender + public class VectorRenderModule : IRegionModule, IDynamicTextureRender { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -112,10 +110,15 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender #endregion - #region ISharedRegionModule Members + #region IRegionModule Members - public void Initialise(IConfigSource config) + public void Initialise(Scene scene, IConfigSource config) { + if (m_scene == null) + { + m_scene = scene; + } + if (m_graph == null) { Bitmap bitmap = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb); @@ -130,20 +133,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender m_log.DebugFormat("[VECTORRENDERMODULE]: using font \"{0}\" for text rendering.", m_fontName); } - public void AddRegion(Scene scene) - { - if (m_scene == null) - { - m_scene = scene; - } - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public void RegionLoaded(Scene scene) + public void PostInitialise() { m_textureManager = m_scene.RequestModuleInterface(); if (m_textureManager != null) @@ -152,14 +142,6 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender } } - public void RemoveRegion(Scene scene) - { - } - - public void PostInitialise() - { - } - public void Close() { } @@ -169,6 +151,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender get { return m_name; } } + public bool IsSharedModule + { + get { return true; } + } + #endregion private void Draw(string data, UUID id, string extraParams) diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index d935c56..93aa88c 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -28,7 +28,6 @@ using System; using System.Collections; using System.Collections.Generic; -using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -86,8 +85,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.WorldComm { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class WorldCommModule : ISharedRegionModule, IWorldComm + public class WorldCommModule : IRegionModule, IWorldComm { // private static readonly ILog m_log = // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -100,9 +98,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private int m_saydistance = 30; private int m_shoutdistance = 100; - #region ISharedRegionModule Members + #region IRegionModule Members - public void Initialise(IConfigSource config) + public void Initialise(Scene scene, IConfigSource config) { // wrap this in a try block so that defaults will work if // the config file doesn't specify otherwise. @@ -122,6 +120,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm if (maxlisteners < 1) maxlisteners = int.MaxValue; if (maxhandles < 1) maxhandles = int.MaxValue; +<<<<<<< HEAD:OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs m_listenerManager = new ListenerManager(maxlisteners, maxhandles); m_pendingQ = new Queue(); m_pending = Queue.Synchronized(m_pendingQ); @@ -133,26 +132,19 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm public void AddRegion(Scene scene) { +======= +>>>>>>> ec3c31e... Updates all IRegionModules to the new style region modules.:OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs m_scene = scene; m_scene.RegisterModuleInterface(this); + m_listenerManager = new ListenerManager(maxlisteners, maxhandles); m_scene.EventManager.OnChatFromClient += DeliverClientMessage; m_scene.EventManager.OnChatBroadcast += DeliverClientMessage; + m_pendingQ = new Queue(); + m_pending = Queue.Synchronized(m_pendingQ); } - public Type ReplaceableInterface - { - get { return null; } - } - - public void RegionLoaded(Scene scene) - { - } - - public void RemoveRegion(Scene scene) + public void PostInitialise() { - scene.UnregisterModuleInterface(this); - scene.EventManager.OnChatFromClient -= DeliverClientMessage; - scene.EventManager.OnChatBroadcast -= DeliverClientMessage; } public void Close() @@ -164,6 +156,11 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm get { return "WorldCommModule"; } } + public bool IsSharedModule + { + get { return false; } + } + #endregion #region IWorldComm Members diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index a9147fb6..27b64bf 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs @@ -32,7 +32,6 @@ using System.Net; using System.Reflection; using System.Threading; using log4net; -using Mono.Addins; using Nini.Config; using Nwc.XmlRpc; using OpenMetaverse; @@ -77,8 +76,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.XMLRPC { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class XMLRPCModule : ISharedRegionModule, IXMLRPC + public class XMLRPCModule : IRegionModule, IXMLRPC { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -96,9 +94,9 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC private int RemoteReplyScriptWait = 300; private object XMLRPCListLock = new object(); - #region ISharedRegionModule Members + #region IRegionModule Members - public void Initialise(IConfigSource config) + public void Initialise(Scene scene, IConfigSource config) { // We need to create these early because the scripts might be calling // But since this gets called for every region, we need to make sure they @@ -118,14 +116,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC { } } - } - - public void PostInitialise() - { - } - public void AddRegion(Scene scene) - { if (!m_scenes.Contains(scene)) { m_scenes.Add(scene); @@ -134,12 +125,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC } } - public Type ReplaceableInterface - { - get { return null; } - } - private Dictionary m_HttpServers = new Dictionary(); - public void RegionLoaded(Scene scene) + public void PostInitialise() { if (IsEnabled()) { @@ -147,31 +133,9 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC // Attach xmlrpc handlers m_log.Info("[REMOTE_DATA]: " + "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); - BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); + BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort); httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); httpServer.Start(); - m_HttpServers.Add(scene, httpServer); - } - } - - public void RemoveRegion(Scene scene) - { - if (m_scenes.Contains(scene)) - m_scenes.Remove(scene); - scene.UnregisterModuleInterface(this); - if (IsEnabled()) - { - // Start http server - // Attach xmlrpc handlers - if (m_HttpServers.ContainsKey(scene)) - { - BaseHttpServer httpServer; - m_HttpServers.TryGetValue(scene, out httpServer); - m_log.Info("[REMOTE_DATA]: " + - "Stopping XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); - httpServer.RemoveXmlRPCHandler("llRemoteData"); - httpServer.Stop(); - } } } @@ -184,6 +148,11 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC get { return m_name; } } + public bool IsSharedModule + { + get { return true; } + } + public int Port { get { return m_remoteDataPort; } -- cgit v1.1 From 44c86cedcf8ddba1ca4c9e3ff4f1e39ceb59be06 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 29 Jan 2010 07:42:45 +0000 Subject: Resolve one more conflict I overlooked --- .../CoreModules/Scripting/WorldComm/WorldCommModule.cs | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 93aa88c..60df2e7 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -120,20 +120,6 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm if (maxlisteners < 1) maxlisteners = int.MaxValue; if (maxhandles < 1) maxhandles = int.MaxValue; -<<<<<<< HEAD:OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs - m_listenerManager = new ListenerManager(maxlisteners, maxhandles); - m_pendingQ = new Queue(); - m_pending = Queue.Synchronized(m_pendingQ); - } - - public void PostInitialise() - { - } - - public void AddRegion(Scene scene) - { -======= ->>>>>>> ec3c31e... Updates all IRegionModules to the new style region modules.:OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs m_scene = scene; m_scene.RegisterModuleInterface(this); m_listenerManager = new ListenerManager(maxlisteners, maxhandles); -- cgit v1.1 From 4fa1d4896c89d9907fe49f3ad718444b63c03ec9 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 28 Jun 2010 02:30:36 +0200 Subject: Change the way IRegionModule us referenced by IEmailModule to allow later conversion to new style --- OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index 83f004d..c0975ea 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -40,7 +40,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Scripting.EmailModules { - public class EmailModule : IEmailModule + public class EmailModule : IRegionModule, IEmailModule { // // Log -- cgit v1.1 From d5cbe4cb75a40a5b98d92d7fac504943edf428a1 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 1 Jul 2010 16:40:26 +0200 Subject: Remove trailing slash from HTTP URLs to be compatible with SL --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 9b565ed..ab27da9 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_UrlMap[url] = urlData; - string uri = "/lslhttp/" + urlcode.ToString() + "/"; + string uri = "/lslhttp/" + urlcode.ToString(); m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, -- cgit v1.1 From 3d5d44279b99e58cb4f2db3532df522ad3b5cccf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 1 Jul 2010 17:06:29 +0200 Subject: ANother stab at LSL compatibility --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index ab27da9..f8cb414 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString(); UrlData urlData = new UrlData(); urlData.hostID = host.UUID; -- cgit v1.1 From 721d8a72987cea267ce9d32dfb91a288019107b2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 3 Jul 2010 07:09:27 +0200 Subject: Re-add the slashes at the end of the URL. Too much depends on them --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f8cb414..9b565ed 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString(); + string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -155,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_UrlMap[url] = urlData; - string uri = "/lslhttp/" + urlcode.ToString(); + string uri = "/lslhttp/" + urlcode.ToString() + "/"; m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, -- cgit v1.1 From 86a82e6ecb564c4b3126d3472482d713213aaf31 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 3 Jul 2010 08:33:08 +0200 Subject: Now, fix the slash issue the right way. Our URLs now work like SL's --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 9b565ed..1fd1f47 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString(); UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -152,10 +152,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.urlcode = urlcode; urlData.requests = new Dictionary(); - m_UrlMap[url] = urlData; - string uri = "/lslhttp/" + urlcode.ToString() + "/"; + string uri = "/lslhttp/" + urlcode.ToString(); m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, @@ -386,6 +385,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp return response; } + public void HttpRequestHandler(UUID requestID, Hashtable request) { lock (request) @@ -400,8 +400,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp int pos1 = uri.IndexOf("/");// /lslhttp int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ - int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// - string uri_tmp = uri.Substring(0, pos3 + 1); + int pos3 = pos2 + 37; // /lslhttp/urlcode + string uri_tmp = uri.Substring(0, pos3); //HTTP server code doesn't provide us with QueryStrings string pathInfo; string queryString; -- cgit v1.1 From 5ce296e08de8875da6feddd4a9edf4b16558009d Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 14 Dec 2010 09:14:34 -0800 Subject: Workaround to allow llHTTPRequest to POST data to Lighthttpd which doesn't support Expect: 100-Continue --- .../Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index d78931a..e4a2461 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -341,6 +341,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest try { Request = (HttpWebRequest) WebRequest.Create(Url); + + //This works around some buggy HTTP Servers like Lighttpd + Request.ServicePoint.Expect100Continue = false; + Request.Method = HttpMethod; Request.ContentType = HttpMIMEType; -- cgit v1.1 From 13d4fedf7a7822ed408693863d4db00a5381315d Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 28 Jan 2011 13:45:27 -0800 Subject: Fix a discrepancy vs. SL with parsing x-query-string --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 1fd1f47..302a192 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -439,7 +439,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (request.ContainsKey(key)) { string val = (String)request[key]; - queryString = queryString + key + "=" + val + "&"; + if (key == "") + { + queryString = queryString + key + "=" + val + "&"; + } + else + { + queryString = queryString + val + "&"; + } } } if (queryString.Length > 1) -- cgit v1.1 From 87ed39c9534809e2b3edd88b22c7ecf126b37e2b Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 28 Jan 2011 16:51:35 -0800 Subject: Significantly increase the total number of URL's available. In second life, the limit is 15,000 URL's (one per prim), so i'd hope we can manage 1k. --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 302a192..b83eb90 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp new Dictionary(); - private int m_TotalUrls = 100; + private int m_TotalUrls = 1000; private IHttpServer m_HttpServer = null; -- cgit v1.1 From 188bdfc87860dbd5d6d616337c203c55c7a0b80a Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 29 Jan 2011 12:45:53 -0800 Subject: Ignore duplicate llHTTPResponse calls to the same request. Prevents response corruption. Only the first llHTTPResponse call is obeyed, akin to SL. --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index b83eb90..4851b33 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public string url; public UUID urlcode; public Dictionary requests; + public bool responseSent; } public class RequestData @@ -199,10 +200,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (m_RequestMap.ContainsKey(request)) { UrlData urlData = m_RequestMap[request]; - urlData.requests[request].responseCode = status; - urlData.requests[request].responseBody = body; - //urlData.requests[request].ev.Set(); - urlData.requests[request].requestDone =true; + if (!urlData.responseSent) + { + urlData.requests[request].responseCode = status; + urlData.requests[request].responseBody = body; + //urlData.requests[request].ev.Set(); + urlData.requests[request].requestDone = true; + urlData.responseSent = true; + } } else { -- cgit v1.1 From 35d29ef3e3539b03164289481fbf305ad7565dfb Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 29 Jan 2011 19:38:05 -0800 Subject: If llHTTPRequest results in an error, still attempt to get the response text. If we can't (which implies the server is unreachable), return the StatusDescription as before. --- .../CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index e4a2461..51742ff 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -408,7 +408,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; Status = (int)webRsp.StatusCode; - ResponseBody = webRsp.StatusDescription; + try + { + using (Stream responseStream = webRsp.GetResponseStream()) + { + ResponseBody = responseStream.GetStreamString(); + } + } + catch + { + ResponseBody = webRsp.StatusDescription; + } } else { -- cgit v1.1 From e5ef993f2b7ee8b7777d8a413d815c3e8e2ca786 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 31 Jan 2011 18:01:53 -0800 Subject: Fix cm/15627 : Don't block the entire URL on duplicate requests, just that particular request! --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 4851b33..89f5da3 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -48,7 +48,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public string url; public UUID urlcode; public Dictionary requests; - public bool responseSent; } public class RequestData @@ -61,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp //public ManualResetEvent ev; public bool requestDone; public int startTime; + public bool responseSent; public string uri; } @@ -200,13 +200,13 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (m_RequestMap.ContainsKey(request)) { UrlData urlData = m_RequestMap[request]; - if (!urlData.responseSent) + if (!urlData.requests[request].responseSent) { urlData.requests[request].responseCode = status; urlData.requests[request].responseBody = body; //urlData.requests[request].ev.Set(); urlData.requests[request].requestDone = true; - urlData.responseSent = true; + urlData.requests[request].responseSent = true; } } else -- cgit v1.1 From 9a9c9644acb4135d168b239f40fd07aafe34f190 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 3 Feb 2011 17:25:55 -0800 Subject: Repair x-query-string --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 89f5da3..66eb747 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -444,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (request.ContainsKey(key)) { string val = (String)request[key]; - if (key == "") + if (key != "") { queryString = queryString + key + "=" + val + "&"; } -- cgit v1.1 From 4d4765aa28d4553ffa2893eea201eaa27867a022 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 21 Mar 2011 13:30:53 -0700 Subject: Since we've plugged the leak, now increase URLs to 5000 since the limit is being hit in several sims --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 66eb747..bdbd0c2 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp new Dictionary(); - private int m_TotalUrls = 1000; + private int m_TotalUrls = 5000; private IHttpServer m_HttpServer = null; -- cgit v1.1 From 276181053147eb3ff0831ce1e730dc4819b16763 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 17 Apr 2011 18:28:06 +0200 Subject: Fix the cert validation handler so that it will not block other parts of the server doing ssl successfully. --- .../CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 4e64979..5e28ee1 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -118,7 +118,15 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest return true; } - return chain.Build(new X509Certificate2(certificate)); + if ((((int)sslPolicyErrors) & ~4) != 0) + return false; + + if (ServicePointManager.CertificatePolicy != null) + { + ServicePoint sp = Request.ServicePoint; + return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); + } + return true; } #region IHttpRequestModule Members @@ -478,4 +486,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } } } -} \ No newline at end of file +} -- cgit v1.1 From e847d1d83f36a6d8e87fc9271c960b43c6ab6812 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 17 May 2011 18:44:07 -0700 Subject: Lock m_requestMap properly to prevent some nasty access errors and the resulting downward spiral --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 81 ++++++++++++++-------- 1 file changed, 51 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index fa17fb6..998f3d2 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -233,9 +233,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp return; } - foreach (UUID req in data.requests.Keys) - m_RequestMap.Remove(req); - + lock (m_RequestMap) + { + foreach (UUID req in data.requests.Keys) + m_RequestMap.Remove(req); + } + RemoveUrl(data); m_UrlMap.Remove(url); } @@ -243,36 +246,42 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void HttpResponse(UUID request, int status, string body) { - if (m_RequestMap.ContainsKey(request)) + lock (m_RequestMap) { - UrlData urlData = m_RequestMap[request]; - if (!urlData.requests[request].responseSent) + if (m_RequestMap.ContainsKey(request)) { - urlData.requests[request].responseCode = status; - urlData.requests[request].responseBody = body; - //urlData.requests[request].ev.Set(); - urlData.requests[request].requestDone = true; - urlData.requests[request].responseSent = true; + UrlData urlData = m_RequestMap[request]; + if (!urlData.requests[request].responseSent) + { + urlData.requests[request].responseCode = status; + urlData.requests[request].responseBody = body; + //urlData.requests[request].ev.Set(); + urlData.requests[request].requestDone = true; + urlData.requests[request].responseSent = true; + } + } + else + { + m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); } - } - else - { - m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); } } public string GetHttpHeader(UUID requestId, string header) { - if (m_RequestMap.ContainsKey(requestId)) - { - UrlData urlData=m_RequestMap[requestId]; - string value; - if (urlData.requests[requestId].headers.TryGetValue(header,out value)) - return value; - } - else + lock (m_RequestMap) { - m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); + if (m_RequestMap.ContainsKey(requestId)) + { + UrlData urlData = m_RequestMap[requestId]; + string value; + if (urlData.requests[requestId].headers.TryGetValue(header, out value)) + return value; + } + else + { + m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); + } } return String.Empty; } @@ -294,8 +303,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { RemoveUrl(url.Value); removeURLs.Add(url.Key); - foreach (UUID req in url.Value.requests.Keys) - m_RequestMap.Remove(req); + lock (m_RequestMap) + { + foreach (UUID req in url.Value.requests.Keys) + m_RequestMap.Remove(req); + } } } @@ -316,8 +328,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { RemoveUrl(url.Value); removeURLs.Add(url.Key); - foreach (UUID req in url.Value.requests.Keys) - m_RequestMap.Remove(req); + lock (m_RequestMap) + { + foreach (UUID req in url.Value.requests.Keys) + m_RequestMap.Remove(req); + } } } @@ -355,7 +370,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp lock (url) { url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); + lock (m_RequestMap) + { + m_RequestMap.Remove(requestID); + } } return response; @@ -431,7 +449,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp lock (url) { url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); + lock (m_RequestMap) + { + m_RequestMap.Remove(requestID); + } } return response; -- cgit v1.1 From 1f17960e6772c48abf100ce59a660662648df825 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 17 May 2011 18:56:55 -0700 Subject: Also fix the locking of url.requests and tidy the locks in general --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 54 +++++++++++++--------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 998f3d2..f6351ff 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -351,14 +351,16 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { Hashtable response = new Hashtable(); UrlData url; + int startTime = 0; lock (m_RequestMap) { if (!m_RequestMap.ContainsKey(requestID)) return response; url = m_RequestMap[requestID]; + startTime = url.requests[requestID].startTime; } - if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) + if (System.Environment.TickCount - startTime > 25000) { response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; @@ -367,13 +369,13 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp response["reusecontext"] = false; //remove from map - lock (url) + lock (url.requests) { url.requests.Remove(requestID); - lock (m_RequestMap) - { - m_RequestMap.Remove(requestID); - } + } + lock (m_RequestMap) + { + m_RequestMap.Remove(requestID); } return response; @@ -394,22 +396,25 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp return false; } url = m_RequestMap[requestID]; + } + lock (url.requests) + { if (!url.requests.ContainsKey(requestID)) { return false; } + else + { + if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) + { + return true; + } + if (url.requests[requestID].requestDone) + return true; + else + return false; + } } - - if (System.Environment.TickCount-url.requests[requestID].startTime>25000) - { - return true; - } - - if (url.requests[requestID].requestDone) - return true; - else - return false; - } private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) { @@ -421,9 +426,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (!m_RequestMap.ContainsKey(requestID)) return NoEvents(requestID,sessionID); url = m_RequestMap[requestID]; + } + lock (url.requests) + { requestData = url.requests[requestID]; } - + if (!requestData.requestDone) return NoEvents(requestID,sessionID); @@ -446,13 +454,13 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp response["reusecontext"] = false; //remove from map - lock (url) + lock (url.requests) { url.requests.Remove(requestID); - lock (m_RequestMap) - { - m_RequestMap.Remove(requestID); - } + } + lock (m_RequestMap) + { + m_RequestMap.Remove(requestID); } return response; -- cgit v1.1 From b000d9ba724ae12ae27c49dd94e36d4592bd6c26 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 26 May 2011 03:42:01 -0700 Subject: Some additional protection, it seems that responsedata needs to be locked, but I can't immediately see where it's being accessed from another thread. For now, this will protect the server --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f6351ff..b6af1f2 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -491,10 +491,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp pathInfo = uri.Substring(pos3); UrlData url = null; + string urlkey; if (!is_ssl) - url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; + urlkey = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; + //m_UrlMap[]; else - url = m_UrlMap["https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp]; + urlkey = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; + + if (m_UrlMap.ContainsKey(urlkey)) + { + url = m_UrlMap[urlkey]; + } + else + { + m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString()); + } //for llGetHttpHeader support we need to store original URI here //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers -- cgit v1.1 From 3281b993620a4db85ae26d3d080a2549ae5f405a Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Dec 2011 15:57:47 +0100 Subject: Strip CR from http responses and limit them to 2048 chars --- .../Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 5e28ee1..84ff22b 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -433,10 +433,12 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest // continue building the string sb.Append(tempString); + if (sb.Length > 2048) + break; } } while (count > 0); // any more data to read? - ResponseBody = sb.ToString(); + ResponseBody = sb.ToString().Replace("\r", ""); } catch (Exception e) { -- cgit v1.1 From 2a8a46a32d49fa6629ae3c35365456e0625e3ba5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Dec 2011 18:32:40 +0100 Subject: Fix CHANGED_TEXTURE and CHANGED_COLOR. --- .../CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index f2c8b3d..18bd018 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -355,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture // I'm pretty sure noone whats to set fullbright true if it wasn't true before. // tmptex.DefaultTexture.Fullbright = true; - part.UpdateTexture(tmptex); + part.UpdateTextureEntry(tmptex.GetBytes()); } if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) @@ -437,4 +437,4 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture #endregion } -} \ No newline at end of file +} -- cgit v1.1 From 72247bdaef1cf76e4f51b41bc7413a0837f7a332 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 14 Jan 2012 05:28:57 +0100 Subject: Allow SmtpClients and other SSL users to work with our cert handler installed --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 2fe36c1..9dac6b9 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Mail; using System.Net.Security; using System.Text; using System.Threading; @@ -111,21 +112,36 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest X509Chain chain, SslPolicyErrors sslPolicyErrors) { - HttpWebRequest Request = (HttpWebRequest)sender; - - if (Request.Headers.Get("NoVerifyCert") != null) + // If this is a web request we need to check the headers first + // We may want to ignore SSL + if (sender is HttpWebRequest) { + HttpWebRequest Request = (HttpWebRequest)sender; + ServicePoint sp = Request.ServicePoint; + + // We don't case about encryption, get out of here + if (Request.Headers.Get("NoVerifyCert") != null) + { + return true; + } + + // If there was an upstream cert verification error, bail + if ((((int)sslPolicyErrors) & ~4) != 0) + return false; + + // Check for policy and execute it if defined + if (ServicePointManager.CertificatePolicy != null) + { + return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); + } + return true; } - + + // If it's not HTTP, trust .NET to check it if ((((int)sslPolicyErrors) & ~4) != 0) return false; - if (ServicePointManager.CertificatePolicy != null) - { - ServicePoint sp = Request.ServicePoint; - return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); - } return true; } #region IHttpRequestModule Members -- cgit v1.1 From 625041f1db90c5a7f917f52720199ee0088a3141 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 27 Jun 2012 00:10:51 +0200 Subject: Comment out a spammy message that will spew 4 lines for each request to a nonexistent URL for http-in --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f4cf6b4..a701b46 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -508,7 +508,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } else { - m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString()); + //m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString()); + return; } //for llGetHttpHeader support we need to store original URI here -- cgit v1.1 From c87f0ac2261d1aa5226957aff63bfc8ac0efaffd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 28 Jun 2012 21:23:42 +0200 Subject: Fix llRegionSayTo the right way --- .../Scripting/WorldComm/WorldCommModule.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 176c86d..07bb291 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -90,6 +90,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm // private static readonly ILog m_log = // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private const int DEBUG_CHANNEL = 2147483647; + private ListenerManager m_listenerManager; private Queue m_pending; private Queue m_pendingQ; @@ -311,6 +313,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) { error = null; + + if (channel == DEBUG_CHANNEL) + return true; + // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); @@ -319,7 +325,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm // Send message to avatar if (channel == 0) { - m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); + // Channel 0 goes to viewer ONLY + m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false, false, target); + return true; } List attachments = sp.GetAttachments(); @@ -351,12 +359,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm return true; } - // Need to toss an error here - if (channel == 0) - { - error = "Cannot use llRegionSayTo to message objects on channel 0"; - return false; - } + SceneObjectPart part = m_scene.GetSceneObjectPart(target); + if (part == null) // Not even an object + return true; // No error foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { -- cgit v1.1 From a1a22a2f1034a1feb67b141abf4b138248cdb356 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 28 Jun 2012 22:02:20 +0100 Subject: Revert "Mantis 5977 Corrections to llRegionSayTo" This reverts commit 679da63da617d031e5e7ae3f2d2a29db1a23ace3. Conflicts: OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs --- .../Scripting/WorldComm/WorldCommModule.cs | 70 +++++++++++----------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 8358bc0..176c86d 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -308,56 +308,56 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm /// /// Message. /// - public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) + public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) { + error = null; // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); if (sp != null) { - // ignore if a child agent this is restricted to inside one region - if (sp.IsChildAgent) - return; - - // Send message to the avatar. - // Channel zero only goes to the avatar - // non zero channel messages only go to the attachments + // Send message to avatar if (channel == 0) { - m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); - } - else - { - List attachments = sp.GetAttachments(); - if (attachments.Count == 0) - return; + m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); + } - // Get uuid of attachments - List targets = new List(); - foreach (SceneObjectGroup sog in attachments) - { - if (!sog.IsDeleted) - targets.Add(sog.UUID); - } + List attachments = sp.GetAttachments(); - // Need to check each attachment - foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) - { - if (li.GetHostID().Equals(id)) - continue; + if (attachments.Count == 0) + return true; - if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) - continue; + // Get uuid of attachments + List targets = new List(); + foreach (SceneObjectGroup sog in attachments) + { + if (!sog.IsDeleted) + targets.Add(sog.UUID); + } - if (targets.Contains(li.GetHostID())) - QueueMessage(new ListenerInfo(li, name, id, msg)); - } + // Need to check each attachment + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + { + if (li.GetHostID().Equals(id)) + continue; + + if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) + continue; + + if (targets.Contains(li.GetHostID())) + QueueMessage(new ListenerInfo(li, name, id, msg)); } - return; + return true; + } + + // Need to toss an error here + if (channel == 0) + { + error = "Cannot use llRegionSayTo to message objects on channel 0"; + return false; } - // No avatar found so look for an object foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { // Dont process if this message is from yourself! @@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } - return; + return true; } protected void QueueMessage(ListenerInfo li) -- cgit v1.1 From 02cb0bf80a0b67eb0316ac74e1ea9741bfce1385 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Jul 2012 17:40:02 +0100 Subject: added a timeout paramenter to PollServiceEventArgs, so each type can define it's timeout --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index a701b46..e93266c 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_HttpServer.AddPollServiceHTTPHandler( uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); + new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_HttpsServer.AddPollServiceHTTPHandler( uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); + new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } -- cgit v1.1 From 4854d779041e987ae13de4f30a37e4fab1b7a3d7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jul 2012 23:09:20 +0200 Subject: Add an EventType enum and Type field to the poll service event args. This allows the manager to tell what type of event it is. All events except for lsl http in go to the "slow queue" which is run once per second as before. --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index e93266c..9c5596b 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -172,9 +172,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string uri = "/lslhttp/" + urlcode.ToString(); - m_HttpServer.AddPollServiceHTTPHandler( - uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); + PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); + args.Type = PollServiceEventArgs.EventType.LslHttp; + m_HttpServer.AddPollServiceHTTPHandler(uri, args); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -422,7 +422,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) { - UrlData url = null; + UrlData url = null; RequestData requestData = null; lock (m_RequestMap) -- cgit v1.1 From caef55a6366477b093afd92dadff2c42528a4bc7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 01:05:04 +0200 Subject: Set up https to work like http does in the poll handler --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 9c5596b..c0c97c9 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -214,9 +214,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string uri = "/lslhttps/" + urlcode.ToString() + "/"; - m_HttpsServer.AddPollServiceHTTPHandler( - uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); + PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000)); + args.Type = PollServiceEventArgs.EventType.LslHttp; + m_HttpsServer.AddPollServiceHTTPHandler(uri, args); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } -- cgit v1.1 From 6f7b5ef4cb7a7ba5a780fbb602b82d01347957ab Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 02:24:01 +0200 Subject: Fix a double parenthesis typo --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index c0c97c9..6579f07 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -214,7 +214,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string uri = "/lslhttps/" + urlcode.ToString() + "/"; - PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000)); + PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpsServer.AddPollServiceHTTPHandler(uri, args); -- cgit v1.1 From 07b7301c22be2a89de56b5c13a5e30799106ae21 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Jul 2012 11:21:01 +0200 Subject: Make https work in the poll service manager --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 6579f07..dcf49a7 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -199,7 +199,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; + string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString(); UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -212,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_UrlMap[url] = urlData; - string uri = "/lslhttps/" + urlcode.ToString() + "/"; + string uri = "/lslhttps/" + urlcode.ToString(); PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; -- cgit v1.1 From 9163cdd7c17dd7f3732ba2c140b5fc808e5cd17b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 29 Jul 2012 15:09:42 +0200 Subject: Bump number of URLs to 15000 per region --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f4a89bd..e0e358a 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp /// /// Maximum number of external urls that can be set up by this module. /// - private int m_TotalUrls = 5000; + private int m_TotalUrls = 15000; private uint https_port = 0; private IHttpServer m_HttpServer = null; -- cgit v1.1 From 8ad1d790038ac5a46686528f7f6d5827adecfa74 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 4 Aug 2012 11:07:30 +0100 Subject: fix build on win --- .../Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index d039111..ae4d52a 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -596,9 +596,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender } break; case "R": - Font newFont = new Font(myFont, FontStyle.Regular); + Font anewFont = new Font(myFont, FontStyle.Regular); myFont.Dispose(); - myFont = newFont; + myFont = anewFont; break; } } -- cgit v1.1 From 3fb2523f5b324862f4a125c5bdaeff9e512a67c0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 4 Sep 2012 03:20:37 +0200 Subject: Remove debug spam --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index e0e358a..13762f7 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -188,9 +188,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpServer.AddPollServiceHTTPHandler(uri, args); - m_log.DebugFormat( - "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", - uri, itemID, host.Name, host.LocalId); +// m_log.DebugFormat( +// "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", +// uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -234,9 +234,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpsServer.AddPollServiceHTTPHandler(uri, args); - m_log.DebugFormat( - "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", - uri, itemID, host.Name, host.LocalId); +// m_log.DebugFormat( +// "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", +// uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } -- cgit v1.1 From abb4b9fcae6f8091774325615a37e4e44351b9a6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 15:11:59 +0100 Subject: UriModule GetEvents also doesn't need a request body --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 13762f7..d4a4832 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; + args.GetEventsNeedsRequest = false; m_HttpServer.AddPollServiceHTTPHandler(uri, args); // m_log.DebugFormat( -- cgit v1.1 From 7e3eba1064197024690c5b3cae4c2cf87319e48c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 15:41:57 +0100 Subject: Seems nothing actually need the request body for getevents. so change control flag to false --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index d4a4832..13762f7 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -186,7 +186,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; - args.GetEventsNeedsRequest = false; m_HttpServer.AddPollServiceHTTPHandler(uri, args); // m_log.DebugFormat( -- cgit v1.1 From 617f1b9223375a2dda925e26c395901810d37697 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 16:17:49 +0100 Subject: just remove the damm thing --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 13762f7..56221aa 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -444,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } } } - private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) + private Hashtable GetEvents(UUID requestID, UUID sessionID) { UrlData url = null; RequestData requestData = null; -- cgit v1.1 From 461ecd7cf9edebce45ab715901a7f3b02c216e7b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 20 Jan 2013 02:08:38 +0100 Subject: Refactor scripted http request to use async calls rather than hard threads --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 140 +++++++++++++-------- 1 file changed, 87 insertions(+), 53 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a0ae203..5b39794 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest m_pendingRequests.Add(reqID, htc); } - htc.Process(); + htc.SendRequest(); return reqID; } @@ -340,7 +340,6 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public string HttpMIMEType = "text/plain;charset=utf-8"; public int HttpTimeout; public bool HttpVerifyCert = true; - private Thread httpThread; // Request info private UUID _itemID; @@ -374,27 +373,11 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public void Process() { - httpThread = new Thread(SendRequest); - httpThread.Name = "HttpRequestThread"; - httpThread.Priority = ThreadPriority.BelowNormal; - httpThread.IsBackground = true; - _finished = false; - httpThread.Start(); + SendRequest(); } - /* - * TODO: More work on the response codes. Right now - * returning 200 for success or 499 for exception - */ - public void SendRequest() { - HttpWebResponse response = null; - StringBuilder sb = new StringBuilder(); - byte[] buf = new byte[8192]; - string tempString = null; - int count = 0; - try { Request = (HttpWebRequest) WebRequest.Create(Url); @@ -409,13 +392,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { // We could hijack Connection Group Name to identify // a desired security exception. But at the moment we'll use a dummy header instead. -// Request.ConnectionGroupName = "NoVerify"; Request.Headers.Add("NoVerifyCert", "true"); } -// else -// { -// Request.ConnectionGroupName="Verify"; -// } + if (proxyurl != null && proxyurl.Length > 0) { if (proxyexcepts != null && proxyexcepts.Length > 0) @@ -430,10 +409,14 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } foreach (KeyValuePair entry in ResponseHeaders) + { if (entry.Key.ToLower().Equals("user-agent")) Request.UserAgent = entry.Value; else Request.Headers[entry.Key] = entry.Value; + } + + Request.Timeout = HttpTimeout; // Encode outbound data if (OutboundBody.Length > 0) @@ -441,16 +424,78 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest byte[] data = Util.UTF8.GetBytes(OutboundBody); Request.ContentLength = data.Length; - Stream bstream = Request.GetRequestStream(); - bstream.Write(data, 0, data.Length); - bstream.Close(); + Request.BeginGetRequestStream(new AsyncCallback(SendRequestData), this); + return; } - Request.Timeout = HttpTimeout; + Request.BeginGetResponse(new AsyncCallback(ProcessResponse), this); + } + catch (Exception e) + { + // Do nothing. Abort was called. + } + } + + private void SendRequestData(IAsyncResult ar) + { + try + { + byte[] data = Util.UTF8.GetBytes(OutboundBody); + + Stream bstream = Request.EndGetRequestStream(ar); + bstream.Write(data, 0, data.Length); + bstream.Close(); + + Request.BeginGetResponse(new AsyncCallback(ProcessResponse), this); + } + catch (WebException e) + { + // Abort was called. Just go away + if (e.Status == WebExceptionStatus.RequestCanceled) + return; + + // Server errored on request + if (e.Status == WebExceptionStatus.ProtocolError && e.Response != null) + { + HttpWebResponse webRsp = (HttpWebResponse)e.Response; + + Status = (int)webRsp.StatusCode; + + try + { + using (Stream responseStream = webRsp.GetResponseStream()) + { + ResponseBody = responseStream.GetStreamString(); + } + } + catch + { + ResponseBody = webRsp.StatusDescription; + } + finally + { + webRsp.Close(); + } + return; + } + + _finished = true; + } + } + + private void ProcessResponse(IAsyncResult ar) + { + HttpWebResponse response = null; + StringBuilder sb = new StringBuilder(); + byte[] buf = new byte[8192]; + string tempString = null; + int count = 0; + + try + { try { - // execute the request - response = (HttpWebResponse) Request.GetResponse(); + response = (HttpWebResponse) Request.EndGetResponse(ar); } catch (WebException e) { @@ -485,33 +530,22 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest ResponseBody = sb.ToString().Replace("\r", ""); } - catch (Exception e) + catch (WebException e) { - if (e is WebException && ((WebException)e).Status == WebExceptionStatus.ProtocolError) - { - HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; - Status = (int)webRsp.StatusCode; - try - { - using (Stream responseStream = webRsp.GetResponseStream()) - { - ResponseBody = responseStream.GetStreamString(); - } - } - catch - { - ResponseBody = webRsp.StatusDescription; - } - } - else - { - Status = (int)OSHttpStatusCode.ClientErrorJoker; - ResponseBody = e.Message; - } + // Abort was called. Just go away + if (e.Status == WebExceptionStatus.RequestCanceled) + return; + + Status = (int)OSHttpStatusCode.ClientErrorJoker; + ResponseBody = e.Message; _finished = true; return; } + catch (Exception e) + { + // Ignore + } finally { if (response != null) @@ -525,7 +559,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { try { - httpThread.Abort(); + Request.Abort(); } catch (Exception) { -- cgit v1.1 From cf4bf7432a545888e3af8f540f65092aea6f2686 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 20 Jan 2013 15:58:20 +0100 Subject: Revert "Refactor scripted http request to use async calls rather than hard threads" This reverts commit 461ecd7cf9edebce45ab715901a7f3b02c216e7b. --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 140 ++++++++------------- 1 file changed, 53 insertions(+), 87 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 5b39794..a0ae203 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest m_pendingRequests.Add(reqID, htc); } - htc.SendRequest(); + htc.Process(); return reqID; } @@ -340,6 +340,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public string HttpMIMEType = "text/plain;charset=utf-8"; public int HttpTimeout; public bool HttpVerifyCert = true; + private Thread httpThread; // Request info private UUID _itemID; @@ -373,11 +374,27 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public void Process() { - SendRequest(); + httpThread = new Thread(SendRequest); + httpThread.Name = "HttpRequestThread"; + httpThread.Priority = ThreadPriority.BelowNormal; + httpThread.IsBackground = true; + _finished = false; + httpThread.Start(); } + /* + * TODO: More work on the response codes. Right now + * returning 200 for success or 499 for exception + */ + public void SendRequest() { + HttpWebResponse response = null; + StringBuilder sb = new StringBuilder(); + byte[] buf = new byte[8192]; + string tempString = null; + int count = 0; + try { Request = (HttpWebRequest) WebRequest.Create(Url); @@ -392,9 +409,13 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { // We could hijack Connection Group Name to identify // a desired security exception. But at the moment we'll use a dummy header instead. +// Request.ConnectionGroupName = "NoVerify"; Request.Headers.Add("NoVerifyCert", "true"); } - +// else +// { +// Request.ConnectionGroupName="Verify"; +// } if (proxyurl != null && proxyurl.Length > 0) { if (proxyexcepts != null && proxyexcepts.Length > 0) @@ -409,14 +430,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } foreach (KeyValuePair entry in ResponseHeaders) - { if (entry.Key.ToLower().Equals("user-agent")) Request.UserAgent = entry.Value; else Request.Headers[entry.Key] = entry.Value; - } - - Request.Timeout = HttpTimeout; // Encode outbound data if (OutboundBody.Length > 0) @@ -424,78 +441,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest byte[] data = Util.UTF8.GetBytes(OutboundBody); Request.ContentLength = data.Length; - Request.BeginGetRequestStream(new AsyncCallback(SendRequestData), this); - return; + Stream bstream = Request.GetRequestStream(); + bstream.Write(data, 0, data.Length); + bstream.Close(); } - Request.BeginGetResponse(new AsyncCallback(ProcessResponse), this); - } - catch (Exception e) - { - // Do nothing. Abort was called. - } - } - - private void SendRequestData(IAsyncResult ar) - { - try - { - byte[] data = Util.UTF8.GetBytes(OutboundBody); - - Stream bstream = Request.EndGetRequestStream(ar); - bstream.Write(data, 0, data.Length); - bstream.Close(); - - Request.BeginGetResponse(new AsyncCallback(ProcessResponse), this); - } - catch (WebException e) - { - // Abort was called. Just go away - if (e.Status == WebExceptionStatus.RequestCanceled) - return; - - // Server errored on request - if (e.Status == WebExceptionStatus.ProtocolError && e.Response != null) - { - HttpWebResponse webRsp = (HttpWebResponse)e.Response; - - Status = (int)webRsp.StatusCode; - - try - { - using (Stream responseStream = webRsp.GetResponseStream()) - { - ResponseBody = responseStream.GetStreamString(); - } - } - catch - { - ResponseBody = webRsp.StatusDescription; - } - finally - { - webRsp.Close(); - } - return; - } - - _finished = true; - } - } - - private void ProcessResponse(IAsyncResult ar) - { - HttpWebResponse response = null; - StringBuilder sb = new StringBuilder(); - byte[] buf = new byte[8192]; - string tempString = null; - int count = 0; - - try - { + Request.Timeout = HttpTimeout; try { - response = (HttpWebResponse) Request.EndGetResponse(ar); + // execute the request + response = (HttpWebResponse) Request.GetResponse(); } catch (WebException e) { @@ -530,22 +485,33 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest ResponseBody = sb.ToString().Replace("\r", ""); } - catch (WebException e) + catch (Exception e) { - // Abort was called. Just go away - if (e.Status == WebExceptionStatus.RequestCanceled) - return; - - Status = (int)OSHttpStatusCode.ClientErrorJoker; + if (e is WebException && ((WebException)e).Status == WebExceptionStatus.ProtocolError) + { + HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; + Status = (int)webRsp.StatusCode; + try + { + using (Stream responseStream = webRsp.GetResponseStream()) + { + ResponseBody = responseStream.GetStreamString(); + } + } + catch + { + ResponseBody = webRsp.StatusDescription; + } + } + else + { + Status = (int)OSHttpStatusCode.ClientErrorJoker; + ResponseBody = e.Message; + } - ResponseBody = e.Message; _finished = true; return; } - catch (Exception e) - { - // Ignore - } finally { if (response != null) @@ -559,7 +525,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { try { - Request.Abort(); + httpThread.Abort(); } catch (Exception) { -- cgit v1.1 From b7b3063849c8d7299fa0c262e122ff1a050bfdcb Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 20 Jan 2013 18:38:00 +0100 Subject: Implement HTTP Request froma thread pool to avoid packet congestion --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 59 +++++++++++++++++----- 1 file changed, 45 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a0ae203..708b99d 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -42,6 +42,7 @@ using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Mono.Addins; +using Amib.Threading; /***************************************************** * @@ -102,6 +103,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest private Dictionary m_pendingRequests; private Scene m_scene; // private Queue rpcQueue = new Queue(); + public static SmartThreadPool ThreadPool = null; public HttpRequestModule() { @@ -279,7 +281,30 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); + int maxThreads = 50; + + IConfig httpConfig = config.Configs["HttpRequestModule"]; + if (httpConfig != null) + { + maxThreads = httpConfig.GetInt("MaxPoolThreads", maxThreads); + } + m_pendingRequests = new Dictionary(); + + // First instance sets this up for all sims + if (ThreadPool == null) + { + STPStartInfo startInfo = new STPStartInfo(); + startInfo.IdleTimeout = 20000; + startInfo.MaxWorkerThreads = maxThreads; + startInfo.MinWorkerThreads = 5; + startInfo.ThreadPriority = ThreadPriority.BelowNormal; + startInfo.StartSuspended = true; + + ThreadPool = new SmartThreadPool(startInfo); + + ThreadPool.Start(); + } } public void AddRegion(Scene scene) @@ -340,7 +365,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public string HttpMIMEType = "text/plain;charset=utf-8"; public int HttpTimeout; public bool HttpVerifyCert = true; - private Thread httpThread; + public IWorkItemResult WorkItem = null; // Request info private UUID _itemID; @@ -374,12 +399,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public void Process() { - httpThread = new Thread(SendRequest); - httpThread.Name = "HttpRequestThread"; - httpThread.Priority = ThreadPriority.BelowNormal; - httpThread.IsBackground = true; _finished = false; - httpThread.Start(); + + lock (HttpRequestModule.ThreadPool) + WorkItem = HttpRequestModule.ThreadPool.QueueWorkItem(new WorkItemCallback(StpSendWrapper), null); + } + + private object StpSendWrapper(object o) + { + SendRequest(); + return null; } /* @@ -409,13 +438,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { // We could hijack Connection Group Name to identify // a desired security exception. But at the moment we'll use a dummy header instead. -// Request.ConnectionGroupName = "NoVerify"; Request.Headers.Add("NoVerifyCert", "true"); } -// else -// { -// Request.ConnectionGroupName="Verify"; -// } if (proxyurl != null && proxyurl.Length > 0) { if (proxyexcepts != null && proxyexcepts.Length > 0) @@ -485,9 +509,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest ResponseBody = sb.ToString().Replace("\r", ""); } - catch (Exception e) + catch (WebException e) { - if (e is WebException && ((WebException)e).Status == WebExceptionStatus.ProtocolError) + if (e.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; Status = (int)webRsp.StatusCode; @@ -512,6 +536,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest _finished = true; return; } + catch (Exception e) + { + // Don't crash on anything else + } finally { if (response != null) @@ -525,7 +553,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest { try { - httpThread.Abort(); + if (!WorkItem.Cancel()) + { + WorkItem.Abort(); + } } catch (Exception) { -- cgit v1.1 From 9d2e832b85e35edea8bd177df9de4eb3ee18b004 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 24 Jan 2013 18:23:10 +0100 Subject: Null check the response body to make sure we're not crashing the script engine --- .../Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 708b99d..0276267 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -533,6 +533,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest ResponseBody = e.Message; } + if (ResponseBody == null) + ResponseBody = String.Empty; + _finished = true; return; } @@ -546,6 +549,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest response.Close(); } + if (ResponseBody == null) + ResponseBody = String.Empty; + _finished = true; } -- cgit v1.1 From 13fe3546c31376631ebc557b8d379c157b5b7c37 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 17 Feb 2013 17:43:32 +0100 Subject: Correctly remove https:// URLs from the http server. --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index da59eab..24e925e 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public string url; public UUID urlcode; public Dictionary requests; + public bool isSsl; } public class RequestData @@ -184,6 +185,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; + urlData.isSsl = false; urlData.requests = new Dictionary(); m_UrlMap[url] = urlData; @@ -229,6 +231,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; + urlData.isSsl = true; urlData.requests = new Dictionary(); @@ -394,7 +397,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp private void RemoveUrl(UrlData data) { - m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); + if (data.isSsl) + m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/"); + else + m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); } private Hashtable NoEvents(UUID requestID, UUID sessionID) -- cgit v1.1 From 1ef50fef44e4e4df60c00ed7070ab78e076afffb Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 3 Mar 2013 20:30:59 +0100 Subject: Experimental - add void return support to modSendCommand --- .../CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index f6e1d39..f697c24 100644 --- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -262,6 +262,8 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return "modInvokeR"; else if (sid.ReturnType == typeof(object[])) return "modInvokeL"; + else if (sid.ReturnType == typeof(void)) + return "modInvokeN"; m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); } -- cgit v1.1 From a8faed6f76e5bb7936c1bc2b4711b5eeb143173d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 5 May 2013 22:01:07 +0200 Subject: Implement llSetContentType using the new OpenID auth support for authentication --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 51 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f2922d6..2a4d440 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public UUID urlcode; public Dictionary requests; public bool isSsl; + public Scene scene; } public class RequestData @@ -66,6 +67,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public int startTime; public bool responseSent; public string uri; + public bool allowResponseType = false; + public UUID hostID; + public Scene scene; } /// @@ -171,6 +175,17 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void RemoveRegion(Scene scene) { + // Drop references to that scene + foreach (KeyValuePair kvp in m_UrlMap) + { + if (kvp.Value.scene == scene) + kvp.Value.scene = null; + } + foreach (KeyValuePair kvp in m_RequestMap) + { + if (kvp.Value.scene == scene) + kvp.Value.scene = null; + } } public void Close() @@ -198,6 +213,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.urlcode = urlcode; urlData.isSsl = false; urlData.requests = new Dictionary(); + urlData.scene = host.ParentGroup.Scene; m_UrlMap[url] = urlData; @@ -316,6 +332,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (!urlData.requests[request].responseSent) { string responseBody = body; + + // If we have no OpenID from built-in browser, disable this + if (!urlData.requests[request].allowResponseType) + urlData.requests[request].responseType = "text/plain"; + if (urlData.requests[request].responseType.Equals("text/plain")) { string value; @@ -532,7 +553,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp //put response response["int_response_code"] = requestData.responseCode; response["str_response_string"] = requestData.responseBody; - response["content_type"] = "text/plain"; + response["content_type"] = requestData.responseType; response["keepalive"] = false; response["reusecontext"] = false; @@ -600,6 +621,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp requestData.requestDone = false; requestData.startTime = System.Environment.TickCount; requestData.uri = uri; + requestData.hostID = url.hostID; + requestData.scene = url.scene; if (requestData.headers == null) requestData.headers = new Dictionary(); @@ -608,6 +631,32 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string key = (string)header.Key; string value = (string)header.Value; requestData.headers.Add(key, value); + if (key == "cookie") + { + string[] parts = value.Split(new char[] {'='}); + if (parts[0] == "agni_sl_session_id" && parts.Length > 1) + { + string cookie = Uri.UnescapeDataString(parts[1]); + string[] crumbs = cookie.Split(new char[] {':'}); + UUID owner; + if (crumbs.Length == 2 && UUID.TryParse(crumbs[0], out owner)) + { + if (crumbs[1].Length == 32) + { + Scene scene = requestData.scene; + if (scene != null) + { + SceneObjectPart host = scene.GetSceneObjectPart(requestData.hostID); + if (host != null) + { + if (host.OwnerID == owner) + requestData.allowResponseType = true; + } + } + } + } + } + } } foreach (DictionaryEntry de in request) { -- cgit v1.1 From 4002cd96a52eaefa94e1fe032c90826b5210bb9a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 20 Sep 2014 20:42:07 +0200 Subject: When sending http requests, close the response stream instead of waiting for the finalizer to do it, if it ever does. --- .../Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 5541063..d27869a 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -465,6 +465,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public void SendRequest() { HttpWebResponse response = null; + Stream resStream = null; StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; string tempString = null; @@ -547,7 +548,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest Status = (int)response.StatusCode; - Stream resStream = response.GetResponseStream(); + resStream = response.GetResponseStream(); do { @@ -605,6 +606,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } finally { + if (resStream != null) + resStream.Close(); if (response != null) response.Close(); } -- cgit v1.1 From 6794508f8cd631315a2bbae68a0dcae6a9cd7845 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 13 Oct 2014 11:41:11 +0100 Subject: reduce minimum number of smartpool threads and name it --- .../Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index d27869a..c73d81b 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -320,7 +320,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); - int maxThreads = 50; + int maxThreads = 15; IConfig httpConfig = config.Configs["HttpRequestModule"]; if (httpConfig != null) @@ -336,12 +336,12 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest STPStartInfo startInfo = new STPStartInfo(); startInfo.IdleTimeout = 20000; startInfo.MaxWorkerThreads = maxThreads; - startInfo.MinWorkerThreads = 5; + startInfo.MinWorkerThreads = 1; startInfo.ThreadPriority = ThreadPriority.BelowNormal; startInfo.StartSuspended = true; ThreadPool = new SmartThreadPool(startInfo); - + ThreadPool.Name = "ScriptsHttpReq"; ThreadPool.Start(); } } -- cgit v1.1 From cd87c4bec5490311d47e401acab3915f394f1a22 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 13 Oct 2014 12:00:31 +0100 Subject: change/fix previus commits --- OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index c73d81b..6880f56 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -339,9 +339,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest startInfo.MinWorkerThreads = 1; startInfo.ThreadPriority = ThreadPriority.BelowNormal; startInfo.StartSuspended = true; + startInfo.ThreadPoolName = "ScriptsHttpReq"; ThreadPool = new SmartThreadPool(startInfo); - ThreadPool.Name = "ScriptsHttpReq"; ThreadPool.Start(); } } -- cgit v1.1 From 07dead7dcb8b0f2a27a50748e4a460d9669903fc Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 29 Mar 2015 14:25:12 -0700 Subject: varregion: any conversions of use of Constants.RegionSize converted into Util.cs routines to convert region coords to and from world coords or handles. --- OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index d943b20..4e7ad75 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -213,8 +213,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules if (part != null) { ObjectRegionName = s.RegionInfo.RegionName; - uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); - uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); + uint localX = s.RegionInfo.WorldLocX; + uint localY = s.RegionInfo.WorldLocY; ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; return part; } -- cgit v1.1