From 13b2ac14253a5f9ec75ec9712d1fd2fe17d1d005 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 4 May 2014 20:54:42 -0700 Subject: Makes it possible to support grids in which all the simulators share all central services of a Robust server EXCEPT assets. In other words, grids where the simulators' assets are kept in one DB and the users' inventory assets are kept on another. When users rez items from inventory or take objects from world, an HG-like asset copy takes place between the 2 servers, the world asset server and the user's asset server. This makes the simulators independent of the central asset server. Note that this an advanced configuration and requires some security strengthening coming up. --- .../InventoryAccess/HGInventoryAccessModule.cs | 100 +++++++++++++++++---- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 15 +++- bin/config-include/GridCommon.ini.example | 12 ++- 3 files changed, 103 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index ce7ed26..283a0cf 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -64,6 +64,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess private bool m_bypassPermissions = true; + // This simple check makes it possible to support grids in which all the simulators + // share all central services of the Robust server EXCEPT assets. In other words, + // grids where the simulators' assets are kept in one DB and the users' inventory assets + // are kept on another. When users rez items from inventory or take objects from world, + // an HG-like asset copy takes place between the 2 servers, the world asset server and + // the user's asset server. + private bool m_CheckSeparateAssets = false; + private string m_LocalAssetsURL = string.Empty; + // private bool m_Initialized = false; #region INonSharedRegionModule @@ -99,6 +108,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); + m_CheckSeparateAssets = thisModuleConfig.GetBoolean("CheckSeparateAssets", false); + m_LocalAssetsURL = thisModuleConfig.GetString("RegionHGAssetServerURI", string.Empty); + m_LocalAssetsURL = m_LocalAssetsURL.Trim(new char[] { '/' }); + } else m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); @@ -293,41 +306,92 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) { - string userAssetServer = string.Empty; - if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) - m_assMapper.Get(item.AssetID, sender, userAssetServer); + string senderAssetServer = string.Empty; + string receiverAssetServer = string.Empty; + bool isForeignSender, isForeignReceiver; + isForeignSender = IsForeignUser(sender, out senderAssetServer); + isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer); + + // They're both local. Nothing to do. + if (!isForeignSender && !isForeignReceiver) + return; + + // At least one of them is foreign. + // If both users have the same asset server, no need to transfer the asset + if (senderAssetServer.Equals(receiverAssetServer)) + { + m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer."); + return; + } - if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) - m_assMapper.Post(item.AssetID, receiver, userAssetServer); + if (isForeignSender && senderAssetServer != string.Empty) + m_assMapper.Get(item.AssetID, sender, senderAssetServer); + + if (isForeignReceiver && receiverAssetServer != string.Empty && m_OutboundPermission) + m_assMapper.Post(item.AssetID, receiver, receiverAssetServer); } public override bool IsForeignUser(UUID userID, out string assetServerURL) { assetServerURL = string.Empty; - if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) - { // foreign - ScenePresence sp = null; - if (m_Scene.TryGetScenePresence(userID, out sp)) + if (UserManagementModule != null) + { + if (!m_CheckSeparateAssets) { - AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); - if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) - { - assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); - assetServerURL = assetServerURL.Trim(new char[] { '/' }); + if (!UserManagementModule.IsLocalGridUser(userID)) + { // foreign + ScenePresence sp = null; + if (m_Scene.TryGetScenePresence(userID, out sp)) + { + AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) + { + assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); + assetServerURL = assetServerURL.Trim(new char[] { '/' }); + } + } + else + { + assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); + assetServerURL = assetServerURL.Trim(new char[] { '/' }); + } + return true; } } else { - assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); - assetServerURL = assetServerURL.Trim(new char[] { '/' }); + if (IsLocalInventoryAssetsUser(userID, out assetServerURL)) + { + m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL); + return false; + } + else + { + m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL); + return true; + } } - return true; } - return false; } + private bool IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL) + { + assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI"); + if (assetsURL == string.Empty) + { + AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid); + if (agent != null) + { + assetsURL = agent.ServiceURLs["AssetServerURI"].ToString(); + assetsURL = assetsURL.Trim(new char[] { '/' }); + } + } + return m_LocalAssetsURL.Equals(assetsURL); + } + + protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) { InventoryItemBase item = base.GetItem(agentID, itemID); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index bb9f457..64da5f6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -125,13 +125,18 @@ namespace OpenSim.Region.Framework.Scenes return false; } + } + + public bool AddInventoryItem(InventoryItemBase item) + { + return AddInventoryItem(item, true); } /// /// Add the given inventory item to a user's inventory. /// /// - public bool AddInventoryItem(InventoryItemBase item) + public bool AddInventoryItem(InventoryItemBase item, bool trigger) { if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) { @@ -140,7 +145,8 @@ namespace OpenSim.Region.Framework.Scenes { userlevel = 1; } - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); + if (trigger) + EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); return true; } @@ -179,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes { userlevel = 1; } - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); + if (trigger) + EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); if (originalFolder != UUID.Zero) { @@ -751,7 +758,7 @@ namespace OpenSim.Region.Framework.Scenes IInventoryAccessModule invAccess = RequestModuleInterface(); if (invAccess != null) invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); - AddInventoryItem(itemCopy); + AddInventoryItem(itemCopy, false); if (!Permissions.BypassPermissions()) { diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 5460c0a..59eebd8 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -160,13 +160,21 @@ HomeURI = "http://mygridserver.com:8002" Gatekeeper = "http://mygridserver.com:8002" ;; If you want to protect your assets from being copied by foreign visitors - ;; uncomment the next line. You may want to do this on sims that have licensed content. - ; OutboundPermission = False + ;; set this to false. You may want to do this on sims that have licensed content. + ;; Default is true. + ; OutboundPermission = True ;; Send visual reminder to local users that their inventories are unavailable while they are traveling ;; and available when they return. True by default. ;RestrictInventoryAccessAbroad = True + ;; Warning: advanced and unusual. Default is false. + ;; Enables configurations where grids share user services, including inventory, + ;; while separating regions' assets from users' assets. Asset transfer between + ;; the users' asset server and the regions' asset server is done in HG-like manner. + ; CheckSeparateAssets = false + ; RegionHGAssetServerURI = http://mygridserver.com:8002 + [HGAssetService] ; -- cgit v1.1 From 2fbafc74655892aa5f660a3ed840fa8c19f7e1d8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 May 2014 22:37:26 +0100 Subject: Add Matt Lehmann to contributors --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index f378925..fa79ea7 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -127,6 +127,7 @@ what it is today. * maimedleech * Mana Janus * MarcelEdward +* Matt Lehmann * Mic Bowman * Michelle Argus * Michael Cortez (The Flotsam Project, http://osflotsam.org/) -- cgit v1.1 From 812f5e124df0ef77a24c4937cc35cef0cac13cad Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 7 May 2014 18:39:56 +0100 Subject: Remove duplicate HypergridLinker entry from [GridService] in Robust.HG.ini.example --- bin/Robust.HG.ini.example | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 14e9bff..3dd984e 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -163,8 +163,6 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset [GridService] LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" - HypergridLinker = true - ; Realm = "regions" ; AllowDuplicateNames = "True" -- cgit v1.1 From 2b33677402c3a18ed753e78e02bb191bfcdcee5b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 7 May 2014 23:32:02 +0100 Subject: Add GridUserService service config to [UserAccountService] in Robust[.HG].ini.example so that home can be set for new users rather than always warning that it can't be set. Code already exists to do this but forgot to put entry into config files a long time ago. Thanks to AliciaRaven for the spot. Relates to http://opensimulator.org/mantis/view.php?id=7155 --- bin/Robust.HG.ini.example | 1 + bin/Robust.ini.example | 1 + 2 files changed, 2 insertions(+) diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 3dd984e..e385200 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -282,6 +282,7 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 829e393..2f1a627 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -240,6 +240,7 @@ MapGetServiceConnector = "8002/OpenSim.Server.Handlers.dll:MapGetServiceConnecto GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. -- cgit v1.1 From 3db9b847bfc9d1b2619e3467ba4bc34d9d4e5edc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 7 May 2014 16:59:11 -0700 Subject: Allow Tools.Configger to take -inifile as argument --- OpenSim/Tools/Configger/ConfigurationLoader.cs | 12 ++++++------ OpenSim/Tools/Configger/Main.cs | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OpenSim/Tools/Configger/ConfigurationLoader.cs b/OpenSim/Tools/Configger/ConfigurationLoader.cs index 0b6ee9c..4820e0b 100644 --- a/OpenSim/Tools/Configger/ConfigurationLoader.cs +++ b/OpenSim/Tools/Configger/ConfigurationLoader.cs @@ -64,14 +64,14 @@ namespace OpenSim.Tools.Configger /// /// /// A configuration that gets passed to modules - public IConfigSource LoadConfigSettings() + public IConfigSource LoadConfigSettings(IConfig startupConfig) { bool iniFileExists = false; List sources = new List(); - string iniFileName = "OpenSim.ini"; - string iniFilePath = Path.Combine(".", iniFileName); + string iniFileName = startupConfig.GetString("inifile", Path.Combine(".", "OpenSim.ini")); + Console.WriteLine("---> " + iniFileName + " <---"); if (IsUri(iniFileName)) { @@ -80,10 +80,10 @@ namespace OpenSim.Tools.Configger } else { - if (File.Exists(iniFilePath)) + if (File.Exists(iniFileName)) { - if (!sources.Contains(iniFilePath)) - sources.Add(iniFilePath); + if (!sources.Contains(iniFileName)) + sources.Add(iniFileName); } } diff --git a/OpenSim/Tools/Configger/Main.cs b/OpenSim/Tools/Configger/Main.cs index 61a12e3..d7d918b 100644 --- a/OpenSim/Tools/Configger/Main.cs +++ b/OpenSim/Tools/Configger/Main.cs @@ -35,15 +35,16 @@ namespace OpenSim.Tools.Configger public static int Main(string[] args) { ArgvConfigSource argvConfig = new ArgvConfigSource(args); + argvConfig.AddSwitch("Startup", "format", "f"); + argvConfig.AddSwitch("Startup", "inifile"); IConfig startupConfig = argvConfig.Configs["Startup"]; string format = startupConfig.GetString("format", "ini"); ConfigurationLoader loader = new ConfigurationLoader(); - - IConfigSource s = loader.LoadConfigSettings(); + IConfigSource s = loader.LoadConfigSettings(startupConfig); if (format == "mysql") { -- cgit v1.1 From 093705efd17ae015ee1383ab8086aca33d3f2168 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 7 May 2014 17:19:57 -0700 Subject: Delete extraneous console message in the Configger. --- OpenSim/Tools/Configger/ConfigurationLoader.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Tools/Configger/ConfigurationLoader.cs b/OpenSim/Tools/Configger/ConfigurationLoader.cs index 4820e0b..f1d3649 100644 --- a/OpenSim/Tools/Configger/ConfigurationLoader.cs +++ b/OpenSim/Tools/Configger/ConfigurationLoader.cs @@ -71,7 +71,6 @@ namespace OpenSim.Tools.Configger List sources = new List(); string iniFileName = startupConfig.GetString("inifile", Path.Combine(".", "OpenSim.ini")); - Console.WriteLine("---> " + iniFileName + " <---"); if (IsUri(iniFileName)) { -- cgit v1.1 From a845c1a893a203f1a9bc38dc754a6f94e4c02ea5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 7 May 2014 19:38:33 -0700 Subject: Finished implementing redirects in GetTexture. --- .../Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 12 ++++++++---- .../Handlers/GetTexture/GetTextureServerConnector.cs | 4 +++- .../Handlers/GetTexture/Tests/GetTextureHandlerTests.cs | 2 +- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 9 ++++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 7b3124a..4dfa847 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -56,12 +56,15 @@ namespace OpenSim.Capabilities.Handlers public const string DefaultFormat = "x-j2c"; // TODO: Change this to a config option - const string REDIRECT_URL = null; + private string m_RedirectURL = null; - public GetTextureHandler(string path, IAssetService assService, string name, string description) + public GetTextureHandler(string path, IAssetService assService, string name, string description, string redirectURL) : base("GET", path, name, description) { m_assetService = assService; + m_RedirectURL = redirectURL; + if (!m_RedirectURL.EndsWith("/")) + m_RedirectURL += "/"; } protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) @@ -134,7 +137,7 @@ namespace OpenSim.Capabilities.Handlers if (format != DefaultFormat) fullID = fullID + "-" + format; - if (!String.IsNullOrEmpty(REDIRECT_URL)) + if (!String.IsNullOrEmpty(m_RedirectURL)) { // Only try to fetch locally cached textures. Misses are redirected texture = m_assetService.GetCached(fullID); @@ -150,8 +153,9 @@ namespace OpenSim.Capabilities.Handlers } else { - string textureUrl = REDIRECT_URL + textureID.ToString(); + string textureUrl = m_RedirectURL + textureID.ToString(); m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); + httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently; httpResponse.RedirectLocation = textureUrl; return true; } diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs index 71cf033..fa0b228 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs @@ -62,8 +62,10 @@ namespace OpenSim.Capabilities.Handlers if (m_AssetService == null) throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); + string rurl = serverConfig.GetString("GetTextureRedirectURL"); + ; server.AddStreamHandler( - new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null)); + new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null, rurl)); } } } \ No newline at end of file diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs index d4d6d10..8ffafa4 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs @@ -52,7 +52,7 @@ namespace OpenSim.Capabilities.Handlers.GetTexture.Tests // Overkill - we only really need the asset service, not a whole scene. Scene scene = new SceneHelpers().SetupScene(); - GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null); + GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null, null); TestOSHttpRequest req = new TestOSHttpRequest(); TestOSHttpResponse resp = new TestOSHttpResponse(); req.Url = new Uri("http://localhost/?texture_id=00000000-0000-1111-9999-000000000012"); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 54cf285..bb932f2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_Enabled = false; // TODO: Change this to a config option - const string REDIRECT_URL = null; + private string m_RedirectURL = null; private string m_URL; @@ -78,7 +78,10 @@ namespace OpenSim.Region.ClientStack.Linden m_URL = config.GetString("Cap_GetTexture", string.Empty); // Cap doesn't exist if (m_URL != string.Empty) + { m_Enabled = true; + m_RedirectURL = config.GetString("GetTextureRedirectURL"); + } } public void AddRegion(Scene s) @@ -132,14 +135,14 @@ namespace OpenSim.Region.ClientStack.Linden // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); caps.RegisterHandler( "GetTexture", - new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString())); + new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString(), m_RedirectURL)); } else { // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); IExternalCapsModule handler = m_scene.RequestModuleInterface(); if (handler != null) - handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture",m_URL); + handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture", m_URL); else caps.RegisterHandler("GetTexture", m_URL); } -- cgit v1.1 From a31393ba0becd593977fe85c79fb26746c42756e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 8 May 2014 11:18:17 -0700 Subject: Make the URL for texture redirects match the path of the resource that we use in OpenSim. --- OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 4dfa847..48d637c 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -153,7 +153,7 @@ namespace OpenSim.Capabilities.Handlers } else { - string textureUrl = m_RedirectURL + textureID.ToString(); + string textureUrl = m_RedirectURL + "?texture_id="+ textureID.ToString(); m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently; httpResponse.RedirectLocation = textureUrl; -- cgit v1.1 From afb938e5792e113dcae311b49b240204671b7028 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 8 May 2014 11:30:45 -0700 Subject: Fix test breakage --- OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 48d637c..828e943 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -63,7 +63,7 @@ namespace OpenSim.Capabilities.Handlers { m_assetService = assService; m_RedirectURL = redirectURL; - if (!m_RedirectURL.EndsWith("/")) + if (m_RedirectURL != null && !m_RedirectURL.EndsWith("/")) m_RedirectURL += "/"; } -- cgit v1.1 From f41809e07d354654642f45583ec759024d83db05 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 May 2014 22:39:17 +0100 Subject: minor: Capitalize Hypergrid help category like others --- OpenSim/Services/GridService/HypergridLinker.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index c6d2ee3..09c7938 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -156,18 +156,18 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance != null) { - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", "link-region []", "Link a HyperGrid Region. Examples for : http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region", "link-region []", "Link a hypergrid region (deprecated)", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region", "unlink-region ", "Unlink a hypergrid region", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [ ]", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [ ]", "Set local coordinate to map HG regions to", RunCommand); - MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks", + MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks", "List the HG regions", HandleShow); } } -- cgit v1.1 From 667a272cce75dbfd39c30bff9a5d9999bbacb460 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 May 2014 11:06:03 -0700 Subject: This little sucker had evaded my attention forever. As a consequence some assets associated with foreign users were being missed. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 38 ++++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 53217a0..c28e58d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -8949,7 +8949,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString(); - return ((Scene)Scene).AssetService.Get(assetServer + "/" + id); + if (!string.IsNullOrEmpty(assetServer)) + return ((Scene)Scene).AssetService.Get(assetServer + "/" + id); } return null; @@ -12658,16 +12659,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (asset == null) { - req.AssetInf = null; - req.AssetRequestSource = source; - req.IsTextureRequest = false; - req.NumPackets = 0; - req.Params = transferRequest.TransferInfo.Params; - req.RequestAssetID = requestID; - req.TransferRequestID = transferRequest.TransferInfo.TransferID; + // Try the user's asset server + IInventoryAccessModule inventoryAccessModule = Scene.RequestModuleInterface(); + + string assetServerURL = string.Empty; + if (inventoryAccessModule.IsForeignUser(AgentId, out assetServerURL) && !string.IsNullOrEmpty(assetServerURL)) + { + if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("=")) + assetServerURL = assetServerURL + "/"; + + //m_log.DebugFormat("[LLCLIENTVIEW]: asset {0} not found in local storage. Trying user's storage.", assetServerURL + id); + asset = m_scene.AssetService.Get(assetServerURL + id); + } + + if (asset == null) + { + req.AssetInf = null; + req.AssetRequestSource = source; + req.IsTextureRequest = false; + req.NumPackets = 0; + req.Params = transferRequest.TransferInfo.Params; + req.RequestAssetID = requestID; + req.TransferRequestID = transferRequest.TransferInfo.TransferID; + + SendAssetNotFound(req); + return; + } - SendAssetNotFound(req); - return; } if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) -- cgit v1.1 From bf8f64e40eb0766de1f671bf05f985e422761ea8 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 12 May 2014 08:54:31 +0300 Subject: Fixed error if a user didn't have a "Current Outfit" folder in their suitcase. This fixes http://opensimulator.org/mantis/view.php?id=7161 --- .../HypergridService/HGSuitcaseInventoryService.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 3de2330..4416995 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -122,7 +122,7 @@ namespace OpenSim.Services.HypergridService } List tree = GetFolderTree(principalID, suitcase.folderID); - if (tree == null || (tree != null && tree.Count == 0)) + if (tree.Count == 0) return null; List folders = new List(); @@ -537,13 +537,13 @@ namespace OpenSim.Services.HypergridService private List GetFolderTree(UUID principalID, UUID folder) { - List t = null; + List t; if (m_SuitcaseTrees.TryGetValue(principalID, out t)) return t; // Get the tree of the suitcase folder t = GetFolderTreeRecursive(folder); - m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes + m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5 minutes return t; } @@ -554,8 +554,10 @@ namespace OpenSim.Services.HypergridService new string[] { "parentFolderID" }, new string[] { root.ToString() }); - if (folders == null || (folders != null && folders.Length == 0)) + if (folders == null || folders.Length == 0) + { return tree; // empty tree + } else { foreach (XInventoryFolder f in folders) @@ -588,17 +590,18 @@ namespace OpenSim.Services.HypergridService List tree = new List(); tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); + // Also add the Current Outfit folder to the list of available folders - tree.Add(GetCurrentOutfitXFolder(principalID)); + XInventoryFolder folder = GetCurrentOutfitXFolder(principalID); + if (folder != null) + tree.Add(folder); XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) { - if (fl.folderID == folderID) return true; - else return false; + return (fl.folderID == folderID); }); - if (f == null) return false; - else return true; + return (f != null); } #endregion -- cgit v1.1 From faf9ba53fc10d8abcc9e58e98cc887c1f0f49696 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 19:20:00 +0100 Subject: In SynchronousRestObjectRequester.MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) actually set timeout on WebRequest if given. Previously, we were doing nothing with this parameter. No effect on current code since none of the 6 callers attempt to use the timeout. --- OpenSim/Framework/WebUtil.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 70fab77..2a309a7 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -1116,6 +1116,8 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); HttpWebRequest ht = (HttpWebRequest)request; + ht.Timeout = pTimeout; + if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) ht.ServicePoint.ConnectionLimit = maxConnections; -- cgit v1.1 From 7db4336f1cf612ac8694cd6bd20624d97cf4a7ff Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 22:05:02 +0100 Subject: minor: Add method doc to SynchronousRestObjectRequester.MakeRequest() methods --- OpenSim/Framework/WebUtil.cs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 2a309a7..37ecd46 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -1085,21 +1085,43 @@ namespace OpenSim.Framework /// /// /// - /// - /// - /// - /// Thrown if we encounter a network issue while posting - /// the request. You'll want to make sure you deal with this as they're not uncommon + /// + /// + /// The response. If there was an internal exception, then the default(TResponse) is returned. + /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj) { return MakeRequest(verb, requestUrl, obj, 0); } + /// + /// Perform a synchronous REST request. + /// + /// + /// + /// + /// Request timeout in milliseconds. + /// + /// The response. If there was an internal exception or the request timed out, + /// then the default(TResponse) is returned. + /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout) { return MakeRequest(verb, requestUrl, obj, pTimeout, 0); } + /// + /// Perform a synchronous REST request. + /// + /// + /// + /// + /// Request timeout in milliseconds. + /// + /// + /// The response. If there was an internal exception or the request timed out, + /// then the default(TResponse) is returned. + /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) { int reqnum = WebUtil.RequestNumber++; -- cgit v1.1 From 19d8f05584f67d73539616235a5de2d9f4f56cd4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 22:15:01 +0100 Subject: minor: eliminate unused UUID in xmlrpc GroupsMessagingModule.ProcessMessageFromGroupSession() --- .../Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index fd804cd..f8fcd65 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -431,8 +431,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Add them to the session for now, and Invite them m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); - UUID toAgentID = new UUID(msg.toAgentID); - GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); if (groupInfo != null) { -- cgit v1.1 From 8457044b2f46e477442e3dec520c9a47ca20dd6b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 22:23:24 +0100 Subject: Eliminate subsequently unused scene finding in UndeliveredMessage() method of xmlrpc and core offline IM modules --- OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs | 4 ---- .../Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | 4 ---- 2 files changed, 8 deletions(-) diff --git a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs index 5ef068a..950e1fd 100644 --- a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs +++ b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs @@ -226,10 +226,6 @@ namespace OpenSim.OfflineIM return; } - Scene scene = FindScene(new UUID(im.fromAgentID)); - if (scene == null) - scene = m_SceneList[0]; - string reason = string.Empty; bool success = m_OfflineIMService.StoreMessage(im, out reason); diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 7f3d0a2..bd2b2fe 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs @@ -226,10 +226,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return; } - Scene scene = FindScene(new UUID(im.fromAgentID)); - if (scene == null) - scene = m_SceneList[0]; - bool success = SynchronousRestObjectRequester.MakeRequest( "POST", m_RestURL+"/SaveMessage/", im); -- cgit v1.1 From bbc1dc6bceb18cc1970109c5069724fba84e9c83 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 22:37:07 +0100 Subject: Replace existing 0 timeout in internal overloaded SynchronousRestObjectRequester.MakeRequest() methods with proper Timeout.Infinite (-1) instead. Triggered by recent faf9ba53 though this was wrong in the code before, it's just that we didn't actually try to set the timeout given. --- OpenSim/Framework/WebUtil.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 37ecd46..3b73520 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -36,6 +36,7 @@ using System.Net; using System.Net.Security; using System.Reflection; using System.Text; +using System.Threading; using System.Web; using System.Xml; using System.Xml.Serialization; @@ -1091,7 +1092,7 @@ namespace OpenSim.Framework /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj) { - return MakeRequest(verb, requestUrl, obj, 0); + return MakeRequest(verb, requestUrl, obj, Timeout.Infinite); } /// @@ -1100,7 +1101,7 @@ namespace OpenSim.Framework /// /// /// - /// Request timeout in milliseconds. + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. /// /// The response. If there was an internal exception or the request timed out, /// then the default(TResponse) is returned. @@ -1116,7 +1117,7 @@ namespace OpenSim.Framework /// /// /// - /// Request timeout in milliseconds. + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. /// /// /// The response. If there was an internal exception or the request timed out, -- cgit v1.1 From 515d373a8e5204410797d450def00e87f7c9cd74 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 22:54:54 +0100 Subject: Add send group notice regression test for when MessageOnlineUsersOnly=true --- .../Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index 71f1098..b5a10af 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs @@ -187,5 +187,76 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0)); } + + /// + /// Run test with the MessageOnlineUsersOnly flag set. + /// + [Test] + public void TestSendGroupNoticeOnlineOnly() + { + TestHelpers.InMethod(); + // TestHelpers.EnableLogging(); + + TestScene scene = new SceneHelpers().SetupScene(); + + MessageTransferModule mtm = new MessageTransferModule(); + GroupsModule gm = new GroupsModule(); + GroupsMessagingModule gmm = new GroupsMessagingModule(); + + IConfigSource configSource = new IniConfigSource(); + + { + IConfig config = configSource.AddConfig("Messaging"); + config.Set("MessageTransferModule", mtm.Name); + } + + { + IConfig config = configSource.AddConfig("Groups"); + config.Set("Enabled", true); + config.Set("Module", gm.Name); + config.Set("DebugEnabled", true); + config.Set("MessagingModule", gmm.Name); + config.Set("MessagingEnabled", true); + config.Set("MessageOnlineUsersOnly", true); + } + + SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm); + + UUID userId = TestHelpers.ParseTail(0x1); + string subjectText = "newman"; + string messageText = "Hello"; + string combinedSubjectMessage = string.Format("{0}|{1}", subjectText, messageText); + + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); + TestClient tc = (TestClient)sp.ControllingClient; + + UUID groupID = gm.CreateGroup(tc, "group1", null, true, UUID.Zero, 0, true, true, true); + gm.JoinGroupRequest(tc, groupID); + + // Create a second user who doesn't want to receive notices + ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x2)); + TestClient tc2 = (TestClient)sp2.ControllingClient; + gm.JoinGroupRequest(tc2, groupID); + gm.SetGroupAcceptNotices(tc2, groupID, false, true); + + List spReceivedMessages = new List(); + tc.OnReceivedInstantMessage += im => spReceivedMessages.Add(im); + + List sp2ReceivedMessages = new List(); + tc2.OnReceivedInstantMessage += im => sp2ReceivedMessages.Add(im); + + GridInstantMessage noticeIm = new GridInstantMessage(); + noticeIm.fromAgentID = userId.Guid; + noticeIm.toAgentID = groupID.Guid; + noticeIm.message = combinedSubjectMessage; + noticeIm.dialog = (byte)InstantMessageDialog.GroupNotice; + + tc.HandleImprovedInstantMessage(noticeIm); + + Assert.That(spReceivedMessages.Count, Is.EqualTo(1)); + Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage)); + + Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0)); + } } } \ No newline at end of file -- cgit v1.1 From 87e2668529af4479e3dd94215193ff63ae685148 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 23:30:44 +0100 Subject: For XmlRpcGroups (Flotsam) module, when MessageOnlineUsersOnly = true, handle notices to offline users directly as known undeliverable messages rather than discarding or attempting delivery. Offline notices can still be controlled with the [Messaging] ForwardOfflineGroupMessages setting. Looks to address more of http://opensimulator.org/mantis/view.php?id=7037 Only for Flotsam now for testing, but if approach works should be possible with core offline notices as well. --- .../InstantMessage/HGMessageTransferModule.cs | 4 +-- .../Avatar/InstantMessage/MessageTransferModule.cs | 10 +++--- .../Framework/Interfaces/IMessageTransferModule.cs | 2 ++ .../Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 39 ++++++++++++++-------- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index c51b30f..6f3c80a 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage success = m_IMService.OutgoingInstantMessage(im, url, foreigner); if (!success && !foreigner) - HandleUndeliveredMessage(im, result); + HandleUndeliverableMessage(im, result); else result(success); }); @@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return successful; } - protected void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result) + public void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result) { UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage; diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 40a400f..7aa7123 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage SendGridInstantMessageViaXMLRPC(im, result); } - private void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result) + public void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result) { UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage; @@ -511,14 +511,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (upd.RegionID == prevRegionID) { // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliveredMessage(im, result); + HandleUndeliverableMessage(im, result); return; } } else { // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliveredMessage(im, result); + HandleUndeliverableMessage(im, result); return; } } @@ -567,12 +567,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage else { m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); - HandleUndeliveredMessage(im, result); + HandleUndeliverableMessage(im, result); } } else { - HandleUndeliveredMessage(im, result); + HandleUndeliverableMessage(im, result); } } diff --git a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs index b0b47a7..379c769 100644 --- a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs @@ -37,5 +37,7 @@ namespace OpenSim.Region.Framework.Interfaces event UndeliveredMessage OnUndeliveredMessage; void SendInstantMessage(GridInstantMessage im, MessageResultNotification result); + + void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result); } } diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index f8fcd65..26b70a1 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -248,6 +248,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { List groupMembers = m_groupData.GetGroupMembers(sendingAgentForGroupCalls, groupID); int groupMembersCount = groupMembers.Count; + HashSet attemptDeliveryUuidSet = null; if (m_messageOnlineAgentsOnly) { @@ -263,10 +264,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds); } - HashSet onlineAgentsUuidSet = new HashSet(); - Array.ForEach(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID)); + attemptDeliveryUuidSet + = new HashSet(Array.ConvertAll(onlineAgents, pi => pi.UserID)); - groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList(); + //Array.ForEach(onlineAgents, pi => attemptDeliveryUuidSet.Add(pi.UserID)); + + //groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList(); // if (m_debugEnabled) // m_log.DebugFormat( @@ -275,6 +278,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups } else { + attemptDeliveryUuidSet + = new HashSet(groupMembers.ConvertAll(gmd => gmd.AgentID.ToString())); + if (m_debugEnabled) m_log.DebugFormat( "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", @@ -325,26 +331,33 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups msg.toAgentID = member.AgentID.Guid; - IClientAPI client = GetActiveClient(member.AgentID); - if (client == null) + if (attemptDeliveryUuidSet.Contains(member.AgentID.ToString())) { - // If they're not local, forward across the grid - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); - m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); + IClientAPI client = GetActiveClient(member.AgentID); + if (client == null) + { + // If they're not local, forward across the grid + if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); + m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); + } + else + { + // Deliver locally, directly + if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); + ProcessMessageFromGroupSession(msg, client); + } } else { - // Deliver locally, directly - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); - ProcessMessageFromGroupSession(msg, client); + m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { }); } } // Temporary for assessing how long it still takes to send messages to large online groups. if (m_messageOnlineAgentsOnly) m_log.DebugFormat( - "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} visible members, {2} online took {3}ms", - groupID, groupMembersCount, groupMembers.Count(), Environment.TickCount - requestStartTick); + "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3}ms", + groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick); } #region SimGridEventHandlers -- cgit v1.1 From 8ad29fc5c831fb5e02acaf140cb7fb7a7f5b1f08 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 23:42:47 +0100 Subject: Make offline IM delivery to URL (pre recent Addons code) have a 10 second rather than infinite timeout. This both signals a problem with the URL and eventually frees the thread, rather than hanging indefinitely with no information. --- .../Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index bd2b2fe..c75920d 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs @@ -227,7 +227,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } bool success = SynchronousRestObjectRequester.MakeRequest( - "POST", m_RestURL+"/SaveMessage/", im); + "POST", m_RestURL+"/SaveMessage/", im, 10000); if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) { -- cgit v1.1 From 484aa72ff893df31d7f0ecc186039905ceee7f24 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 May 2014 23:49:37 +0100 Subject: minor: Add some method doc to IMessageTransferModule --- .../Framework/Interfaces/IMessageTransferModule.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs index 379c769..290b826 100644 --- a/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IMessageTransferModule.cs @@ -36,8 +36,26 @@ namespace OpenSim.Region.Framework.Interfaces { event UndeliveredMessage OnUndeliveredMessage; + /// + /// Attempt to send an instant message to a given destination. + /// + /// + /// If the message cannot be delivered for any reason, this will be signalled on the OnUndeliveredMessage + /// event. result(false) will also be called if the message cannot be delievered unless the type is + /// InstantMessageDialog.MessageFromAgent. For successful message delivery, result(true) is called. + /// + /// + /// void SendInstantMessage(GridInstantMessage im, MessageResultNotification result); + /// + /// Appropriately handle a known undeliverable message without attempting a send. + /// + /// + /// Essentially, this invokes the OnUndeliveredMessage event. + /// + /// + /// void HandleUndeliverableMessage(GridInstantMessage im, MessageResultNotification result); } } -- cgit v1.1 From 4569c595bf9f56662c8d434917e78db60514396e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 13 May 2014 22:21:20 +0100 Subject: Fix behaviour change in recent commit bbc1dc6 so that SynchronousRestObjectRequester.MakeRequest() calls with no timeout specified use the default HttpWebRequest timeout as previously. I mistakenly thought that that default request timeout was inifite rather than 100 seconds, restoring previously behaviour. As per http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout%28v=vs.100%29.aspx Relates to http://opensimulator.org/mantis/view.php?id=7165 --- OpenSim/Framework/WebUtil.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 3b73520..0970fd1 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -36,7 +36,6 @@ using System.Net; using System.Net.Security; using System.Reflection; using System.Text; -using System.Threading; using System.Web; using System.Xml; using System.Xml.Serialization; @@ -1092,7 +1091,7 @@ namespace OpenSim.Framework /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj) { - return MakeRequest(verb, requestUrl, obj, Timeout.Infinite); + return MakeRequest(verb, requestUrl, obj, 0); } /// @@ -1101,7 +1100,9 @@ namespace OpenSim.Framework /// /// /// - /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. + /// + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// /// /// The response. If there was an internal exception or the request timed out, /// then the default(TResponse) is returned. @@ -1117,7 +1118,9 @@ namespace OpenSim.Framework /// /// /// - /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. + /// + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// /// /// /// The response. If there was an internal exception or the request timed out, @@ -1139,7 +1142,9 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); HttpWebRequest ht = (HttpWebRequest)request; - ht.Timeout = pTimeout; + + if (pTimeout != 0) + ht.Timeout = pTimeout; if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) ht.ServicePoint.ConnectionLimit = maxConnections; -- cgit v1.1 From c23d37a509bc6ca7bdcba91a61dfd9fb4014639e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 14 May 2014 00:11:07 +0100 Subject: Fix recent asset request timeout issue by commenting out (for now) the m_maxAssetRequestConcurrency mistakenly passed in as a timeout to SynchronousRestObjectRequester.MakeRequest() For a long time, possibly forever, the m_maxAssetRequestConcurrency was mistakenly passed in as a 30 ms timeout rather than as a concurrent connection limiter. This didn't come to light until the timeout was actually used in recent commit faf9ba53 Since this hasn't been operational for a long time and in release candidate phase, commenting it out for now though will need to revisit this. Relates to http://opensimulator.org/mantis/view.php?id=7165 --- .../Connectors/Asset/AssetServicesConnector.cs | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index ee047e0..2ba8e04 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs @@ -117,8 +117,16 @@ namespace OpenSim.Services.Connectors if (asset == null) { - asset = SynchronousRestObjectRequester. - MakeRequest("GET", uri, 0, m_maxAssetRequestConcurrency); + // XXX: Commented out for now since this has either never been properly operational or not for some time + // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option. + // Wasn't noticed before because timeout wasn't actually used. + // Not attempting concurrency setting for now as this omission was discovered in release candidate + // phase for OpenSimulator 0.8. Need to revisit afterwards. +// asset +// = SynchronousRestObjectRequester.MakeRequest( +// "GET", uri, 0, m_maxAssetRequestConcurrency); + + asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0); if (m_Cache != null) m_Cache.Cache(asset); @@ -148,8 +156,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/assets/" + id + "/metadata"; - AssetMetadata asset = SynchronousRestObjectRequester. - MakeRequest("GET", uri, 0); + AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0); return asset; } @@ -290,8 +297,7 @@ namespace OpenSim.Services.Connectors string newID; try { - newID = SynchronousRestObjectRequester. - MakeRequest("POST", uri, asset); + newID = SynchronousRestObjectRequester.MakeRequest("POST", uri, asset); } catch (Exception e) { @@ -337,8 +343,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectRequester. - MakeRequest("POST", uri, asset)) + if (SynchronousRestObjectRequester.MakeRequest("POST", uri, asset)) { if (m_Cache != null) m_Cache.Cache(asset); @@ -352,8 +357,7 @@ namespace OpenSim.Services.Connectors { string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectRequester. - MakeRequest("DELETE", uri, 0)) + if (SynchronousRestObjectRequester.MakeRequest("DELETE", uri, 0)) { if (m_Cache != null) m_Cache.Expire(id); -- cgit v1.1 From 0c0ee95bd8313ecadd828c2e3b1a168984b7ea30 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 14 May 2014 19:22:55 +0100 Subject: minor: Clean up and make consistent some log file messages in EstateManagementModule relating to RAW file uploading. --- .../CoreModules/World/Estate/EstateManagementModule.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index a032bc7..eecc478 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -1106,13 +1106,14 @@ namespace OpenSim.Region.CoreModules.World.Estate TerrainUploader = null; } + + m_log.DebugFormat("[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name); remoteClient.SendAlertMessage("Terrain Upload Complete. Loading...."); + ITerrainModule terr = Scene.RequestModuleInterface(); if (terr != null) { - m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName); - try { MemoryStream terrainStream = new MemoryStream(terrainData); @@ -1161,7 +1162,10 @@ namespace OpenSim.Region.CoreModules.World.Estate { if (TerrainUploader == null) { - m_log.DebugFormat("Starting to receive uploaded terrain"); + m_log.DebugFormat( + "[TERRAIN]: Started receiving terrain upload for region {0} from {1}", + Scene.Name, remote_client.Name); + TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); remote_client.OnXferReceive += TerrainUploader.XferReceive; remote_client.OnAbortXfer += AbortTerrainXferHandler; @@ -1182,7 +1186,7 @@ namespace OpenSim.Region.CoreModules.World.Estate if (terr != null) { - m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName); +// m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName); if (File.Exists(Util.dataDir() + "/terrain.raw")) { File.Delete(Util.dataDir() + "/terrain.raw"); @@ -1194,8 +1198,9 @@ namespace OpenSim.Region.CoreModules.World.Estate input.Read(bdata, 0, (int)input.Length); remote_client.SendAlertMessage("Terrain file written, starting download..."); Scene.XferManager.AddNewFile("terrain.raw", bdata); - // Tell client about it - m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name); + + m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name); + remote_client.SendInitiateDownload("terrain.raw", clientFileName); } } -- cgit v1.1 From 2f7539a25b859d3983ad78106d9cac78abda2b4d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 14 May 2014 21:49:29 +0100 Subject: Remove a race where the client's SP.CompleteMovement() thread could attempt to restart attachment scripts before the source simulator's SP.UpdateAgent() thread had added them. This commit changes the order of code so that attachments are re-added before the CompleteMovement() thread is released. Relates to http://opensimulator.org/mantis/view.php?id=7148 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8c56975..6020a9e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3876,9 +3876,6 @@ namespace OpenSim.Region.Framework.Scenes private void CopyFrom(AgentData cAgent) { - lock (m_originRegionIDAccessLock) - m_originRegionID = cAgent.RegionID; - m_callbackURI = cAgent.CallbackURI; // m_log.DebugFormat( // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", @@ -3951,6 +3948,12 @@ namespace OpenSim.Region.Framework.Scenes if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); + + // This must occur after attachments are copied, as it releases the CompleteMovement() calling thread + // originating from the client completing a teleport. Otherwise, CompleteMovement() code to restart + // script attachments can outrace this thread. + lock (m_originRegionIDAccessLock) + m_originRegionID = cAgent.RegionID; } public bool CopyAgent(out IAgentData agent) -- cgit v1.1 From 7c12dfe18573ab9fa2484fd3402b0fe480e97074 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 14 May 2014 22:08:06 +0100 Subject: On ScenePresence.MakeChildAgent(), reset the m_originRegionID as this is currently being used as a flag to orchestrate destination simulator threads on teleport. If not reset, it's possible that teleports back and forth between simulators may not restart scripts in attachments. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6020a9e..dd4bbe9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1328,6 +1328,11 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); + // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating + // from the source simulator has completed on a V2 teleport. + lock (m_originRegionIDAccessLock) + m_originRegionID = UUID.Zero; + // Reset these so that teleporting in and walking out isn't seen // as teleporting back TeleportFlags = TeleportFlags.Default; -- cgit v1.1 From d32d25634d0a8d257ed3d05abb9e6c70d086b3f5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 May 2014 22:09:37 +0100 Subject: Escape find string in MySQL core groups plugin --- OpenSim/Data/MySQL/MySQLGroupsData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs index 8e39229..afa499e 100644 --- a/OpenSim/Data/MySQL/MySQLGroupsData.cs +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs @@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL if (string.IsNullOrEmpty(pattern)) pattern = "1"; else - pattern = string.Format("Name LIKE '%{0}%'", pattern); + pattern = string.Format("Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern)); return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern)); } -- cgit v1.1 From 6dc1b113d0a7cdf3d7b6d567728d39568f1ed982 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 May 2014 22:45:01 +0100 Subject: Escape find string in PgSQL core groups plugin --- OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs | 18 ++++++++++++++++++ OpenSim/Data/PGSQL/PGSQLGroupsData.cs | 10 +++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs index 2151568..826c6fc 100644 --- a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs +++ b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs @@ -300,9 +300,27 @@ namespace OpenSim.Data.PGSQL m_Realm, where); cmd.Connection = conn; cmd.CommandText = query; + //m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where); + + conn.Open(); + return DoQuery(cmd); + } + } + public virtual T[] Get(string where, NpgsqlParameter parameter) + { + using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + + string query = String.Format("SELECT * FROM {0} WHERE {1}", + m_Realm, where); + cmd.Connection = conn; + cmd.CommandText = query; //m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where); + cmd.Parameters.Add(parameter); + conn.Open(); return DoQuery(cmd); } diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs index ed75b63..15c965b 100644 --- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs @@ -83,11 +83,15 @@ namespace OpenSim.Data.PGSQL public GroupData[] RetrieveGroups(string pattern) { if (string.IsNullOrEmpty(pattern)) // True for where clause + { pattern = " true ORDER BY lower(\"Name\") LIMIT 100"; + return m_Groups.Get(pattern); + } else - pattern = string.Format(" lower(\"Name\") LIKE lower('%{0}%') ORDER BY lower(\"Name\") LIMIT 100", pattern); - - return m_Groups.Get(pattern); + { + pattern = string.Format(" lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100"); + return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); + } } public bool DeleteGroup(UUID groupID) -- cgit v1.1 From d2c738fc09e4b4c9668cf5fb0114f909b6d6b808 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 May 2014 22:48:05 +0100 Subject: Don't warn on not seeing [Groups] Robust section for core groups as this does not contain any mandatory parameters and won't be present on older installations. --- OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs index 828965f..33dc301 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs @@ -64,8 +64,8 @@ namespace OpenSim.Groups key = groupsConfig.GetString("SecretKey", string.Empty); m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key); } - else - m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); +// else +// m_log.DebugFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); m_GroupsService = new GroupsService(config); -- cgit v1.1 From 4a74c4533c80403a664a761dbc871e52e3e7788e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 May 2014 22:51:47 +0100 Subject: minor: eliminate now unnecessary string.Format in postgresql RetrieveGroups method --- OpenSim/Data/PGSQL/PGSQLGroupsData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs index 15c965b..669e3c8 100644 --- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs @@ -89,7 +89,7 @@ namespace OpenSim.Data.PGSQL } else { - pattern = string.Format(" lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100"); + pattern = " lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100"; return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); } } -- cgit v1.1 From 0be9e3b079088829eec49d856980f14a6372fda4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 17 May 2014 20:11:22 -0700 Subject: BulletSim: adjust avatar step up parameters to better walk up small staircases. This change is required because of the change in the avatar default shape from the capsule to the rectangle. --- OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs | 4 ++-- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 1bcf879..1b8a454 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -399,8 +399,8 @@ public class BSActorAvatarMove : BSActor m_controllingPrim.ForcePosition = m_controllingPrim.RawPosition + displacement; } } - m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs.ComputeStairCorrection,disp={1},force={2}", - m_controllingPrim.LocalID, displacement, ret); + m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs.ComputeStairCorrection,stepUp={1},isp={2},force={3}", + m_controllingPrim.LocalID, stepUp, displacement, ret); } return ret; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 6683446..de42a4c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -598,9 +598,9 @@ public static class BSParam new ParameterDefn("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step", 1.0f ), new ParameterDefn("AvatarStepUpCorrectionFactor", "Multiplied by height of step collision to create up movement at step", - 1.0f ), + 2.0f ), new ParameterDefn("AvatarStepSmoothingSteps", "Number of frames after a step collision that we continue walking up stairs", - 2 ), + 1 ), new ParameterDefn("VehicleMaxLinearVelocity", "Maximum velocity magnitude that can be assigned to a vehicle", 1000.0f, -- cgit v1.1 From 922f76a3a766220592bc4ccad3911a66728329a0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 18 May 2014 07:49:01 -0700 Subject: Don't fetch assets from the server when doing simple inventory operations like copy-paste items in inventory. --- .../InventoryAccess/InventoryAccessModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 79 ++++++++-------------- 2 files changed, 29 insertions(+), 52 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index d30ce72..a116f0f 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -203,7 +203,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_Scene.AssetService.Store(asset); m_Scene.CreateNewInventoryItem( remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, - name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); + name, description, 0, callbackID, asset.FullID, asset.Type, invType, nextOwnerMask, creationDate); } else { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3c3d077..71e3032 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -879,50 +879,33 @@ namespace OpenSim.Region.Framework.Scenes return; } - AssetBase asset = AssetService.Get(item.AssetID.ToString()); + if (newName == String.Empty) + newName = item.Name; - if (asset != null) + if (remoteClient.AgentId == oldAgentID + || (LibraryService != null + && LibraryService.LibraryRootFolder != null + && oldAgentID == LibraryService.LibraryRootFolder.Owner)) { - if (newName != String.Empty) - { - asset.Name = newName; - } - else - { - newName = item.Name; - } - - if (remoteClient.AgentId == oldAgentID - || (LibraryService != null - && LibraryService.LibraryRootFolder != null - && oldAgentID == LibraryService.LibraryRootFolder.Owner)) + CreateNewInventoryItem( + remoteClient, item.CreatorId, item.CreatorData, newFolderID, + newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType, + item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, + item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); + } + else + { + // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. + if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) + && (m_permissions.BypassPermissions() + || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) { CreateNewInventoryItem( - remoteClient, item.CreatorId, item.CreatorData, newFolderID, - newName, item.Description, item.Flags, callbackID, asset, (sbyte)item.InvType, - item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, + remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, + item.AssetID, (sbyte)item.AssetType, (sbyte) item.InvType, + item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); } - else - { - // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. - if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) - && (m_permissions.BypassPermissions() - || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) - { - CreateNewInventoryItem( - remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, - asset, (sbyte) item.InvType, - item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, - item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); - } - } - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not copy item {0} since asset {1} could not be found", - item.Name, item.AssetID); } } @@ -973,10 +956,10 @@ namespace OpenSim.Region.Framework.Scenes public void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, string description, uint flags, uint callbackID, - AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) + UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate) { CreateNewInventoryItem( - remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, + remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); } @@ -1001,7 +984,7 @@ namespace OpenSim.Region.Framework.Scenes /// Unix timestamp at which this item was created. private void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, - string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, + string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType, uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) { InventoryItemBase item = new InventoryItemBase(); @@ -1009,11 +992,11 @@ namespace OpenSim.Region.Framework.Scenes item.CreatorId = creatorID; item.CreatorData = creatorData; item.ID = UUID.Random(); - item.AssetID = asset.FullID; + item.AssetID = assetID; item.Name = name; item.Description = description; item.Flags = flags; - item.AssetType = asset.Type; + item.AssetType = assetType; item.InvType = invType; item.Folder = folderID; item.CurrentPermissions = currentMask; @@ -1086,15 +1069,9 @@ namespace OpenSim.Region.Framework.Scenes // return; // } - AssetBase asset = new AssetBase(); - asset.FullID = olditemID; - asset.Type = type; - asset.Name = name; - asset.Description = description; - CreateNewInventoryItem( - remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, - name, description, 0, callbackID, asset, invType, + remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, + name, description, 0, callbackID, olditemID, type, invType, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch()); } -- cgit v1.1 From ab1472e5b7649702aec0585fa4b9d6a5d87948a4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 18 May 2014 23:01:55 -0700 Subject: Don't trigger ItemUploaded when no item has been uploaded. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 71e3032..542d454 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -891,7 +891,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte)item.InvType, item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, - item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); + item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false); } else { @@ -904,7 +904,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, item.AssetID, (sbyte)item.AssetType, (sbyte) item.InvType, item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, - item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); + item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch(), false); } } } @@ -960,7 +960,8 @@ namespace OpenSim.Region.Framework.Scenes { CreateNewInventoryItem( remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType, - (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); + (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, + creationDate, true); } /// @@ -985,7 +986,8 @@ namespace OpenSim.Region.Framework.Scenes private void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType, - uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) + uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate, + bool assetUpload) { InventoryItemBase item = new InventoryItemBase(); item.Owner = remoteClient.AgentId; @@ -1006,7 +1008,7 @@ namespace OpenSim.Region.Framework.Scenes item.BasePermissions = baseMask; item.CreationDate = creationDate; - if (AddInventoryItem(item)) + if (AddInventoryItem(item, assetUpload)) { remoteClient.SendInventoryItemCreateUpdate(item, callbackID); } @@ -1073,7 +1075,8 @@ namespace OpenSim.Region.Framework.Scenes remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, description, 0, callbackID, olditemID, type, invType, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All, - (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch()); + (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, Util.UnixTimeSinceEpoch(), + false); } else { -- cgit v1.1 From 96e5836b50f6615bcea4ae43b238147b027fd5f7 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 15 May 2014 16:09:44 +0300 Subject: When can't rez, show only one error message; not two. And show more specific error messages. --- .../CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 3 --- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 283a0cf..b7de0dc 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -297,9 +297,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, RezSelected, RemoveItem, fromTaskID, attachment); - if (sog == null) - remoteClient.SendAgentAlertMessage("Unable to rez: problem accessing inventory or locating assets", false); - return sog; } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index a116f0f..5cdb70b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -773,12 +773,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_log.WarnFormat( "[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", assetID, item.Name, item.ID, remoteClient.Name); + remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0} for item {1}.", assetID, item.Name), false); } else { m_log.WarnFormat( "[INVENTORY ACCESS MODULE]: Could not find asset {0} for {1} in RezObject()", assetID, remoteClient.Name); + remoteClient.SendAgentAlertMessage(string.Format("Unable to rez: could not find asset {0}.", assetID), false); } return null; -- cgit v1.1 From 882af7195ca6d7ac5f36f4121f65aab1302ad272 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 16 May 2014 13:18:04 +0300 Subject: Better error-handling and logging in case User Profile requests fail --- .../Servers/HttpServer/JsonRpcRequestManager.cs | 24 +++++++++++----------- .../Avatar/UserProfiles/UserProfileModule.cs | 9 ++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs index ed6a14c..2fe1a7d 100644 --- a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs @@ -90,14 +90,14 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (Exception e) { - m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); + m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); return false; } if (!response.ContainsKey("_Result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } response = (OSDMap)response["_Result"]; @@ -107,15 +107,15 @@ namespace OpenSim.Framework.Servers.HttpServer if (response.ContainsKey("error")) { data = response["error"]; - m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", - method, OSDParser.SerializeJsonString(data)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", + method, uri, OSDParser.SerializeJsonString(data)); return false; } if (!response.ContainsKey("result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } @@ -161,14 +161,14 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (Exception e) { - m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); + m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); return false; } if (!response.ContainsKey("_Result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } response = (OSDMap)response["_Result"]; @@ -176,8 +176,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (response.ContainsKey("error")) { data = response["error"]; - m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", - method, OSDParser.SerializeJsonString(data)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", + method, uri, OSDParser.SerializeJsonString(data)); return false; } diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 1ee2a7b..c4b5aac 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -484,6 +484,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating classified", false); + return; } } @@ -510,6 +511,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error classified delete", false); + return; } parameters = (OSDMap)Params; @@ -612,6 +614,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error selecting pick", false); + return; } pick = (UserProfilePick) Pick; @@ -714,6 +717,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating pick", false); + return; } m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString()); @@ -740,6 +744,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error picks delete", false); + return; } } #endregion Picks @@ -807,6 +812,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles object Note = note; if(!rpc.JsonRpcRequest(ref Note, "avatar_notes_update", serverURI, UUID.Random().ToString())) { + remoteClient.SendAgentAlertMessage( + "Error updating note", false); return; } } @@ -916,6 +923,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating interests", false); + return; } } @@ -1044,6 +1052,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles { remoteClient.SendAgentAlertMessage( "Error updating properties", false); + return; } RequestAvatarProperties(remoteClient, newProfile.ID); -- cgit v1.1 From dd30a29ba07a181d5c8f5773140a7247a0066510 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 18 May 2014 16:10:18 +0300 Subject: Return more specific error messages if an attempt to enter a region fails due to permissions (in QueryAccess and IsAuthorizedForRegion) --- .../EntityTransfer/EntityTransferModule.cs | 2 +- .../Authorization/AuthorizationService.cs | 34 +++++++++++++--------- OpenSim/Region/Framework/Scenes/Scene.cs | 15 ++++++++-- .../AuthorizationServicesConnector.cs | 2 +- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 539367d..3830791 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -766,7 +766,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.ControllingClient.SendTeleportFailed(reason); m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because {3}", + "[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because: {3}", sp.Name, sp.Scene.Name, finalDestination.RegionName, reason); return; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs index 4470799..93dff1f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs @@ -89,35 +89,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization public bool IsAuthorizedForRegion( string user, string firstName, string lastName, string regionID, out string message) { - message = "authorized"; - // This should not happen if (m_Scene.RegionInfo.RegionID.ToString() != regionID) { m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}", m_Scene.RegionInfo.RegionID, regionID); - return true; + message = string.Format("Region {0} received request to authorize for region {1}", m_Scene.RegionInfo.RegionID, regionID); + return false; } if (m_accessValue == AccessFlags.None) + { + message = "Authorized"; return true; + } UUID userID = new UUID(user); - bool authorized = true; - if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners) + + if ((m_accessValue & AccessFlags.DisallowForeigners) != 0) { - authorized = m_UserManagement.IsLocalGridUser(userID); - if (!authorized) - message = "no foreigner users allowed in this region"; + if (!m_UserManagement.IsLocalGridUser(userID)) + { + message = "No foreign users allowed in this region"; + return false; + } } - if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents) + + if ((m_accessValue & AccessFlags.DisallowResidents) != 0) { - authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID); - if (!authorized) - message = "only Admins and Managers allowed in this region"; + if (!(m_Scene.Permissions.IsGod(userID) || m_Scene.Permissions.IsAdministrator(userID))) + { + message = "Only Admins and Managers allowed in this region"; + return false; + } } - return authorized; + message = "Authorized"; + return true; } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e6887b4..1115399 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3865,7 +3865,7 @@ namespace OpenSim.Region.Framework.Scenes if (!AuthorizationService.IsAuthorizedForRegion( agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) { - m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because {4}", + m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}", agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason); return false; @@ -5465,7 +5465,7 @@ namespace OpenSim.Region.Framework.Scenes /// public bool QueryAccess(UUID agentID, string agentHomeURI, Vector3 position, out string reason) { - reason = "You are banned from the region"; + reason = string.Empty; if (Permissions.IsGod(agentID)) { @@ -5525,6 +5525,7 @@ namespace OpenSim.Region.Framework.Scenes catch (Exception e) { m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); + reason = "Error authorizing agent: " + e.Message; return false; } @@ -5568,6 +5569,7 @@ namespace OpenSim.Region.Framework.Scenes if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) { // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); + reason = "You are banned from the region on all parcels"; return false; } } @@ -5575,13 +5577,22 @@ namespace OpenSim.Region.Framework.Scenes { ILandObject land = LandChannel.GetLandObject(position.X, position.Y); if (land == null) + { + reason = "No parcel found"; return false; + } bool banned = land.IsBannedFromLand(agentID); bool restricted = land.IsRestrictedFromLand(agentID); if (banned || restricted) + { + if (banned) + reason = "You are banned from the parcel"; + else + reason = "The parcel is restricted"; return false; + } } reason = String.Empty; diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs index 35b7109..63730b3 100644 --- a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs @@ -105,7 +105,7 @@ namespace OpenSim.Services.Connectors catch (Exception e) { m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message); - message = ""; + message = e.Message; return m_ResponseOnFailure; } if (response == null) -- cgit v1.1 From 78733b979fa2f34ef0a0066fc019cb698239e9f5 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 18 May 2014 18:52:57 +0300 Subject: Log the user when an inventory operation is blocked because the item/folder isn't in the Suitcase --- .../HypergridService/HGSuitcaseInventoryService.cs | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 4416995..649e66c 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -249,7 +249,7 @@ namespace OpenSim.Services.HypergridService if (!IsWithinSuitcaseTree(principalID, folderID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} is not within Suitcase tree", folderID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID); return new InventoryCollection(); } @@ -269,7 +269,7 @@ namespace OpenSim.Services.HypergridService // make sure the given folder exists under the suitcase tree of this user if (!IsWithinSuitcaseTree(principalID, folderID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} is not within Suitcase tree", folderID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID); return new List(); } @@ -284,7 +284,7 @@ namespace OpenSim.Services.HypergridService if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} is not within Suitcase tree", folder.ParentID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner); return false; } @@ -306,7 +306,7 @@ namespace OpenSim.Services.HypergridService //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} is not within Suitcase tree", folder.Name, folder.ID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} (user {2}) is not within Suitcase tree", folder.Name, folder.ID, folder.Owner); return false; } @@ -318,13 +318,13 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner); return false; } if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ParentID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner); return false; } @@ -349,7 +349,7 @@ namespace OpenSim.Services.HypergridService // make sure the given folder's parent folder exists under the suitcase tree of this user if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} is not within Suitcase tree", item.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } @@ -362,7 +362,7 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} is not within Suitcase tree", item.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } @@ -378,7 +378,7 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", item.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } } @@ -389,7 +389,7 @@ namespace OpenSim.Services.HypergridService InventoryItemBase originalItem = base.GetItem(item); if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", originalItem.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner); return false; } } @@ -414,8 +414,8 @@ namespace OpenSim.Services.HypergridService if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0}/{1} (folder {2}) is not within Suitcase tree or Appearance", - it.Name, it.ID, it.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetItem: item {0}/{1} (folder {2}) (user {3}) is not within Suitcase tree or Appearance", + it.Name, it.ID, it.Folder, it.Owner); return null; } @@ -437,8 +437,8 @@ namespace OpenSim.Services.HypergridService { if (!IsWithinSuitcaseTree(f.Owner, f.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Folder {0}/{1} is not within Suitcase tree", - f.Name, f.ID); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolder: folder {0}/{1} (user {2}) is not within Suitcase tree", + f.Name, f.ID, f.Owner); return null; } } -- cgit v1.1 From 47b84875fd2b9f01140288a2695c33f5ef4466c0 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 18 May 2014 19:45:27 +0300 Subject: Tell QueryAccess explicitly whether the user is coming in via Teleport or Cross, because the permission checks are different. Previously we used a heuristic of checking if the entry position is 0 to differentiate between Teleport and Cross, but that doesn't work anymore since we've started providing the precise entry position for cross, too. That's required in order to ensure that the user is allowed to enter the parcel that he's walking into. --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 4 ++-- .../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 4 ++-- .../ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | 6 +++--- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 6 +++++- .../Services/Connectors/Simulation/SimulationServiceConnector.cs | 3 ++- OpenSim/Services/Interfaces/ISimulationService.cs | 3 ++- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 3830791..e583590 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -761,7 +761,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason; string version; if (!Scene.SimulationService.QueryAccess( - finalDestination, sp.ControllingClient.AgentId, homeURI, position, out version, out reason)) + finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, out version, out reason)) { sp.ControllingClient.SendTeleportFailed(reason); @@ -1510,7 +1510,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Check to see if we have access to the target region. if (neighbourRegion != null - && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, newpos, out version, out failureReason)) + && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, false, newpos, out version, out failureReason)) { // remember banned m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 3348b42..926ef05 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -264,7 +264,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return true; } - public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason) { reason = "Communications failure"; version = ServiceVersion; @@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // s.RegionInfo.RegionName, destination.RegionHandle); - return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, position, out reason); + return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, out reason); } //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 8436488..0444e49 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return m_remoteConnector.UpdateAgent(destination, cAgentData); } - public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason) { reason = "Communications failure"; version = "Unknown"; @@ -216,12 +216,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; // Try local first - if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason)) + if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason)) return true; // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionID)) - return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason); + return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason); return false; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1115399..3b8fbfd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5463,7 +5463,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public bool QueryAccess(UUID agentID, string agentHomeURI, Vector3 position, out string reason) + public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string reason) { reason = string.Empty; @@ -5529,7 +5529,7 @@ namespace OpenSim.Region.Framework.Scenes return false; } - if (position == Vector3.Zero) // Teleport + if (viaTeleport) { if (!RegionInfo.EstateSettings.AllowDirectTeleport) { diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 06392f7..7291931 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -132,6 +132,10 @@ namespace OpenSim.Server.Handlers.Simulation // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]); OSDMap args = Utils.GetOSDMap((string)request["body"]); + bool viaTeleport = true; + if (args.ContainsKey("viaTeleport")) + viaTeleport = args["viaTeleport"].AsBoolean(); + Vector3 position = Vector3.Zero; if (args.ContainsKey("position")) position = Vector3.Parse(args["position"].AsString()); @@ -145,7 +149,7 @@ namespace OpenSim.Server.Handlers.Simulation string reason; string version; - bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, position, out version, out reason); + bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, out version, out reason); responsedata["int_response_code"] = HttpStatusCode.OK; diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index d9fe5a0..099ba98 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -282,7 +282,7 @@ namespace OpenSim.Services.Connectors.Simulation } - public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason) + public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason) { reason = "Failed to contact destination"; version = "Unknown"; @@ -296,6 +296,7 @@ namespace OpenSim.Services.Connectors.Simulation string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; OSDMap request = new OSDMap(); + request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); request.Add("position", OSD.FromString(position.ToString())); if (agentHomeURI != null) request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 375a35c..8b87ac0 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -83,11 +83,12 @@ namespace OpenSim.Services.Interfaces /// Desired destination /// The visitor's User ID /// The visitor's Home URI. Will be missing (null) in older OpenSims. + /// True: via teleport; False: via cross (walking) /// Position in the region /// /// [out] Optional error message /// True: ok; False: not allowed - bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, out string version, out string reason); + bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string version, out string reason); /// /// Message from receiving region to departing region, telling it got contacted by the client. -- cgit v1.1 From 3a6f3124841ee91778df1d7fa2fbda9893079c6d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 May 2014 22:06:41 +0100 Subject: Fix recent regression from 77e7bbc where an attachment on a received group notice with XmlRpcGroups messaging did not appear in the user's inventory. This was because the "session ID" when the message template was copied was always replaced with the group ID, whereas a notice requires this to be the notice ID. Instead just copy the "session ID" as is - other callers already have this set properly so replacing with group ID was redundant anyway. Relates to http://opensimulator.org/mantis/view.php?id=7037 --- .../Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 7 +++++-- .../Avatar/XmlRpcGroups/GroupsModule.cs | 15 +++++++++++++- .../Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | 9 +++++++- .../Common/Mock/MockGroupsServicesConnector.cs | 24 +++++++++++++++++++++- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 26b70a1..3724a2c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -315,7 +315,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Copy Message GridInstantMessage msg = new GridInstantMessage(); - msg.imSessionID = groupID.Guid; + msg.imSessionID = im.imSessionID; msg.fromAgentName = im.fromAgentName; msg.message = im.message; msg.dialog = im.dialog; @@ -420,7 +420,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) { - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}", + msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog); UUID AgentID = new UUID(msg.fromAgentID); UUID GroupID = new UUID(msg.imSessionID); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index f34152c..8a9e4d2 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -357,7 +357,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) { - if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS]: {0} called for {1}, message type {2}", + System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name, (InstantMessageDialog)im.dialog); // Group invitations if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) @@ -551,6 +554,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups UUID noticeID = new UUID(im.imSessionID); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS]: Requesting notice {0} for {1}", noticeID, remoteClient.AgentId); + GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID); if (notice != null) { @@ -572,6 +578,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); } + else + { + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.", + noticeID, remoteClient.AgentId); + } } // Interop, received special 210 code for ejecting a group member diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index b5a10af..d944087 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs @@ -132,6 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests MessageTransferModule mtm = new MessageTransferModule(); GroupsModule gm = new GroupsModule(); GroupsMessagingModule gmm = new GroupsMessagingModule(); + MockGroupsServicesConnector mgsc = new MockGroupsServicesConnector(); IConfigSource configSource = new IniConfigSource(); @@ -149,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests config.Set("MessagingEnabled", true); } - SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm); + SceneHelpers.SetupSceneModules(scene, configSource, mgsc, mtm, gm, gmm); UUID userId = TestHelpers.ParseTail(0x1); string subjectText = "newman"; @@ -185,6 +186,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests Assert.That(spReceivedMessages.Count, Is.EqualTo(1)); Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage)); + List notices = mgsc.GetGroupNotices(UUID.Zero, groupID); + Assert.AreEqual(1, notices.Count); + + // OpenSimulator (possibly also SL) transport the notice ID as the session ID! + Assert.AreEqual(notices[0].NoticeID.Guid, spReceivedMessages[0].imSessionID); + Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0)); } diff --git a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs index b3f8c36..5a257e9 100644 --- a/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs +++ b/OpenSim/Tests/Common/Mock/MockGroupsServicesConnector.cs @@ -324,7 +324,29 @@ namespace OpenSim.Tests.Common.Mock public List GetGroupNotices(UUID requestingAgentID, UUID groupID) { - return null; + XGroup group = GetXGroup(groupID, null); + + if (group == null) + return null; + + List notices = new List(); + + foreach (XGroupNotice notice in group.notices.Values) + { + GroupNoticeData gnd = new GroupNoticeData() + { + NoticeID = notice.noticeID, + Timestamp = notice.timestamp, + FromName = notice.fromName, + Subject = notice.subject, + HasAttachment = notice.hasAttachment, + AssetType = (byte)notice.assetType + }; + + notices.Add(gnd); + } + + return notices; } public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) -- cgit v1.1 From b46be88db62bcfa7dcf70c3677a1a1270d177a22 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 May 2014 22:45:17 +0100 Subject: Split verbose groups messaging logging into its own setting separate from that of the groups module. This is to allow us to get useful information on messaging without being overwhelmed by the rest of groups debug. Enabled with [Groups] DebugMessagingEnabled = true in config (default false) Or "debug groups messaging verbose true|false on the console" (similar to existing groups setting). Done for both xmlrpc and V2 groups. --- OpenSim/Addons/Groups/GroupsMessagingModule.cs | 34 ++++++- .../Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 100 ++++++++++++++++----- bin/OpenSimDefaults.ini | 3 + 3 files changed, 111 insertions(+), 26 deletions(-) diff --git a/OpenSim/Addons/Groups/GroupsMessagingModule.cs b/OpenSim/Addons/Groups/GroupsMessagingModule.cs index bbb5e05..bd8db32 100644 --- a/OpenSim/Addons/Groups/GroupsMessagingModule.cs +++ b/OpenSim/Addons/Groups/GroupsMessagingModule.cs @@ -56,8 +56,8 @@ namespace OpenSim.Groups private IGroupsServicesConnector m_groupData = null; // Config Options - private bool m_groupMessagingEnabled = false; - private bool m_debugEnabled = true; + private bool m_groupMessagingEnabled; + private bool m_debugEnabled; /// /// If enabled, module only tries to send group IMs to online users by querying cached presence information. @@ -120,7 +120,7 @@ namespace OpenSim.Groups return; } - m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); + m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled); m_log.InfoFormat( "[Groups.Messaging]: GroupsMessagingModule enabled with MessageOnlineOnly = {0}, DebugEnabled = {1}", @@ -140,6 +140,14 @@ namespace OpenSim.Groups scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; scene.EventManager.OnClientLogin += OnClientLogin; + + scene.AddCommand( + "Debug", + this, + "debug groups messaging verbose", + "debug groups messaging verbose ", + "This setting turns on very verbose groups messaging debugging", + HandleDebugGroupsMessagingVerbose); } public void RegionLoaded(Scene scene) @@ -227,6 +235,26 @@ namespace OpenSim.Groups #endregion + private void HandleDebugGroupsMessagingVerbose(object modules, string[] args) + { + if (args.Length < 5) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + bool verbose = false; + if (!bool.TryParse(args[4], out verbose)) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + m_debugEnabled = verbose; + + MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled); + } + /// /// Not really needed, but does confirm that the group exists. /// diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 3724a2c..09bbec2 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -55,8 +55,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups private IGroupsServicesConnector m_groupData = null; // Config Options - private bool m_groupMessagingEnabled = false; - private bool m_debugEnabled = true; + private bool m_groupMessagingEnabled; + private bool m_debugEnabled; /// /// If enabled, module only tries to send group IMs to online users by querying cached presence information. @@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (m_messageOnlineAgentsOnly) m_usersOnlineCache = new ExpiringCache(); - m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); + m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled); } m_log.InfoFormat( @@ -127,6 +127,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups return; scene.RegisterModuleInterface(this); + + scene.AddCommand( + "Debug", + this, + "debug groups messaging verbose", + "debug groups messaging verbose ", + "This setting turns on very verbose groups messaging debugging", + HandleDebugGroupsMessagingVerbose); } public void RegionLoaded(Scene scene) @@ -218,6 +226,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups #endregion + private void HandleDebugGroupsMessagingVerbose(object modules, string[] args) + { + if (args.Length < 5) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + bool verbose = false; + if (!bool.TryParse(args[4], out verbose)) + { + MainConsole.Instance.Output("Usage: debug groups messaging verbose "); + return; + } + + m_debugEnabled = verbose; + + MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled); + } + /// /// Not really needed, but does confirm that the group exists. /// @@ -336,27 +364,45 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups IClientAPI client = GetActiveClient(member.AgentID); if (client == null) { + int startTick = Environment.TickCount; + // If they're not local, forward across the grid - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); + + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Delivering to {0} via grid took {1} ms", + member.AgentID, Environment.TickCount - startTick); } else { - // Deliver locally, directly - if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); + int startTick = Environment.TickCount; + ProcessMessageFromGroupSession(msg, client); + + // Deliver locally, directly + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Delivering to {0} locally took {1} ms", + member.AgentID, Environment.TickCount - startTick); } } else { + int startTick = Environment.TickCount; + m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { }); + + if (m_debugEnabled) + m_log.DebugFormat( + "[GROUPS-MESSAGING]: Handling undeliverable message for {0} took {1} ms", + member.AgentID, Environment.TickCount - startTick); } } - // Temporary for assessing how long it still takes to send messages to large online groups. - if (m_messageOnlineAgentsOnly) + if (m_debugEnabled) m_log.DebugFormat( - "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3}ms", + "[GROUPS-MESSAGING]: Total SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3} ms", groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick); } @@ -591,15 +637,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // Don't log any normal IMs (privacy!) if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) { - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); - m_log.WarnFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); + m_log.DebugFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); } } @@ -610,7 +656,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups /// private IClientAPI GetActiveClient(UUID agentID) { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); IClientAPI child = null; @@ -622,12 +669,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { if (!sp.IsChildAgent) { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); + return sp.ControllingClient; } else { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); + child = sp.ControllingClient; } } @@ -636,12 +687,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups // If we didn't find a root, then just return whichever child we found, or null if none if (child == null) { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); } else { - if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); + if (m_debugEnabled) + m_log.DebugFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); } + return child; } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index cae2958..3b7a611 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1664,6 +1664,9 @@ ; This makes the Groups modules very chatty on the console. DebugEnabled = false + ; This makes the Groups Messaging modules very chatty on the console. + DebugMessagingEnabled = false + ; Groups data is cached for this number of seconds before another request is made to the groups service ; Set to 0 to disable the cache. ; Default is 30 seconds -- cgit v1.1 From 77a331fce360fbd4640bd98ec2f6dfb00d31eac5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 May 2014 23:00:04 +0100 Subject: Add DebugMessagingEnabled = false to OpenSim.ini.example for consistency. Slightly simplify config comments. --- bin/OpenSim.ini.example | 5 ++++- bin/OpenSimDefaults.ini | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 7f2cba6..f3cd603 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -1033,9 +1033,12 @@ ; Applies Flotsam Group only. V2 has this always on, no other option ; MessageOnlineUsersOnly = false - ;; This makes the Groups modules very chatty on the console. + ;; This makes the Group module very chatty on the console. ; DebugEnabled = false + ; This makes the Group Messaging module very chatty on the console. + ; DebugMessagingEnabled = false + ;; XmlRpc Security settings. These must match those set on your backend ;; groups service if the service is using these keys ; XmlRpcServiceReadKey = 1234 diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 3b7a611..fd6e8b7 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1661,10 +1661,10 @@ ; Enable Group Notices ;NoticesEnabled = true - ; This makes the Groups modules very chatty on the console. + ; This makes the Group module very chatty on the console. DebugEnabled = false - ; This makes the Groups Messaging modules very chatty on the console. + ; This makes the Groups Messaging module very chatty on the console. DebugMessagingEnabled = false ; Groups data is cached for this number of seconds before another request is made to the groups service -- cgit v1.1 From 5ec3429843ecb8058698f663556ae1d4cae53434 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 May 2014 23:01:48 +0100 Subject: On verbose groups messaging logging, count all operations in reported time when sending group messages, not just those after get group members and get presence status, as applicable --- OpenSim/Addons/Groups/GroupsMessagingModule.cs | 4 ++-- .../OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Addons/Groups/GroupsMessagingModule.cs b/OpenSim/Addons/Groups/GroupsMessagingModule.cs index bd8db32..e6a4765 100644 --- a/OpenSim/Addons/Groups/GroupsMessagingModule.cs +++ b/OpenSim/Addons/Groups/GroupsMessagingModule.cs @@ -283,6 +283,8 @@ namespace OpenSim.Groups public void SendMessageToGroup( GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func sendCondition) { + int requestStartTick = Environment.TickCount; + UUID fromAgentID = new UUID(im.fromAgentID); // Unlike current XmlRpcGroups, Groups V2 can accept UUID.Zero when a perms check for the requesting agent @@ -315,8 +317,6 @@ namespace OpenSim.Groups // "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members, {2} online", // groupID, groupMembersCount, groupMembers.Count()); - int requestStartTick = Environment.TickCount; - im.imSessionID = groupID.Guid; im.fromGroup = true; IClientAPI thisClient = GetActiveClient(fromAgentID); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 09bbec2..e1b6abb 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs @@ -274,6 +274,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups public void SendMessageToGroup( GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func sendCondition) { + int requestStartTick = Environment.TickCount; + List groupMembers = m_groupData.GetGroupMembers(sendingAgentForGroupCalls, groupID); int groupMembersCount = groupMembers.Count; HashSet attemptDeliveryUuidSet = null; @@ -313,9 +315,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups m_log.DebugFormat( "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", groupID, groupMembers.Count); - } - - int requestStartTick = Environment.TickCount; + } foreach (GroupMembersData member in groupMembers) { -- cgit v1.1 From 9479f647781184d39d174fd708650da1e847c18c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 May 2014 23:48:10 +0100 Subject: Fix issue where avatar and script chat could sometimes be heard from anywhere in neighbouring regions. This was due to a silent uint overflow in ScenePresence.UpdateChildAgent() corrupting child agent positions when the child agent was in a region with a greater x or y map co-ord than the root agent region Probably introduced in beeec1c. This still will not function properly with very high region map co-ords (in the millions) but other parts of the code don't handle this properly anyway. Looks to address http://opensimulator.org/mantis/view.php?id=7163 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dd4bbe9..28b5b46 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3777,10 +3777,15 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) return; - //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}", +// Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position); + // Find the distance (in meters) between the two regions - uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX); - uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY); + // XXX: We cannot use Util.RegionLocToHandle() here because a negative value will silently overflow the + // uint + int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize); + int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize); Vector3 offset = new Vector3(shiftx, shifty, 0f); -- cgit v1.1 From 32070fa5f40aaad6da3624de7dfce724ee482643 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 May 2014 23:54:49 +0100 Subject: minor: remove compiler warning in SceneObjectPartInventory --- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index fb8ecd5..75e1cbb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -751,7 +751,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3 bbox; float offsetHeight; - bool single = m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); + m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); for (int i = 0; i < objlist.Count; i++) { -- cgit v1.1 From d93275745b8944ecb62ad34914af1c7f21103f51 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 May 2014 23:57:03 +0100 Subject: minor: Remove some unused fields in ScenePresence --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 28b5b46..398d394 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -208,7 +208,6 @@ namespace OpenSim.Region.Framework.Scenes // private int m_lastColCount = -1; //KF: Look for Collision chnages // private int m_updateCount = 0; //KF: Update Anims for a while // private static readonly int UPDATE_COUNT = 10; // how many frames to update for - private List m_lastColliders = new List(); private TeleportFlags m_teleportFlags; public TeleportFlags TeleportFlags @@ -271,8 +270,6 @@ namespace OpenSim.Region.Framework.Scenes //private int m_moveToPositionStateStatus; //***************************************************** - private object m_collisionEventLock = new Object(); - private int m_movementAnimationUpdateCounter = 0; public Vector3 PrevSitOffset { get; set; } -- cgit v1.1 From 5b433e101d178817d0127f568b5ff1b68fa70c09 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 May 2014 23:59:08 +0100 Subject: minor: Comment out currently unused log setup in TerrainCompressor --- OpenSim/Region/Framework/Scenes/TerrainCompressor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs index e797207..396f1e8 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { public static class OpenSimTerrainCompressor { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); #pragma warning disable 414 private static string LogHeader = "[TERRAIN COMPRESSOR]"; -- cgit v1.1 From a1b291c88966de86a083b60d9784a8bf2f7ae3ba Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 21 May 2014 09:34:57 +0300 Subject: Allow map searches for regions that contain the characters "!+|" These characters are used as placeholders for other characters: ": /". But we should search first for the exact string the user entered, and only if that fails then replace the characters and search again. --- .../CoreModules/World/WorldMap/MapSearchModule.cs | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index c35f6b7..1437b1b 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -143,28 +143,32 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } - //m_log.DebugFormat("MAP NAME=({0})", mapName); - - // Hack to get around the fact that ll V3 now drops the port from the - // map name. See https://jira.secondlife.com/browse/VWR-28570 - // - // Caller, use this magic form instead: - // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 - // or url encode if possible. - // the hacks we do with this viewer... - // + List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); + string mapNameOrig = mapName; - if (mapName.Contains("|")) - mapName = mapName.Replace('|', ':'); - if (mapName.Contains("+")) - mapName = mapName.Replace('+', ' '); - if (mapName.Contains("!")) - mapName = mapName.Replace('!', '/'); + if (regionInfos.Count == 0) + { + // Hack to get around the fact that ll V3 now drops the port from the + // map name. See https://jira.secondlife.com/browse/VWR-28570 + // + // Caller, use this magic form instead: + // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 + // or url encode if possible. + // the hacks we do with this viewer... + // + if (mapName.Contains("|")) + mapName = mapName.Replace('|', ':'); + if (mapName.Contains("+")) + mapName = mapName.Replace('+', ' '); + if (mapName.Contains("!")) + mapName = mapName.Replace('!', '/'); + + if (mapName != mapNameOrig) + regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); + } - // try to fetch from GridServer - List regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); - m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); + if (regionInfos.Count > 0) { foreach (GridRegion info in regionInfos) @@ -178,7 +182,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap data.MapImageId = info.TerrainImage; // ugh! V2-3 is very sensitive about the result being // exactly the same as the requested name - if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) + if (regionInfos.Count == 1 && (mapName != mapNameOrig)) data.Name = mapNameOrig; else data.Name = info.RegionName; -- cgit v1.1 From 251b93d97eb6d8d56c4deb1f6f56dbe2092c2976 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 21 May 2014 19:05:20 +0300 Subject: Store the Teleport Flags in the Circuit. This doesn't seem to be necessary, because everything has worked so far, but it's the right thing to do. --- OpenSim/Framework/AgentCircuitData.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index f2fe494..0d053e4 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -321,6 +321,8 @@ namespace OpenSim.Framework Mac = args["mac"].AsString(); if (args["id0"] != null) Id0 = args["id0"].AsString(); + if (args["teleport_flags"] != null) + teleportFlags = args["teleport_flags"].AsUInteger(); if (args["start_pos"] != null) Vector3.TryParse(args["start_pos"].AsString(), out startpos); -- cgit v1.1 From 04aa13a086239b8d628821809bef9c9585c35f8f Mon Sep 17 00:00:00 2001 From: AliciaRaven Date: Thu, 22 May 2014 00:51:33 +0100 Subject: Fix mantis 6973. Prevent BOM being prefixed to message XML which was causing an exception when the service tried to read the data later on. Signed-off-by: Oren Hurvitz --- OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs index 690c955..02084ff 100644 --- a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs +++ b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs @@ -104,7 +104,7 @@ namespace OpenSim.OfflineIM using (MemoryStream mstream = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings(); - settings.Encoding = Encoding.UTF8; + settings.Encoding = Util.UTF8NoBomEncoding; using (XmlWriter writer = XmlWriter.Create(mstream, settings)) { @@ -112,7 +112,7 @@ namespace OpenSim.OfflineIM writer.Flush(); } - imXml = Util.UTF8.GetString(mstream.ToArray()); + imXml = Util.UTF8NoBomEncoding.GetString(mstream.ToArray()); } OfflineIMData data = new OfflineIMData(); -- cgit v1.1 From f7b2aa0f49f5eca0a58c20b903103d19742220e9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 22 May 2014 10:16:01 -0700 Subject: Fixed a problem with detaching attachments in situations where the user's asset server is not the same as the simulator's asset server. Unfortunately this still continues to be wasteful -- new assets are created every time an attachment is detached, but the process of storing the new asset goes through the InventoryAccess module, which does all sorts of checks regarding the users' inventory. --- .../Avatar/Attachments/AttachmentsModule.cs | 9 ++------ .../InventoryAccess/HGInventoryAccessModule.cs | 14 ++++++++++++ .../InventoryAccess/InventoryAccessModule.cs | 26 +++++++++++++++++++++- .../Framework/Interfaces/IInventoryAccessModule.cs | 4 +++- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index e9b2f4f..7333769 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -774,15 +774,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments (sbyte)AssetType.Object, Utils.StringToBytes(sceneObjectXml), sp.UUID); - m_scene.AssetService.Store(asset); - item.AssetID = asset.FullID; - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; - item.InvType = (int)InventoryType.Object; + IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); - m_scene.InventoryService.UpdateItem(item); + invAccess.UpdateInventoryItemAsset(sp.UUID, item, asset); // If the name of the object has been changed whilst attached then we want to update the inventory // item in the viewer. diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 283a0cf..71570da 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -253,6 +253,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return newAssetID; } + /// + /// UpdateInventoryItemAsset + /// + public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) + { + if (base.UpdateInventoryItemAsset(ownerID, item, asset)) + { + UploadInventoryItem(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0); + return true; + } + + return false; + } + /// /// Used in DeleteToInventory /// diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index a116f0f..6e48fcc 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -292,7 +292,31 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess return UUID.Zero; } - + + public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset) + { + if (item != null && item.Owner == ownerID && asset != null) + { + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = (int)InventoryType.Object; + + m_Scene.AssetService.Store(asset); + m_Scene.InventoryService.UpdateItem(item); + + return true; + } + else + { + m_log.ErrorFormat("[INVENTORY ACCESS MODULE]: Given invalid item for inventory update: {0}", + (item == null || asset == null? "null item or asset" : "wrong owner")); + return false; + } + + } + public virtual List CopyToInventory( DeRezAction action, UUID folderID, List objectGroups, IClientAPI remoteClient, bool asAttachment) diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs index 3576e35..6bad018 100644 --- a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs @@ -38,7 +38,9 @@ namespace OpenSim.Region.Framework.Interfaces public interface IInventoryAccessModule { UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data); - + + bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset); + /// /// Copy objects to a user's inventory. /// -- cgit v1.1 From 1b156b7fe84bf132b51ff198d6d730708f5930b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 19:18:24 +0100 Subject: Add regression test for in-range chat between neighbouring regions from east to west. --- .../Avatar/Chat/Tests/ChatModuleTests.cs | 158 +++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 5 +- .../BasicPhysicsPlugin/BasicPhysicsScene.cs | 1 + OpenSim/Tests/Common/Mock/TestClient.cs | 40 ++++++ prebuild.xml | 1 + 5 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs new file mode 100644 index 0000000..315cc19 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs @@ -0,0 +1,158 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using log4net.Config; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.CoreModules.Avatar.Chat; +using OpenSim.Region.CoreModules.Framework; +using OpenSim.Region.CoreModules.Framework.EntityTransfer; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests +{ + [TestFixture] + public class ChatModuleTests : OpenSimTestCase + { + [TestFixtureSetUp] + public void FixtureInit() + { + // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. + // We must do this here so that child agent positions are updated in a predictable manner. + Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; + } + + [TestFixtureTearDown] + public void TearDown() + { + // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple + // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression + // tests really shouldn't). + Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; + } + + /// + /// Tests chat between neighbour regions on the east-west axis + /// + /// + /// Really, this is a combination of a child agent position update test and a chat range test. These need + /// to be separated later on. + /// + [Test] + public void TestInterRegionChatDistanceEastWest() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID sp1Uuid = TestHelpers.ParseTail(0x11); + UUID sp2Uuid = TestHelpers.ParseTail(0x12); + + Vector3 sp1Position = new Vector3(6, 128, 20); + Vector3 sp2Position = new Vector3(250, 128, 20); + + // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the + // CapabilitiesModule complain when it can't set up HTTP endpoints. +// BaseHttpServer httpServer = new BaseHttpServer(99999); +// MainServer.AddHttpServer(httpServer); +// MainServer.Instance = httpServer; + + // We need entity transfer modules so that when sp2 logs into the east region, the region calls + // EntityTransferModuleto set up a child agent on the west region. + // XXX: However, this is not an entity transfer so is misleading. + EntityTransferModule etmA = new EntityTransferModule(); + EntityTransferModule etmB = new EntityTransferModule(); + LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Chat"); + IConfig modulesConfig = config.AddConfig("Modules"); + modulesConfig.Set("EntityTransferModule", etmA.Name); + modulesConfig.Set("SimulationServices", lscm.Name); + + SceneHelpers sh = new SceneHelpers(); + + TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000); + TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000); + SceneHelpers.SetupSceneModules(new Scene[] { sceneWest, sceneEast }, config, lscm); + + SceneHelpers.SetupSceneModules(sceneWest, config, new CapabilitiesModule(), etmA, new ChatModule()); + SceneHelpers.SetupSceneModules(sceneEast, config, new CapabilitiesModule(), etmB, new ChatModule()); + + ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneEast, sp1Uuid); + TestClient sp1Client = (TestClient)sp1.ControllingClient; + + // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0. + // TODO: May need to create special complete no-op test physics module rather than basic physics, since + // physics is irrelevant to this test. + sp1.Flying = true; + sp1.AbsolutePosition = sp1Position; + + AgentCircuitData acd = SceneHelpers.GenerateAgentData(sp2Uuid); + TestClient tc = new TestClient(acd, sceneEast); + List destinationTestClients = new List(); + EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); + + ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, tc, acd); + TestClient sp2Client = (TestClient)sp2.ControllingClient; + + sp2.Flying = true; + sp2.AbsolutePosition = sp2Position; + + TestClient sp2ChildClient = destinationTestClients[0]; + + // We must update the scene in order to make the new root agent sp2 in sceneWest trigger a position update to its + // child in sceneEast. + sceneWest.Update(1); + + // Check child position is correct. + Assert.AreEqual( + new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z), + sp2ChildClient.SceneAgent.AbsolutePosition); + + // Check chat received + string receivedChatMessage = ""; + + sp2ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedChatMessage = message; + + string testMessage = "'ello darling"; + sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); + + Assert.AreEqual(testMessage, receivedChatMessage); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3b8fbfd..7005c0a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4133,7 +4133,10 @@ namespace OpenSim.Region.Framework.Scenes /// true if we handled it. public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData) { - //m_log.Debug(" XXX Scene IncomingChildAgentDataUpdate POSITION in " + RegionInfo.RegionName); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}", +// cAgentData.AgentID, Name, cAgentData.Position); + ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); if (childAgentUpdate != null) { diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs index 8e40561..f53adcb 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs @@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X]; float height = terrainHeight + actor.Size.Z; +// Console.WriteLine("height {0}, actorPosition {1}", height, actorPosition); if (actor.Flying) { diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index c2b0935..8eeaf99 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -62,14 +62,23 @@ namespace OpenSim.Tests.Common.Mock public event Action OnReceivedMoveAgentIntoRegion; public event Action OnTestClientInformClientOfNeighbour; public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; + public event Action OnReceivedEntityUpdate; + + public event OnReceivedChatMessageDelegate OnReceivedChatMessage; public event Action OnReceivedInstantMessage; + public event Action OnReceivedSendRebakeAvatarTextures; public delegate void TestClientOnSendRegionTeleportDelegate( ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL); + public delegate void OnReceivedChatMessageDelegate( + string message, byte type, Vector3 fromPos, string fromName, + UUID fromAgentID, UUID ownerID, byte source, byte audible); + + // disable warning: public events, part of the public API #pragma warning disable 67 @@ -467,6 +476,34 @@ namespace OpenSim.Tests.Common.Mock } /// + /// Trigger chat coming from this connection. + /// + /// + /// + /// + public bool Chat(int channel, ChatTypeEnum type, string message) + { + ChatMessage handlerChatFromClient = OnChatFromClient; + + if (handlerChatFromClient != null) + { + OSChatMessage args = new OSChatMessage(); + args.Channel = channel; + args.From = Name; + args.Message = message; + args.Type = type; + + args.Scene = Scene; + args.Sender = this; + args.SenderUUID = AgentId; + + handlerChatFromClient(this, args); + } + + return true; + } + + /// /// Attempt a teleport to the given region. /// /// @@ -550,6 +587,9 @@ namespace OpenSim.Tests.Common.Mock string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible) { +// Console.WriteLine("mmm {0} {1} {2}", message, Name, AgentId); + if (OnReceivedChatMessage != null) + OnReceivedChatMessage(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); } public void SendInstantMessage(GridInstantMessage im) diff --git a/prebuild.xml b/prebuild.xml index 9a419eb..196bfd2 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -3081,6 +3081,7 @@ + -- cgit v1.1 From 65a135f4d33fc0be3738f11c51a6c27c344a10aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 19:47:33 +0100 Subject: Simplify regression TestInterRegionChatDistanceEastWest() by making the child presence connection directly rather than routing through TestClient. This code isn't relevant to this test and is already exercised by other tests. --- .../Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs | 13 ++++++------- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 6 +++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs index 315cc19..c5eb2ad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs @@ -121,18 +121,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests sp1.Flying = true; sp1.AbsolutePosition = sp1Position; - AgentCircuitData acd = SceneHelpers.GenerateAgentData(sp2Uuid); - TestClient tc = new TestClient(acd, sceneEast); - List destinationTestClients = new List(); - EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); - - ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, tc, acd); + ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, sp2Uuid); TestClient sp2Client = (TestClient)sp2.ControllingClient; + // When sp2 logs in to sceneWest, it sets up a child agent in sceneEast and informs the sp2 client to + // make the connection. For this test, will simplify this chain by making the connection separately here. + ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneEast, sp2Uuid); + sp2.Flying = true; sp2.AbsolutePosition = sp2Position; - TestClient sp2ChildClient = destinationTestClients[0]; + TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient; // We must update the scene in order to make the new root agent sp2 in sceneWest trigger a position update to its // child in sceneEast. diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 874ff62..342cd06 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -574,7 +574,11 @@ namespace OpenSim.Tests.Common public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) { - AgentCircuitData acd = GenerateAgentData(agentId); + return AddChildScenePresence(scene, GenerateAgentData(agentId)); + } + + public static ScenePresence AddChildScenePresence(Scene scene, AgentCircuitData acd) + { acd.child = true; // XXX: ViaLogin may not be correct for child agents -- cgit v1.1 From 15b50ae737cf316cfe9db6843f06f7b3799f139e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 19:55:34 +0100 Subject: Extend regression TestInterRegionChatDistanceEastWest() to test in range chat both ways. --- .../Avatar/Chat/Tests/ChatModuleTests.cs | 55 +++++++++++++++------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs index c5eb2ad..fac9bd4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs @@ -119,39 +119,60 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests // TODO: May need to create special complete no-op test physics module rather than basic physics, since // physics is irrelevant to this test. sp1.Flying = true; + + // When sp1 logs in to sceneEast, it sets up a child agent in sceneWest and informs the sp2 client to + // make the connection. For this test, will simplify this chain by making the connection directly. + ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneWest, sp1Uuid); + TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient; + sp1.AbsolutePosition = sp1Position; ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, sp2Uuid); TestClient sp2Client = (TestClient)sp2.ControllingClient; - - // When sp2 logs in to sceneWest, it sets up a child agent in sceneEast and informs the sp2 client to - // make the connection. For this test, will simplify this chain by making the connection separately here. - ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneEast, sp2Uuid); - sp2.Flying = true; - sp2.AbsolutePosition = sp2Position; + ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneEast, sp2Uuid); TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient; - // We must update the scene in order to make the new root agent sp2 in sceneWest trigger a position update to its - // child in sceneEast. + sp2.AbsolutePosition = sp2Position; + + // We must update the scenes in order to make the root new root agents trigger position updates in their + // children. sceneWest.Update(1); + sceneEast.Update(1); + + // Check child positions are correct. + Assert.AreEqual( + new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); - // Check child position is correct. Assert.AreEqual( new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z), sp2ChildClient.SceneAgent.AbsolutePosition); - // Check chat received - string receivedChatMessage = ""; + // Check chat from sp1 + { + string receivedChatMessage = ""; + + sp2ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedChatMessage = message; + + string testMessage = "'ello darling"; + sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); + } + + // Check chat from sp2 + { + string receivedChatMessage = ""; - sp2ChildClient.OnReceivedChatMessage - += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedChatMessage = message; + sp1ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedChatMessage = message; - string testMessage = "'ello darling"; - sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); - - Assert.AreEqual(testMessage, receivedChatMessage); + string testMessage = "fantastic cats"; + sp2Client.Chat(0, ChatTypeEnum.Say, testMessage); + + Assert.AreEqual(testMessage, receivedChatMessage); + } } } } \ No newline at end of file -- cgit v1.1 From bffc9ad18471076360692731597f89d232bb07b9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 20:04:32 +0100 Subject: Extend regression TestInterRegionChatDistanceEastWest() to test out of range chat --- .../Avatar/Chat/Tests/ChatModuleTests.cs | 49 +++++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs index fac9bd4..bdaa97b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs @@ -150,28 +150,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z), sp2ChildClient.SceneAgent.AbsolutePosition); - // Check chat from sp1 - { - string receivedChatMessage = ""; + string receivedSp1ChatMessage = ""; + string receivedSp2ChatMessage = ""; - sp2ChildClient.OnReceivedChatMessage - += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedChatMessage = message; + sp1ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message; + sp2ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; + // Check chat from sp1 + { string testMessage = "'ello darling"; sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); + +// Assert.AreEqual(testMessage, receivedSp1ChatMessage); + Assert.AreEqual(testMessage, receivedSp2ChatMessage); } // Check chat from sp2 + { + string testMessage = "fantastic cats"; + sp2Client.Chat(0, ChatTypeEnum.Say, testMessage); + + Assert.AreEqual(testMessage, receivedSp1ChatMessage); +// Assert.AreEqual(testMessage, receivedSp2ChatMessage); + } + + sp1Position = new Vector3(30, 128, 20); + sp1.AbsolutePosition = sp1Position; + sceneEast.Update(1); + + // Check child position is correct. + Assert.AreEqual( + new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); + + // sp2 should now be out of range for chat from sp1 { - string receivedChatMessage = ""; + string testMessage = "beef"; + sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); - sp1ChildClient.OnReceivedChatMessage - += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedChatMessage = message; + Assert.AreNotEqual(testMessage, receivedSp2ChatMessage); + } - string testMessage = "fantastic cats"; + // sp1 should now be out of range for chat from sp2 + { + string testMessage = "lentils"; sp2Client.Chat(0, ChatTypeEnum.Say, testMessage); - - Assert.AreEqual(testMessage, receivedChatMessage); + + Assert.AreNotEqual(testMessage, receivedSp1ChatMessage); } } } -- cgit v1.1 From f8b824123970418211bbc5ea501ead98a1781084 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 20:28:26 +0100 Subject: Add regression test for north-south chat across neighbour regions. --- .../Avatar/Chat/Tests/ChatModuleTests.cs | 185 +++++++++++++++------ 1 file changed, 133 insertions(+), 52 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs index bdaa97b..7b8c418 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs @@ -65,6 +65,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } + private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB) + { + // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the + // CapabilitiesModule complain when it can't set up HTTP endpoints. + // BaseHttpServer httpServer = new BaseHttpServer(99999); + // MainServer.AddHttpServer(httpServer); + // MainServer.Instance = httpServer; + + // We need entity transfer modules so that when sp2 logs into the east region, the region calls + // EntityTransferModuleto set up a child agent on the west region. + // XXX: However, this is not an entity transfer so is misleading. + EntityTransferModule etmA = new EntityTransferModule(); + EntityTransferModule etmB = new EntityTransferModule(); + LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Chat"); + IConfig modulesConfig = config.AddConfig("Modules"); + modulesConfig.Set("EntityTransferModule", etmA.Name); + modulesConfig.Set("SimulationServices", lscm.Name); + + SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); + SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule()); + SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule()); + } + /// /// Tests chat between neighbour regions on the east-west axis /// @@ -84,33 +110,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests Vector3 sp1Position = new Vector3(6, 128, 20); Vector3 sp2Position = new Vector3(250, 128, 20); - // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the - // CapabilitiesModule complain when it can't set up HTTP endpoints. -// BaseHttpServer httpServer = new BaseHttpServer(99999); -// MainServer.AddHttpServer(httpServer); -// MainServer.Instance = httpServer; - - // We need entity transfer modules so that when sp2 logs into the east region, the region calls - // EntityTransferModuleto set up a child agent on the west region. - // XXX: However, this is not an entity transfer so is misleading. - EntityTransferModule etmA = new EntityTransferModule(); - EntityTransferModule etmB = new EntityTransferModule(); - LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); - - IConfigSource config = new IniConfigSource(); - config.AddConfig("Chat"); - IConfig modulesConfig = config.AddConfig("Modules"); - modulesConfig.Set("EntityTransferModule", etmA.Name); - modulesConfig.Set("SimulationServices", lscm.Name); - SceneHelpers sh = new SceneHelpers(); - TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000); TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000); - SceneHelpers.SetupSceneModules(new Scene[] { sceneWest, sceneEast }, config, lscm); - SceneHelpers.SetupSceneModules(sceneWest, config, new CapabilitiesModule(), etmA, new ChatModule()); - SceneHelpers.SetupSceneModules(sceneEast, config, new CapabilitiesModule(), etmB, new ChatModule()); + SetupNeighbourRegions(sceneWest, sceneEast); ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneEast, sp1Uuid); TestClient sp1Client = (TestClient)sp1.ControllingClient; @@ -158,23 +162,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests sp2ChildClient.OnReceivedChatMessage += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; - // Check chat from sp1 - { - string testMessage = "'ello darling"; - sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); - -// Assert.AreEqual(testMessage, receivedSp1ChatMessage); - Assert.AreEqual(testMessage, receivedSp2ChatMessage); - } - - // Check chat from sp2 - { - string testMessage = "fantastic cats"; - sp2Client.Chat(0, ChatTypeEnum.Say, testMessage); - - Assert.AreEqual(testMessage, receivedSp1ChatMessage); -// Assert.AreEqual(testMessage, receivedSp2ChatMessage); - } + TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage); + TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage); sp1Position = new Vector3(30, 128, 20); sp1.AbsolutePosition = sp1Position; @@ -185,21 +174,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), sp1ChildClient.SceneAgent.AbsolutePosition); - // sp2 should now be out of range for chat from sp1 - { - string testMessage = "beef"; - sp1Client.Chat(0, ChatTypeEnum.Say, testMessage); + TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage); + TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage); + } + + /// + /// Tests chat between neighbour regions on the north-south axis + /// + /// + /// Really, this is a combination of a child agent position update test and a chat range test. These need + /// to be separated later on. + /// + [Test] + public void TestInterRegionChatDistanceNorthSouth() + { + TestHelpers.InMethod(); + // TestHelpers.EnableLogging(); + + UUID sp1Uuid = TestHelpers.ParseTail(0x11); + UUID sp2Uuid = TestHelpers.ParseTail(0x12); + + Vector3 sp1Position = new Vector3(128, 250, 20); + Vector3 sp2Position = new Vector3(128, 6, 20); + + SceneHelpers sh = new SceneHelpers(); + TestScene sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000); + TestScene sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001); - Assert.AreNotEqual(testMessage, receivedSp2ChatMessage); - } + SetupNeighbourRegions(sceneNorth, sceneSouth); + + ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneNorth, sp1Uuid); + TestClient sp1Client = (TestClient)sp1.ControllingClient; + + // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0. + // TODO: May need to create special complete no-op test physics module rather than basic physics, since + // physics is irrelevant to this test. + sp1.Flying = true; + + // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to + // make the connection. For this test, will simplify this chain by making the connection directly. + ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid); + TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient; + + sp1.AbsolutePosition = sp1Position; + + ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid); + TestClient sp2Client = (TestClient)sp2.ControllingClient; + sp2.Flying = true; + + ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid); + TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient; + + sp2.AbsolutePosition = sp2Position; + + // We must update the scenes in order to make the root new root agents trigger position updates in their + // children. + sceneNorth.Update(1); + sceneSouth.Update(1); + + // Check child positions are correct. + Assert.AreEqual( + new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); + + Assert.AreEqual( + new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z), + sp2ChildClient.SceneAgent.AbsolutePosition); + + string receivedSp1ChatMessage = ""; + string receivedSp2ChatMessage = ""; + + sp1ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message; + sp2ChildClient.OnReceivedChatMessage + += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; + + TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage); + TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage); + + sp1Position = new Vector3(30, 128, 20); + sp1.AbsolutePosition = sp1Position; + sceneNorth.Update(1); + + // Check child position is correct. + Assert.AreEqual( + new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), + sp1ChildClient.SceneAgent.AbsolutePosition); + + TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage); + TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage); + } + + private void TestUserInRange(TestClient speakClient, string testMessage, ref string receivedMessage) + { + receivedMessage = ""; + + speakClient.Chat(0, ChatTypeEnum.Say, testMessage); + + Assert.AreEqual(testMessage, receivedMessage); + } + + private void TestUserOutOfRange(TestClient speakClient, string testMessage, ref string receivedMessage) + { + receivedMessage = ""; - // sp1 should now be out of range for chat from sp2 - { - string testMessage = "lentils"; - sp2Client.Chat(0, ChatTypeEnum.Say, testMessage); + speakClient.Chat(0, ChatTypeEnum.Say, testMessage); - Assert.AreNotEqual(testMessage, receivedSp1ChatMessage); - } + Assert.AreNotEqual(testMessage, receivedMessage); } } } \ No newline at end of file -- cgit v1.1 From 16bf38e1abd3a6235008a38ba7ca29e836c925c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 23:39:22 +0100 Subject: Fix issue where llSetCameraAtOffset() and llSetCameraEyeOffset() in non-root prims moved camera/focus to wrong position. For non-root prim, eye offsets now need to be made relative to root prim if either camera-at or camera-eye are set. Probably a regression since November 2013 when all sits were made relative to root prim to match viewer expections (and fix other bugs). Addresses http://opensimulator.org/mantis/view.php?id=7176 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 398d394..ed107e4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2755,6 +2755,10 @@ namespace OpenSim.Region.Framework.Scenes cameraAtOffset = part.GetCameraAtOffset(); cameraEyeOffset = part.GetCameraEyeOffset(); + + if (cameraEyeOffset != Vector3.Zero || cameraAtOffset != Vector3.Zero) + cameraEyeOffset += part.OffsetPosition; + forceMouselook = part.GetForceMouselook(); // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is -- cgit v1.1 From 3fbaef9275dbb1767dc734e2d8dbe1d2cabfb566 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 23:52:28 +0100 Subject: If the root prim has a camera-at or camera-eye setting and a sat upon child prim does not, use the root prim offsets. This matches behaviour just tested on the Linden Lab grid. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ed107e4..026b0b6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2754,8 +2754,15 @@ namespace OpenSim.Region.Framework.Scenes part.AddSittingAvatar(this); cameraAtOffset = part.GetCameraAtOffset(); + + if (cameraAtOffset == Vector3.Zero) + cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset(); + cameraEyeOffset = part.GetCameraEyeOffset(); + if (cameraEyeOffset == Vector3.Zero) + cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); + if (cameraEyeOffset != Vector3.Zero || cameraAtOffset != Vector3.Zero) cameraEyeOffset += part.OffsetPosition; -- cgit v1.1 From 174df941720bc45c1e73224919c34f059129b9e1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 May 2014 23:58:28 +0100 Subject: If a script calls llSetCameraAtOffset() or llSetCameraEyeOffset() on a child prim and the root prim has no corresponding value set, then also set the root prim. This matches behaviour just tested on the Linden Lab grid. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5590cd5..7d8821c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6846,12 +6846,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); m_host.SetCameraEyeOffset(offset); + + if (m_host.ParentGroup.RootPart.GetCameraEyeOffset() == Vector3.Zero) + m_host.ParentGroup.RootPart.SetCameraEyeOffset(offset); } public void llSetCameraAtOffset(LSL_Vector offset) { m_host.AddScriptLPS(1); m_host.SetCameraAtOffset(offset); + + if (m_host.ParentGroup.RootPart.GetCameraAtOffset() == Vector3.Zero) + m_host.ParentGroup.RootPart.SetCameraAtOffset(offset); } public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) -- cgit v1.1 From fbed2455965283e7cec92f8cceb89a333e1dca14 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 01:34:02 +0100 Subject: Compensate camera-at and camera-eye for child prim rotation when sitting on child prim with camera-eye set --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 026b0b6..eaac71d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2764,7 +2764,19 @@ namespace OpenSim.Region.Framework.Scenes cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); if (cameraEyeOffset != Vector3.Zero || cameraAtOffset != Vector3.Zero) + { + if (!part.IsRoot) + { + cameraEyeOffset = cameraEyeOffset * part.RotationOffset; + cameraAtOffset = part.OffsetPosition; + } + cameraEyeOffset += part.OffsetPosition; + } + +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Using cameraAtOffset {0}, cameraEyeOffset {1} for sit on {2} by {3} in {4}", +// cameraAtOffset, cameraEyeOffset, part.Name, Name, Scene.Name); forceMouselook = part.GetForceMouselook(); -- cgit v1.1 From c78a8271c44c581e4c939fa6347fd967ffdee847 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 01:38:05 +0100 Subject: Add any camera at compensation for sat upon child prims to any existing camera-at value, rather than replace. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index eaac71d..f067f9d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2768,7 +2768,7 @@ namespace OpenSim.Region.Framework.Scenes if (!part.IsRoot) { cameraEyeOffset = cameraEyeOffset * part.RotationOffset; - cameraAtOffset = part.OffsetPosition; + cameraAtOffset += part.OffsetPosition; } cameraEyeOffset += part.OffsetPosition; -- cgit v1.1 From 5015b0b485058db5bf1f2b56cf375c23349749ad Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 01:55:05 +0100 Subject: If one is sitting on a child with an unset camera-eye and so using one set in a root prim, the focus should remain on the root prim. Matches behaviour just tested on the Linden grid. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f067f9d..17f54c2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2755,15 +2755,19 @@ namespace OpenSim.Region.Framework.Scenes cameraAtOffset = part.GetCameraAtOffset(); - if (cameraAtOffset == Vector3.Zero) + if (!part.IsRoot && cameraAtOffset == Vector3.Zero) cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset(); + bool cameraEyeOffsetFromRootForChild = false; cameraEyeOffset = part.GetCameraEyeOffset(); - if (cameraEyeOffset == Vector3.Zero) + if (!part.IsRoot && cameraEyeOffset == Vector3.Zero) + { cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); + cameraEyeOffsetFromRootForChild = true; + } - if (cameraEyeOffset != Vector3.Zero || cameraAtOffset != Vector3.Zero) + if ((cameraEyeOffset != Vector3.Zero && !cameraEyeOffsetFromRootForChild) || cameraAtOffset != Vector3.Zero) { if (!part.IsRoot) { -- cgit v1.1 From 72c67c50911e31937826314c825fdf13baa1cc28 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 20:14:49 +0100 Subject: Fix possible infinite recursion in MessageTransferModule.SendGridInstantMessageViaXMLRPCAsync() whilst preserving retry lookup behaviour. This is based on heavily mikemig's original patch in http://opensimulator.org/mantis/view.php?id=7149 but instead of exiting after the first IM delivery failure to presence information retrieved from the presence service it will retry the lookup until the result matches the previous lookup. This is to deal with the case where the agent is sent an IM whilst they are teleporting. --- .../Avatar/InstantMessage/MessageTransferModule.cs | 164 +++++++-------------- 1 file changed, 56 insertions(+), 108 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 7aa7123..2462ff8 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -428,7 +428,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// /// delegate for sending a grid instant message asynchronously /// - public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); + public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); protected virtual void GridInstantMessageCompleted(IAsyncResult iar) { @@ -442,138 +442,87 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; - d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); + d.BeginInvoke(im, result, GridInstantMessageCompleted, d); } /// - /// Recursive SendGridInstantMessage over XMLRPC method. - /// This is called from within a dedicated thread. - /// The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from - /// itself, prevRegionHandle will be the last region handle that we tried to send. - /// If the handles are the same, we look up the user's location using the grid. - /// If the handles are still the same, we end. The send failed. + /// Internal SendGridInstantMessage over XMLRPC method. /// - /// - /// Pass in 0 the first time this method is called. It will be called recursively with the last - /// regionhandle tried - /// - protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) + /// + /// This is called from within a dedicated thread. + /// + private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) { UUID toAgentID = new UUID(im.toAgentID); - - PresenceInfo upd = null; - - bool lookupAgent = false; + UUID regionID; + bool needToLookupAgent; lock (m_UserRegionMap) + needToLookupAgent = !m_UserRegionMap.TryGetValue(toAgentID, out regionID); + + while (true) { - if (m_UserRegionMap.ContainsKey(toAgentID)) + if (needToLookupAgent) { - upd = new PresenceInfo(); - upd.RegionID = m_UserRegionMap[toAgentID]; + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); - // We need to compare the current regionhandle with the previous region handle - // or the recursive loop will never end because it will never try to lookup the agent again - if (prevRegionID == upd.RegionID) - { - lookupAgent = true; - } - } - else - { - lookupAgent = true; - } - } - + UUID foundRegionID = UUID.Zero; - // Are we needing to look-up an agent? - if (lookupAgent) - { - // Non-cached user agent lookup. - PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); - if (presences != null && presences.Length > 0) - { - foreach (PresenceInfo p in presences) + if (presences != null) { - if (p.RegionID != UUID.Zero) + foreach (PresenceInfo p in presences) { - upd = p; - break; + if (p.RegionID != UUID.Zero) + { + foundRegionID = p.RegionID; + break; + } } } - } - if (upd != null) - { - // check if we've tried this before.. - // This is one way to end the recursive loop - // - if (upd.RegionID == prevRegionID) - { - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliverableMessage(im, result); - return; - } + // If not found or the found region is the same as the last lookup, then message is undeliverable + if (foundRegionID == UUID.Zero || foundRegionID == regionID) + break; + else + regionID = foundRegionID; } - else + + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, regionID); + if (reginfo == null) { - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - HandleUndeliverableMessage(im, result); - return; + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", regionID); + break; } - } - if (upd != null) - { - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, - upd.RegionID); - if (reginfo != null) + // Try to send the message to the agent via the retrieved region. + Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); + msgdata["region_handle"] = 0; + bool imresult = doIMSending(reginfo, msgdata); + + // If the message delivery was successful, then cache the entry. + if (imresult) { - Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); - // Not actually used anymore, left in for compatibility - // Remove at next interface change - // - msgdata["region_handle"] = 0; - bool imresult = doIMSending(reginfo, msgdata); - if (imresult) - { - // IM delivery successful, so store the Agent's location in our local cache. - lock (m_UserRegionMap) - { - if (m_UserRegionMap.ContainsKey(toAgentID)) - { - m_UserRegionMap[toAgentID] = upd.RegionID; - } - else - { - m_UserRegionMap.Add(toAgentID, upd.RegionID); - } - } - result(true); - } - else + lock (m_UserRegionMap) { - // try again, but lookup user this time. - // Warning, this must call the Async version - // of this method or we'll be making thousands of threads - // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync - // The version that spawns the thread is SendGridInstantMessageViaXMLRPC - - // This is recursive!!!!! - SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.RegionID); + m_UserRegionMap[toAgentID] = regionID; } + result(true); + return; } - else - { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); - HandleUndeliverableMessage(im, result); - } - } - else - { - HandleUndeliverableMessage(im, result); + + // If we reach this point in the first iteration of the while, then we may have unsuccessfully tried + // to use a locally cached region ID. All subsequent attempts need to lookup agent details from + // the presence service. + needToLookupAgent = true; } + + // If we reached this point then the message was not deliverable. Remove the bad cache entry and + // signal the delivery failure. + lock (m_UserRegionMap) + m_UserRegionMap.Remove(toAgentID); + + // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); + HandleUndeliverableMessage(im, result); } /// @@ -584,7 +533,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// Bool if the message was successfully delivered at the other side. protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata) { - ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams); -- cgit v1.1 From fbcb76383d5083a7a1b4c4ba75d37b247859a87d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 20:57:50 +0100 Subject: Allow console output to be multiline by making colourization regex RegexOptions.SingleLine --- OpenSim/Framework/Console/LocalConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index a967db6..b17b8e0 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -283,7 +283,7 @@ namespace OpenSim.Framework.Console { string regex = @"^(?.*?)\[(?[^\]]+)\]:?(?.*)"; - Regex RE = new Regex(regex, RegexOptions.Multiline); + Regex RE = new Regex(regex, RegexOptions.Singleline); MatchCollection matches = RE.Matches(text); if (matches.Count == 1) -- cgit v1.1 From f55e15363665ac885b51fa549c9c1566e9ea0cc6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 21:09:48 +0100 Subject: Compile the regex that extract categories for colourization just once rather than on every single log. Compiling every time is unnecessary since Regex is thread-safe. --- OpenSim/Framework/Console/LocalConsole.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index b17b8e0..260a86f 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs @@ -46,6 +46,11 @@ namespace OpenSim.Framework.Console // private readonly object m_syncRoot = new object(); private const string LOGLEVEL_NONE = "(none)"; + // Used to extract categories for colourization. + private Regex m_categoryRegex + = new Regex( + @"^(?.*?)\[(?[^\]]+)\]:?(?.*)", RegexOptions.Singleline | RegexOptions.Compiled); + private int m_cursorYPosition = -1; private int m_cursorXPosition = 0; private StringBuilder m_commandLine = new StringBuilder(); @@ -280,11 +285,8 @@ namespace OpenSim.Framework.Console string outText = text; if (level != LOGLEVEL_NONE) - { - string regex = @"^(?.*?)\[(?[^\]]+)\]:?(?.*)"; - - Regex RE = new Regex(regex, RegexOptions.Singleline); - MatchCollection matches = RE.Matches(text); + { + MatchCollection matches = m_categoryRegex.Matches(text); if (matches.Count == 1) { -- cgit v1.1 From b3a496d6f2fa09659b0109f745632bc80acc756f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 21:13:37 +0100 Subject: Add mikemig to contributors --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index fa79ea7..1d080ff 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -134,6 +134,7 @@ what it is today. * Micheil Merlin * Mike Osias (IBM) * Mike Pitman (IBM) +* mikemig * mikkopa/_someone - RealXtend * Misterblue * Mircea Kitsune -- cgit v1.1 From 250ea09328253422ff2a0e4877ee9968556328f0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 22:12:49 +0100 Subject: Reactivate regression test TestCastAndConcatString() in CompilerTests. --- .../ScriptEngine/Shared/CodeTools/Compiler.cs | 4 ++-- .../Shared/CodeTools/Tests/CompilerTest.cs | 24 ++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index b4640ef..1efe798 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -444,7 +444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // return compileScript; // } - private static string CreateCSCompilerScript( + public static string CreateCSCompilerScript( string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters) { compileScript = string.Format( @@ -472,7 +472,7 @@ namespace SecondLife return compileScript; } - private static string CreateVBCompilerScript(string compileScript, string className, string baseClassName) + public static string CreateVBCompilerScript(string compileScript, string className, string baseClassName) { compileScript = String.Empty + "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " + diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 05a8756..29b6006 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using Microsoft.CSharp; using NUnit.Framework; using OpenSim.Region.ScriptEngine.Shared.CodeTools; +using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Tests.Common; namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests @@ -66,9 +67,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests m_CSCodeProvider = new CSharpCodeProvider(); m_compilerParameters = new CompilerParameters(); - string rootPath = Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory), "bin"); + string rootPath = Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory)); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); + m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll")); m_compilerParameters.GenerateExecutable = false; } @@ -112,6 +114,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests "public Script() { } " + cg.Convert(input) + "} }\n"; + Dictionary, KeyValuePair> positionMap = cg.PositionMap; m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); @@ -124,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests /// Test that a string can be cast to string and another string /// concatenated. /// - //[Test] + [Test] public void TestCastAndConcatString() { TestHelpers.InMethod(); @@ -143,15 +146,20 @@ default } }"; +// System.Console.WriteLine(input); CSCodeGenerator cg = new CSCodeGenerator(); - string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + - "namespace SecondLife { " + - "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + - "public Script() { } " + - cg.Convert(input) + - "} }\n"; + string output = cg.Convert(input); + + output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); +// System.Console.WriteLine(output); + m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); +// foreach (CompilerError compErr in m_compilerResults.Errors) +// { +// System.Console.WriteLine("Error: {0}", compErr); +// } + Assert.AreEqual(0, m_compilerResults.Errors.Count); } } -- cgit v1.1 From cf95b65c10c285b297257db492fbeb9dc19d1d4c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 May 2014 22:29:47 +0100 Subject: Get regression test TestUseUndeclaredVariable() functional again, though not yet enabled. This reveals the position map problems and will make the fix (and subsequent continual checking) easier. --- .../Shared/CodeTools/Tests/CompilerTest.cs | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 29b6006..ab68793 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -108,19 +108,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests }"; CSCodeGenerator cg = new CSCodeGenerator(); - string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + - "namespace SecondLife { " + - "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + - "public Script() { } " + - cg.Convert(input) + - "} }\n"; + string output = cg.Convert(input); + + output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); + System.Console.WriteLine(output); Dictionary, KeyValuePair> positionMap = cg.PositionMap; m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); - Assert.AreEqual(new KeyValuePair(5, 21), - positionMap[new KeyValuePair(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]); + foreach (KeyValuePair key in positionMap.Keys) + { + KeyValuePair val = positionMap[key]; + + System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value); + } + + foreach (CompilerError compErr in m_compilerResults.Errors) + { + System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr); + } + + Assert.AreEqual( + new KeyValuePair(5, 21), + positionMap[new KeyValuePair(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]); } /// -- cgit v1.1 From 9bae636ff0dc426e913e26c45b6936f16131f6d5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 24 May 2014 00:12:23 +0100 Subject: Fix issues where reported LSL compiler error line numbers do not match the script. This is probably due to changes in the layout of the generated script preamble (using statements etc, ) in c8afc852 (Jan 17 2013). Re-enabled existing regression test that exercises at least one case of this. --- .../Shared/CodeTools/CSCodeGenerator.cs | 2 +- .../Shared/CodeTools/Tests/CompilerTest.cs | 30 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 6aa717d..8b8e038 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -162,7 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools m_braceCount++; // line number - m_CSharpLine += 3; + m_CSharpLine += 9; // here's the payload retstr += GenerateLine(); diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index ab68793..badf82a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -92,7 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests /// Test the C# compiler error message can be mapped to the correct /// line/column in the LSL source when an undeclared variable is used. /// - //[Test] + [Test] public void TestUseUndeclaredVariable() { TestHelpers.InMethod(); @@ -110,24 +110,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests CSCodeGenerator cg = new CSCodeGenerator(); string output = cg.Convert(input); - output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); - System.Console.WriteLine(output); + output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null); +// System.Console.WriteLine(output); Dictionary, KeyValuePair> positionMap = cg.PositionMap; m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); - - foreach (KeyValuePair key in positionMap.Keys) - { - KeyValuePair val = positionMap[key]; - - System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value); - } - - foreach (CompilerError compErr in m_compilerResults.Errors) - { - System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr); - } +// +// foreach (KeyValuePair key in positionMap.Keys) +// { +// KeyValuePair val = positionMap[key]; +// +// System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value); +// } +// +// foreach (CompilerError compErr in m_compilerResults.Errors) +// { +// System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr); +// } Assert.AreEqual( new KeyValuePair(5, 21), -- cgit v1.1 From 20f20895cf1444071d5edc42e11a1fb94b1b1079 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 23 May 2014 16:19:43 -0700 Subject: Adds optional HTTP Basic Authentication to Robust service connectors. --- OpenSim/Framework/Communications/RestClient.cs | 29 ++++++-- .../Servers/HttpServer/BaseStreamHandler.cs | 19 +++++- .../ServiceAuth/BasicHttpAuthentication.cs | 79 ++++++++++++++++++++++ OpenSim/Framework/ServiceAuth/IServiceAuth.cs | 15 ++++ OpenSim/Framework/ServiceAuth/ServiceAuth.cs | 23 +++++++ OpenSim/Framework/WebUtil.cs | 75 ++++++++++++++++++-- .../Avatar/BakedTextures/XBakesModule.cs | 8 ++- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 2 +- .../Server/Handlers/Asset/AssetServerConnector.cs | 9 ++- .../Handlers/Asset/AssetServerDeleteHandler.cs | 7 ++ .../Server/Handlers/Asset/AssetServerGetHandler.cs | 9 ++- .../Handlers/Asset/AssetServerPostHandler.cs | 7 ++ .../Server/Handlers/Asset/AssetsExistHandler.cs | 7 ++ .../AuthenticationServerConnector.cs | 5 +- .../AuthenticationServerPostHandler.cs | 8 ++- .../Handlers/Avatar/AvatarServerConnector.cs | 5 +- .../Handlers/Avatar/AvatarServerPostHandler.cs | 5 +- .../Handlers/BakedTextures/XBakesGetHandler.cs | 9 +-- .../Server/Handlers/BakedTextures/XBakesHandler.cs | 7 +- .../Handlers/BakedTextures/XBakesPostHandler.cs | 11 +-- .../Handlers/Friends/FriendServerConnector.cs | 4 +- .../Handlers/Friends/FriendsServerPostHandler.cs | 5 +- .../Server/Handlers/Grid/GridServerConnector.cs | 5 +- .../Server/Handlers/Grid/GridServerPostHandler.cs | 5 +- .../Handlers/GridUser/GridUserServerConnector.cs | 5 +- .../Handlers/GridUser/GridUserServerPostHandler.cs | 5 +- .../Handlers/Inventory/XInventoryInConnector.cs | 9 ++- .../Server/Handlers/Map/MapAddServerConnector.cs | 8 ++- .../Handlers/Presence/PresenceServerConnector.cs | 5 +- .../Handlers/Presence/PresenceServerPostHandler.cs | 5 +- .../UserAccounts/UserAccountServerConnector.cs | 5 +- .../UserAccounts/UserAccountServerPostHandler.cs | 7 +- .../Connectors/Asset/AssetServicesConnector.cs | 19 +++--- .../AuthenticationServicesConnector.cs | 14 ++-- .../Connectors/Avatar/AvatarServicesConnector.cs | 17 +++-- .../Services/Connectors/BaseServiceConnector.cs | 33 +++++++++ .../Connectors/Friends/FriendsServicesConnector.cs | 10 +-- .../Connectors/Grid/GridServicesConnector.cs | 31 +++++---- .../GridUser/GridUserServicesConnector.cs | 13 ++-- .../Inventory/XInventoryServicesConnector.cs | 5 +- .../MapImage/MapImageServicesConnector.cs | 10 ++- .../Presence/PresenceServicesConnector.cs | 23 +++++-- .../UserAccounts/UserAccountServicesConnector.cs | 14 ++-- bin/OpenSim.ini.example | 10 +++ bin/Robust.HG.ini.example | 15 ++++ bin/Robust.ini.example | 13 ++++ prebuild.xml | 1 + 47 files changed, 519 insertions(+), 116 deletions(-) create mode 100644 OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs create mode 100644 OpenSim/Framework/ServiceAuth/IServiceAuth.cs create mode 100644 OpenSim/Framework/ServiceAuth/ServiceAuth.cs create mode 100644 OpenSim/Services/Connectors/BaseServiceConnector.cs diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index e7f0ca8..89e6aa1 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -35,6 +35,8 @@ using System.Threading; using System.Web; using log4net; +using OpenSim.Framework.ServiceAuth; + namespace OpenSim.Framework.Communications { /// @@ -297,7 +299,7 @@ namespace OpenSim.Framework.Communications /// /// Perform a synchronous request /// - public Stream Request() + public Stream Request(IServiceAuth auth) { lock (_lock) { @@ -307,6 +309,8 @@ namespace OpenSim.Framework.Communications _request.Timeout = 200000; _request.Method = RequestMethod; _asyncException = null; + if (auth != null) + auth.AddAuthorization(_request.Headers); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); try @@ -358,7 +362,7 @@ namespace OpenSim.Framework.Communications } } - public Stream Request(Stream src) + public Stream Request(Stream src, IServiceAuth auth) { _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; @@ -367,6 +371,8 @@ namespace OpenSim.Framework.Communications _request.Method = RequestMethod; _asyncException = null; _request.ContentLength = src.Length; + if (auth != null) + auth.AddAuthorization(_request.Headers); m_log.InfoFormat("[REST]: Request Length {0}", _request.ContentLength); m_log.InfoFormat("[REST]: Sending Web Request {0}", buildUri()); @@ -384,7 +390,22 @@ namespace OpenSim.Framework.Communications length = src.Read(buf, 0, 1024); } - _response = (HttpWebResponse) _request.GetResponse(); + try + { + _response = (HttpWebResponse)_request.GetResponse(); + } + catch (WebException e) + { + m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}", + RequestMethod, _request.RequestUri, e.Status, e.Message); + } + catch (Exception e) + { + m_log.WarnFormat( + "[REST]: Request {0} {1} failed with exception {2} {3}", + RequestMethod, _request.RequestUri, e.Message, e.StackTrace); + } + // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -423,7 +444,7 @@ namespace OpenSim.Framework.Communications try { // Perform the operation; if sucessful set the result - Stream s = Request(); + Stream s = Request(null); ar.SetAsCompleted(s, false); } catch (Exception e) diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs index 252cc2a..f160734 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs @@ -26,6 +26,8 @@ */ using System.IO; +using System.Net; +using OpenSim.Framework.ServiceAuth; namespace OpenSim.Framework.Servers.HttpServer { @@ -37,15 +39,30 @@ namespace OpenSim.Framework.Servers.HttpServer /// public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler { - protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} + protected IServiceAuth m_Auth; + + protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) { } protected BaseStreamHandler(string httpMethod, string path, string name, string description) : base(httpMethod, path, name, description) {} + protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth) + : base(httpMethod, path, null, null) + { + m_Auth = auth; + } + public virtual byte[] Handle( string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { RequestsReceived++; + if (m_Auth != null && !m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader)) + { + + httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; + httpResponse.ContentType = "text/plain"; + return new byte[0]; + } byte[] result = ProcessRequest(path, request, httpRequest, httpResponse); diff --git a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs new file mode 100644 index 0000000..f33a045 --- /dev/null +++ b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Reflection; + +using Nini.Config; +using log4net; + +namespace OpenSim.Framework.ServiceAuth +{ + public class BasicHttpAuthentication : IServiceAuth + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_Username, m_Password; + private string m_CredentialsB64; + + private string remove_me; + + public string Credentials + { + get { return m_CredentialsB64; } + } + + public BasicHttpAuthentication(IConfigSource config, string section) + { + remove_me = section; + m_Username = Util.GetConfigVarFromSections(config, "HttpAuthUsername", new string[] { "Network", section }, string.Empty); + m_Password = Util.GetConfigVarFromSections(config, "HttpAuthPassword", new string[] { "Network", section }, string.Empty); + string str = m_Username + ":" + m_Password; + byte[] encData_byte = Util.UTF8.GetBytes(str); + + m_CredentialsB64 = Convert.ToBase64String(encData_byte); + m_log.DebugFormat("[HTTP BASIC AUTH]: {0} {1} [{2}]", m_Username, m_Password, section); + } + + public void AddAuthorization(NameValueCollection headers) + { + //m_log.DebugFormat("[HTTP BASIC AUTH]: Adding authorization for {0}", remove_me); + headers["Authorization"] = "Basic " + m_CredentialsB64; + } + + public bool Authenticate(string data) + { + string recovered = Util.Base64ToString(data); + if (!String.IsNullOrEmpty(recovered)) + { + string[] parts = recovered.Split(new char[] { ':' }); + if (parts.Length >= 2) + { + return m_Username.Equals(parts[0]) && m_Password.Equals(parts[1]); + } + } + + return false; + } + + public bool Authenticate(NameValueCollection requestHeaders, AddHeaderDelegate d) + { + //m_log.DebugFormat("[HTTP BASIC AUTH]: Authenticate in {0}", remove_me); + if (requestHeaders != null) + { + string value = requestHeaders.Get("Authorization"); + if (value != null) + { + value = value.Trim(); + if (value.StartsWith("Basic ")) + { + value = value.Replace("Basic ", string.Empty); + if (Authenticate(value)) + return true; + } + } + } + d("WWW-Authenticate", "Basic realm = \"Asset Server\""); + return false; + } + } +} diff --git a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs new file mode 100644 index 0000000..415dc12 --- /dev/null +++ b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; + +namespace OpenSim.Framework.ServiceAuth +{ + public delegate void AddHeaderDelegate(string key, string value); + + public interface IServiceAuth + { + bool Authenticate(string data); + bool Authenticate(NameValueCollection headers, AddHeaderDelegate d); + void AddAuthorization(NameValueCollection headers); + } +} diff --git a/OpenSim/Framework/ServiceAuth/ServiceAuth.cs b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs new file mode 100644 index 0000000..bc32d90 --- /dev/null +++ b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +using Nini.Config; + +namespace OpenSim.Framework.ServiceAuth +{ + public class ServiceAuth + { + public static IServiceAuth Create(IConfigSource config, string section) + { + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", section }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + return new BasicHttpAuthentication(config, section); + } + + return null; + } + } +} diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 0970fd1..e614fd5 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -45,6 +45,8 @@ using Nwc.XmlRpc; using OpenMetaverse.StructuredData; using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper; +using OpenSim.Framework.ServiceAuth; + namespace OpenSim.Framework { /// @@ -773,6 +775,13 @@ namespace OpenSim.Framework string requestUrl, TRequest obj, Action action, int maxConnections) { + MakeRequest(verb, requestUrl, obj, action, maxConnections, null); + } + + public static void MakeRequest(string verb, + string requestUrl, TRequest obj, Action action, + int maxConnections, IServiceAuth auth) + { int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) @@ -786,6 +795,10 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); HttpWebRequest ht = (HttpWebRequest)request; + + if (auth != null) + auth.AddAuthorization(ht.Headers); + if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) ht.ServicePoint.ConnectionLimit = maxConnections; @@ -969,7 +982,7 @@ namespace OpenSim.Framework /// /// Thrown if we encounter a network issue while posting /// the request. You'll want to make sure you deal with this as they're not uncommon - public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs) + public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs, IServiceAuth auth) { int reqnum = WebUtil.RequestNumber++; @@ -984,6 +997,10 @@ namespace OpenSim.Framework request.Method = verb; if (timeoutsecs > 0) request.Timeout = timeoutsecs * 1000; + + if (auth != null) + auth.AddAuthorization(request.Headers); + string respstring = String.Empty; using (MemoryStream buffer = new MemoryStream()) @@ -1068,10 +1085,20 @@ namespace OpenSim.Framework return respstring; } + public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs) + { + return MakeRequest(verb, requestUrl, obj, timeoutsecs, null); + } + public static string MakeRequest(string verb, string requestUrl, string obj) { return MakeRequest(verb, requestUrl, obj, -1); } + + public static string MakeRequest(string verb, string requestUrl, string obj, IServiceAuth auth) + { + return MakeRequest(verb, requestUrl, obj, -1, auth); + } } public class SynchronousRestObjectRequester @@ -1094,6 +1121,10 @@ namespace OpenSim.Framework return MakeRequest(verb, requestUrl, obj, 0); } + public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, IServiceAuth auth) + { + return MakeRequest(verb, requestUrl, obj, 0, auth); + } /// /// Perform a synchronous REST request. /// @@ -1112,7 +1143,11 @@ namespace OpenSim.Framework return MakeRequest(verb, requestUrl, obj, pTimeout, 0); } - /// + public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, IServiceAuth auth) + { + return MakeRequest(verb, requestUrl, obj, pTimeout, 0, auth); + } + /// Perform a synchronous REST request. /// /// @@ -1128,6 +1163,25 @@ namespace OpenSim.Framework /// public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) { + return MakeRequest(verb, requestUrl, obj, pTimeout, maxConnections, null); + } + + /// + /// Perform a synchronous REST request. + /// + /// + /// + /// + /// + /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) + /// + /// + /// + /// The response. If there was an internal exception or the request timed out, + /// then the default(TResponse) is returned. + /// + public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections, IServiceAuth auth) + { int reqnum = WebUtil.RequestNumber++; if (WebUtil.DebugLevel >= 3) @@ -1143,6 +1197,9 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); HttpWebRequest ht = (HttpWebRequest)request; + if (auth != null) + auth.AddAuthorization(ht.Headers); + if (pTimeout != 0) ht.Timeout = pTimeout; @@ -1221,8 +1278,18 @@ namespace OpenSim.Framework { using (HttpWebResponse hwr = (HttpWebResponse)e.Response) { - if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound) - return deserial; + if (hwr != null) + { + if (hwr.StatusCode == HttpStatusCode.NotFound) + return deserial; + if (hwr.StatusCode == HttpStatusCode.Unauthorized) + { + m_log.Error(string.Format( + "[SynchronousRestObjectRequester]: Web request {0} requires authentication ", + requestUrl)); + return deserial; + } + } else m_log.Error(string.Format( "[SynchronousRestObjectRequester]: WebException for {0} {1} {2} ", diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs index af8a0c1..780d17b 100644 --- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs @@ -37,6 +37,7 @@ using System.Collections.Generic; using System.Reflection; using log4net; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -54,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures private string m_URL = String.Empty; private static XmlSerializer m_serializer = new XmlSerializer(typeof(AssetBase)); - + private static IServiceAuth m_Auth; public void Initialise(IConfigSource configSource) { @@ -63,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures return; m_URL = config.GetString("URL", String.Empty); + m_Auth = ServiceAuth.Create(configSource, "XBakes"); } public void AddRegion(Scene scene) @@ -110,7 +112,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures try { - Stream s = rc.Request(); + Stream s = rc.Request(m_Auth); XmlTextReader sr = new XmlTextReader(s); sr.ReadStartElement("BakedAppearance"); @@ -183,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures Util.FireAndForget( delegate { - rc.Request(reqStream); + rc.Request(reqStream, m_Auth); } ); } diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 0c0a7aa..4a06f6e 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -381,7 +381,7 @@ namespace OpenSim.Region.DataSnapshot cli.RequestMethod = "GET"; try { - reply = cli.Request(); + reply = cli.Request(null); } catch (WebException) { diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 9b86986..df9a51b 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -30,6 +30,7 @@ using System.IO; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Console; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; @@ -83,9 +84,11 @@ namespace OpenSim.Server.Handlers.Asset allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; } - server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); - server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); - server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth)); + server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth)); + server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth)); server.AddStreamHandler(new AssetsExistHandler(m_AssetService)); MainConsole.Instance.Commands.AddCommand("Assets", false, diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 941b97d..d85d471 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.Asset @@ -70,6 +71,12 @@ namespace OpenSim.Server.Handlers.Asset m_allowedTypes = allowedTypes; } + public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes, IServiceAuth auth) : + base("DELETE", "/assets", auth) + { + m_AssetService = service; + m_allowedTypes = allowedTypes; + } protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs index ed3b4af..500ec50 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs @@ -38,19 +38,26 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.Asset { public class AssetServerGetHandler : BaseStreamHandler { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IAssetService m_AssetService; public AssetServerGetHandler(IAssetService service) : base("GET", "/assets") { + m_AssetService = service; + } + + public AssetServerGetHandler(IAssetService service, IServiceAuth auth) : + base("GET", "/assets", auth) + { m_AssetService = service; } diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs index a77e67d..1c706a7 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.Asset @@ -54,6 +55,12 @@ namespace OpenSim.Server.Handlers.Asset m_AssetService = service; } + public AssetServerPostHandler(IAssetService service, IServiceAuth auth) : + base("POST", "/assets", auth) + { + m_AssetService = service; + } + protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { diff --git a/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs index 6d01f86..32901b3 100644 --- a/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -55,6 +56,12 @@ namespace OpenSim.Server.Handlers.Asset m_AssetService = service; } + public AssetsExistHandler(IAssetService service, IServiceAuth auth) : + base("POST", "/get_assets_exist", auth) + { + m_AssetService = service; + } + protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { XmlSerializer xs; diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs index 848a037..c9a8dce 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -58,7 +59,9 @@ namespace OpenSim.Server.Handlers.Authentication Object[] args = new Object[] { config }; m_AuthenticationService = ServerUtils.LoadPlugin(authenticationService, args); - server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService, serverConfig)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService, serverConfig, auth)); } } } diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 16e011a..e258dde 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -55,10 +56,10 @@ namespace OpenSim.Server.Handlers.Authentication private bool m_AllowSetPassword = false; public AuthenticationServerPostHandler(IAuthenticationService service) : - this(service, null) {} + this(service, null, null) {} - public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config) : - base("POST", "/auth") + public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config, IServiceAuth auth) : + base("POST", "/auth", auth) { m_AuthenticationService = service; @@ -73,6 +74,7 @@ namespace OpenSim.Server.Handlers.Authentication protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { + m_log.Error("[XXX]: Authenticating..."); string[] p = SplitParams(path); if (p.Length > 0) diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs index 9a57cd9..1831e84 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Avatar Object[] args = new Object[] { config }; m_AvatarService = ServerUtils.LoadPlugin(avatarService, args); - server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new AvatarServerPostHandler(m_AvatarService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index d6bbb8f..59dbed4 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.Avatar private IAvatarService m_AvatarService; - public AvatarServerPostHandler(IAvatarService service) : - base("POST", "/avatar") + public AvatarServerPostHandler(IAvatarService service, IServiceAuth auth) : + base("POST", "/avatar", auth) { m_AvatarService = service; } diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs index fb4b794..9e703f1 100644 --- a/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesGetHandler.cs @@ -38,6 +38,7 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.BakedTextures @@ -50,14 +51,14 @@ namespace OpenSim.Server.Handlers.BakedTextures private System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding(); - public BakesServerGetHandler(IBakedTextureService service) : - base("GET", "/bakes") + public BakesServerGetHandler(IBakedTextureService service, IServiceAuth auth) : + base("GET", "/bakes", auth) { m_BakesService = service; } - public override byte[] Handle(string path, Stream request, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override byte[] ProcessRequest( + string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { string[] p = SplitParams(path); diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs index 7bf7641..4c12967 100644 --- a/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesHandler.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -59,8 +60,10 @@ namespace OpenSim.Server.Handlers.BakedTextures m_BakesService = ServerUtils.LoadPlugin(assetService, args); - server.AddStreamHandler(new BakesServerGetHandler(m_BakesService)); - server.AddStreamHandler(new BakesServerPostHandler(m_BakesService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new BakesServerGetHandler(m_BakesService, auth)); + server.AddStreamHandler(new BakesServerPostHandler(m_BakesService, auth)); } } } diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs index 69adb7f..1aacbc9 100644 --- a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs +++ b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs @@ -38,27 +38,28 @@ using System.Xml.Serialization; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Server.Handlers.BakedTextures { public class BakesServerPostHandler : BaseStreamHandler { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IBakedTextureService m_BakesService; private System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding(); - public BakesServerPostHandler(IBakedTextureService service) : - base("POST", "/bakes") + public BakesServerPostHandler(IBakedTextureService service, IServiceAuth auth) : + base("POST", "/bakes", auth) { m_BakesService = service; } - public override byte[] Handle(string path, Stream request, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override byte[] ProcessRequest( + string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { string[] p = SplitParams(path); diff --git a/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs index 5784bdf..b0e6c7d 100644 --- a/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs +++ b/OpenSim/Server/Handlers/Friends/FriendServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,8 @@ namespace OpenSim.Server.Handlers.Friends Object[] args = new Object[] { config }; m_FriendsService = ServerUtils.LoadPlugin(theService, args); - server.AddStreamHandler(new FriendsServerPostHandler(m_FriendsService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + server.AddStreamHandler(new FriendsServerPostHandler(m_FriendsService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index ca0a24c..d442443 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs @@ -40,6 +40,7 @@ using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -51,8 +52,8 @@ namespace OpenSim.Server.Handlers.Friends private IFriendsService m_FriendsService; - public FriendsServerPostHandler(IFriendsService service) : - base("POST", "/friends") + public FriendsServerPostHandler(IFriendsService service, IServiceAuth auth) : + base("POST", "/friends", auth) { m_FriendsService = service; } diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs index 14daf12..6eb6a79 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Grid Object[] args = new Object[] { config }; m_GridService = ServerUtils.LoadPlugin(gridService, args); - server.AddStreamHandler(new GridServerPostHandler(m_GridService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new GridServerPostHandler(m_GridService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 37ca5a4..dda4756 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -40,6 +40,7 @@ using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -55,8 +56,8 @@ namespace OpenSim.Server.Handlers.Grid private IGridService m_GridService; - public GridServerPostHandler(IGridService service) : - base("POST", "/grid") + public GridServerPostHandler(IGridService service, IServiceAuth auth) : + base("POST", "/grid", auth) { m_GridService = service; } diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs index 66f35e3..1e29378 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs @@ -29,6 +29,7 @@ using System; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.GridUser Object[] args = new Object[] { config }; m_GridUserService = ServerUtils.LoadPlugin(service, args); - server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); ; + + server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService, auth)); } } } diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 0b98e9a..006f6ab 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs @@ -39,6 +39,7 @@ using System.Collections.Generic; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.GridUser private IGridUserService m_GridUserService; - public GridUserServerPostHandler(IGridUserService service) : - base("POST", "/griduser") + public GridUserServerPostHandler(IGridUserService service, IServiceAuth auth) : + base("POST", "/griduser", auth) { m_GridUserService = service; } diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index ce975a8..7283237 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using System.IO; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; @@ -71,7 +72,9 @@ namespace OpenSim.Server.Handlers.Asset m_InventoryService = ServerUtils.LoadPlugin(inventoryService, args); - server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService, auth)); } } @@ -81,8 +84,8 @@ namespace OpenSim.Server.Handlers.Asset private IInventoryService m_InventoryService; - public XInventoryConnectorPostHandler(IInventoryService service) : - base("POST", "/xinventory") + public XInventoryConnectorPostHandler(IInventoryService service, IServiceAuth auth) : + base("POST", "/xinventory", auth) { m_InventoryService = service; } diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index 4d1729e..a896fdb 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs @@ -38,6 +38,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -79,7 +80,8 @@ namespace OpenSim.Server.Handlers.MapImage m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); bool proxy = serverConfig.GetBoolean("HasProxy", false); - server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy, auth)); } } @@ -91,8 +93,8 @@ namespace OpenSim.Server.Handlers.MapImage private IGridService m_GridService; bool m_Proxy; - public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) : - base("POST", "/map") + public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy, IServiceAuth auth) : + base("POST", "/map", auth) { m_MapService = service; m_GridService = grid; diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs index 899cd8f..7a63c36 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerConnector.cs @@ -30,6 +30,7 @@ using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; namespace OpenSim.Server.Handlers.Presence @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Presence Object[] args = new Object[] { config }; m_PresenceService = ServerUtils.LoadPlugin(gridService, args); - server.AddStreamHandler(new PresenceServerPostHandler(m_PresenceService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new PresenceServerPostHandler(m_PresenceService, auth)); } } } diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index abb4b19..0b3b961 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -40,6 +40,7 @@ using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenMetaverse; namespace OpenSim.Server.Handlers.Presence @@ -50,8 +51,8 @@ namespace OpenSim.Server.Handlers.Presence private IPresenceService m_PresenceService; - public PresenceServerPostHandler(IPresenceService service) : - base("POST", "/presence") + public PresenceServerPostHandler(IPresenceService service, IServiceAuth auth) : + base("POST", "/presence", auth) { m_PresenceService = service; } diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs index 344b513..e95e3dc 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerConnector.cs @@ -30,6 +30,7 @@ using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; namespace OpenSim.Server.Handlers.UserAccounts @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.UserAccounts Object[] args = new Object[] { config }; m_UserAccountService = ServerUtils.LoadPlugin(service, args); - server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new UserAccountServerPostHandler(m_UserAccountService, serverConfig, auth)); } } } diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index 24c9de6..c87e022 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -41,6 +41,7 @@ using OpenSim.Services.Interfaces; using OpenSim.Services.UserAccountService; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenMetaverse; namespace OpenSim.Server.Handlers.UserAccounts @@ -54,10 +55,10 @@ namespace OpenSim.Server.Handlers.UserAccounts private bool m_AllowSetAccount = false; public UserAccountServerPostHandler(IUserAccountService service) - : this(service, null) {} + : this(service, null, null) {} - public UserAccountServerPostHandler(IUserAccountService service, IConfig config) : - base("POST", "/accounts") + public UserAccountServerPostHandler(IUserAccountService service, IConfig config, IServiceAuth auth) : + base("POST", "/accounts", auth) { m_UserAccountService = service; diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index 2ba8e04..0996acb 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs @@ -39,7 +39,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class AssetServicesConnector : IAssetService + public class AssetServicesConnector : BaseServiceConnector, IAssetService { private static readonly ILog m_log = LogManager.GetLogger( @@ -71,6 +71,7 @@ namespace OpenSim.Services.Connectors } public AssetServicesConnector(IConfigSource source) + : base(source, "AssetService") { Initialise(source); } @@ -126,7 +127,7 @@ namespace OpenSim.Services.Connectors // = SynchronousRestObjectRequester.MakeRequest( // "GET", uri, 0, m_maxAssetRequestConcurrency); - asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0); + asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth); if (m_Cache != null) m_Cache.Cache(asset); @@ -156,7 +157,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/assets/" + id + "/metadata"; - AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0); + AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth); return asset; } @@ -177,7 +178,7 @@ namespace OpenSim.Services.Connectors rc.RequestMethod = "GET"; - Stream s = rc.Request(); + Stream s = rc.Request(m_Auth); if (s == null) return null; @@ -238,7 +239,7 @@ namespace OpenSim.Services.Connectors m_AssetHandlers.Remove(id); } handlers.Invoke(a); - }, m_maxAssetRequestConcurrency); + }, m_maxAssetRequestConcurrency, m_Auth); success = true; } @@ -268,7 +269,7 @@ namespace OpenSim.Services.Connectors bool[] exist = null; try { - exist = SynchronousRestObjectRequester.MakeRequest("POST", uri, ids); + exist = SynchronousRestObjectRequester.MakeRequest("POST", uri, ids, m_Auth); } catch (Exception) { @@ -297,7 +298,7 @@ namespace OpenSim.Services.Connectors string newID; try { - newID = SynchronousRestObjectRequester.MakeRequest("POST", uri, asset); + newID = SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth); } catch (Exception e) { @@ -343,7 +344,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectRequester.MakeRequest("POST", uri, asset)) + if (SynchronousRestObjectRequester.MakeRequest("POST", uri, asset, m_Auth)) { if (m_Cache != null) m_Cache.Cache(asset); @@ -357,7 +358,7 @@ namespace OpenSim.Services.Connectors { string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectRequester.MakeRequest("DELETE", uri, 0)) + if (SynchronousRestObjectRequester.MakeRequest("DELETE", uri, 0, m_Auth)) { if (m_Cache != null) m_Cache.Expire(id); diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs index 2b77154..56b6434 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs @@ -32,14 +32,14 @@ using System.IO; using System.Reflection; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using OpenSim.Server.Base; using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class AuthenticationServicesConnector : IAuthenticationService + public class AuthenticationServicesConnector : BaseServiceConnector, IAuthenticationService { private static readonly ILog m_log = LogManager.GetLogger( @@ -57,6 +57,7 @@ namespace OpenSim.Services.Connectors } public AuthenticationServicesConnector(IConfigSource source) + : base(source, "AuthenticationService") { Initialise(source); } @@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Authentication connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "AuthenticationService"); } public string Authenticate(UUID principalID, string password, int lifetime) @@ -92,7 +95,7 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auth/plain", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); @@ -105,6 +108,7 @@ namespace OpenSim.Services.Connectors public bool Verify(UUID principalID, string token, int lifetime) { + m_log.Error("[XXX]: Verify"); Dictionary sendData = new Dictionary(); sendData["LIFETIME"] = lifetime.ToString(); sendData["PRINCIPAL"] = principalID.ToString(); @@ -114,7 +118,7 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auth/plain", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); @@ -135,7 +139,7 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auth/plain", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs index ddfca57..3f44efa 100644 --- a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs +++ b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs @@ -32,7 +32,7 @@ using System.IO; using System.Reflection; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using IAvatarService = OpenSim.Services.Interfaces.IAvatarService; @@ -41,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class AvatarServicesConnector : IAvatarService + public class AvatarServicesConnector : BaseServiceConnector, IAvatarService { private static readonly ILog m_log = LogManager.GetLogger( @@ -59,6 +59,7 @@ namespace OpenSim.Services.Connectors } public AvatarServicesConnector(IConfigSource source) + : base(source, "AvatarService") { Initialise(source); } @@ -81,6 +82,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Avatar connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "AvatarService"); } @@ -114,7 +117,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply"); @@ -162,7 +165,7 @@ namespace OpenSim.Services.Connectors //m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -207,7 +210,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -250,7 +253,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -293,7 +296,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); diff --git a/OpenSim/Services/Connectors/BaseServiceConnector.cs b/OpenSim/Services/Connectors/BaseServiceConnector.cs new file mode 100644 index 0000000..98cd489 --- /dev/null +++ b/OpenSim/Services/Connectors/BaseServiceConnector.cs @@ -0,0 +1,33 @@ +using System; +using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; + +using Nini.Config; + +namespace OpenSim.Services.Connectors +{ + public class BaseServiceConnector + { + protected IServiceAuth m_Auth; + + public BaseServiceConnector() { } + + public BaseServiceConnector(IConfigSource config, string section) + { + Initialise(config, section); + } + + public void Initialise(IConfigSource config, string section) + { + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", section }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + m_Auth = new BasicHttpAuthentication(config, section); + break; + } + + } + } +} diff --git a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs index b1dd84e..74851a9 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs @@ -32,6 +32,7 @@ using System.IO; using System.Reflection; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Communications; using OpenSim.Services.Interfaces; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors.Friends { - public class FriendsServicesConnector : IFriendsService + public class FriendsServicesConnector : BaseServiceConnector, IFriendsService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors.Friends throw new Exception("Friends connector init error"); } m_ServerURI = serviceURI; + base.Initialise(source, "FriendsService"); } @@ -112,7 +114,7 @@ namespace OpenSim.Services.Connectors.Friends try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -168,7 +170,7 @@ namespace OpenSim.Services.Connectors.Friends string uri = m_ServerURI + "/friends"; try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -223,7 +225,7 @@ namespace OpenSim.Services.Connectors.Friends string uri = m_ServerURI + "/friends"; try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs index 0f5a613..7f86cff 100644 --- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs @@ -33,6 +33,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class GridServicesConnector : IGridService + public class GridServicesConnector : BaseServiceConnector, IGridService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Grid connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "GridService"); } @@ -102,7 +105,7 @@ namespace OpenSim.Services.Connectors // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); try { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -158,7 +161,7 @@ namespace OpenSim.Services.Connectors try { string reply - = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); if (reply != string.Empty) { @@ -195,7 +198,7 @@ namespace OpenSim.Services.Connectors try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); } catch (Exception e) { @@ -238,7 +241,7 @@ namespace OpenSim.Services.Connectors string uri = m_ServerURI + "/grid"; try { - reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); + reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -285,7 +288,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -330,7 +333,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -374,7 +377,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { @@ -428,7 +431,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -479,7 +482,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -530,7 +533,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -583,7 +586,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -634,7 +637,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); } @@ -685,7 +688,7 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs index 1a62d2f..ffdd94a 100644 --- a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs +++ b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs @@ -33,6 +33,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class GridUserServicesConnector : IGridUserService + public class GridUserServicesConnector : BaseServiceConnector, IGridUserService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors throw new Exception("GridUser connector init error"); } m_ServerURI = serviceURI; + base.Initialise(source, "GridUserService"); } @@ -162,7 +164,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -198,7 +201,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -243,7 +247,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply"); diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 85d105e..f86d2f1 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs @@ -40,7 +40,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class XInventoryServicesConnector : IInventoryService + public class XInventoryServicesConnector : BaseServiceConnector, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger( @@ -60,6 +60,7 @@ namespace OpenSim.Services.Connectors } public XInventoryServicesConnector(IConfigSource source) + : base(source, "InventoryService") { Initialise(source); } @@ -505,7 +506,7 @@ namespace OpenSim.Services.Connectors lock (m_Lock) reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/xinventory", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index 725204d..677825e 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs @@ -36,6 +36,7 @@ using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenMetaverse; @@ -43,7 +44,7 @@ using OpenMetaverse.StructuredData; namespace OpenSim.Services.Connectors { - public class MapImageServicesConnector : IMapImageService + public class MapImageServicesConnector : BaseServiceConnector, IMapImageService { private static readonly ILog m_log = LogManager.GetLogger( @@ -84,6 +85,7 @@ namespace OpenSim.Services.Connectors } m_ServerURI = serviceURI; m_ServerURI = serviceURI.TrimEnd('/'); + base.Initialise(source, "MapImageService"); } public bool RemoveMapTile(int x, int y, out string reason) @@ -101,7 +103,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -163,7 +166,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs index f7d8c53..aade714 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs @@ -33,6 +33,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class PresenceServicesConnector : IPresenceService + public class PresenceServicesConnector : BaseServiceConnector, IPresenceService { private static readonly ILog m_log = LogManager.GetLogger( @@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors throw new Exception("Presence connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "PresenceService"); } @@ -104,7 +107,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -149,7 +153,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -193,7 +198,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -238,7 +244,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); @@ -283,7 +290,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply"); @@ -327,7 +335,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null or empty reply"); diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs index 8110fe5..3f61d9a 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs @@ -33,13 +33,14 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class UserAccountServicesConnector : IUserAccountService + public class UserAccountServicesConnector : BaseServiceConnector, IUserAccountService { private static readonly ILog m_log = LogManager.GetLogger( @@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors throw new Exception("User account connector init error"); } m_ServerURI = serviceURI; + + base.Initialise(source, "UserAccountService"); } public virtual UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) @@ -144,7 +147,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply"); @@ -224,7 +228,8 @@ namespace OpenSim.Services.Connectors { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply"); @@ -260,7 +265,8 @@ namespace OpenSim.Services.Connectors { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, - reqString); + reqString, + m_Auth); if (reply != string.Empty) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index f3cd603..3f9aed6 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -470,6 +470,16 @@ ;; web server ; user_agent = "OpenSim LSL (Mozilla Compatible)" + ;; The follow 3 variables are for HTTP Basic Authentication for the Robust services. + ;; Use this if your central services in port 8003 need to be accessible on the Internet + ;; but you want to protect them from unauthorized access. The username and password + ;; here need to match the ones in the Robust service configuration. + ; AuthType = "BasicHttpAuthentication" + ; HttpAuthUsername = "some_username" + ; HttpAuthPassword = "some_password" + ;; + ;; Any of these 3 variables above can be overriden in any of the service sections. + [XMLRPC] ;# {XmlRpcRouterModule} {} {Module used to route incoming llRemoteData calls} {XmlRpcRouterModule XmlRpcGridRouterModule} XmlRpcRouterModule diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index e385200..aaa78ff 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -104,6 +104,21 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset ; Password for cert ; cert_pass = "password" + ;; The follow 3 variables are for HTTP Basic Authentication for the Robust services. + ;; Use this if your central services in port 8003 need to be accessible on the Internet + ;; but you want to protect them from unauthorized access. + ; AuthType = "BasicHttpAuthentication" + ; HttpAuthUsername = "some_username" + ; HttpAuthPassword = "some_password" + ;; + ;; AuthType above can be overriden in any of the service sections below by + ; AuthType = "None" + ;; This is useful in cases where you want to protect most of the services, + ;; but unprotect individual services. Username and Password can also be + ;; overriden if you want to use different credentials for the different services. + ;; Hypgergrid services are not affected by this; they are publicly available + ;; by design. + ; * The following are for the remote console ; * They have no effect for the local or basic console types diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 2f1a627..203c0e0 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -81,6 +81,19 @@ MapGetServiceConnector = "8002/OpenSim.Server.Handlers.dll:MapGetServiceConnecto ; Password for cert ; cert_pass = "password" + ;; The follow 3 variables are for HTTP Basic Authentication for the Robust services. + ;; Use this if your central services in port 8003 need to be accessible on the Internet + ;; but you want to protect them from unauthorized access. + ; AuthType = "BasicHttpAuthentication" + ; HttpAuthUsername = "some_username" + ; HttpAuthPassword = "some_password" + ;; + ;; AuthType above can be overriden in any of the service sections below by + ; AuthType = "None" + ;; This is useful in cases where you want to protect most of the services, + ;; but unprotect individual services. Username and Password can also be + ;; overriden if you want to use different credentials for the different services. + ; * The following are for the remote console ; * They have no effect for the local or basic console types diff --git a/prebuild.xml b/prebuild.xml index 9a419eb..c35b98e 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -111,6 +111,7 @@ + -- cgit v1.1 From ff9da2446583ffd95b42e7ced2a86c2166c993c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 23 May 2014 17:31:39 -0700 Subject: Added HTTP Authentication also to Groups and offline IM. --- .../Groups/Remote/GroupsServiceRemoteConnector.cs | 33 ++++++++++++++++------ .../Remote/GroupsServiceRemoteConnectorModule.cs | 8 +----- .../Groups/Remote/GroupsServiceRobustConnector.cs | 25 ++++------------ OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs | 2 +- .../Remote/OfflineIMServiceRemoteConnector.cs | 17 ++++++++++- .../Remote/OfflineIMServiceRobustConnector.cs | 9 ++++-- 6 files changed, 55 insertions(+), 39 deletions(-) diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs index 1425a23..7450c14 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs @@ -32,29 +32,47 @@ using System.Reflection; using System.Text; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenMetaverse; using log4net; +using Nini.Config; namespace OpenSim.Groups { - public class GroupsServiceRemoteConnector + public class GroupsServiceRemoteConnector { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_ServerURI; - private string m_SecretKey; + private IServiceAuth m_Auth; private object m_Lock = new object(); - public GroupsServiceRemoteConnector(string url, string secret) + public GroupsServiceRemoteConnector(IConfigSource config) { + IConfig groupsConfig = config.Configs["Groups"]; + string url = groupsConfig.GetString("GroupsServerURI", string.Empty); + if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) + throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); + m_ServerURI = url; if (!m_ServerURI.EndsWith("/")) m_ServerURI += "/"; - m_SecretKey = secret; - m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, secret key {1}", m_ServerURI, m_SecretKey); + /// This is from BaseServiceConnector + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", "Groups" }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + m_Auth = new BasicHttpAuthentication(config, "Groups"); + break; + } + /// + + m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}", + m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString())); } public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, @@ -656,14 +674,13 @@ namespace OpenSim.Groups private Dictionary MakeRequest(string method, Dictionary sendData) { sendData["METHOD"] = method; - if (m_SecretKey != string.Empty) - sendData["KEY"] = m_SecretKey; string reply = string.Empty; lock (m_Lock) reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "groups", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), + m_Auth); if (reply == string.Empty) return null; diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs index 5fb3c19..fddda22 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs @@ -72,13 +72,7 @@ namespace OpenSim.Groups private void Init(IConfigSource config) { - IConfig groupsConfig = config.Configs["Groups"]; - string url = groupsConfig.GetString("GroupsServerURI", string.Empty); - if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) - throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); - - string secret = groupsConfig.GetString("SecretKey", string.Empty); - m_GroupsService = new GroupsServiceRemoteConnector(url, secret); + m_GroupsService = new GroupsServiceRemoteConnector(config); m_Scenes = new List(); } diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs index 33dc301..55ae6db 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs @@ -36,6 +36,7 @@ using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; using log4net; using OpenMetaverse; @@ -69,7 +70,9 @@ namespace OpenSim.Groups m_GroupsService = new GroupsService(config); - server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, auth)); } } @@ -78,13 +81,11 @@ namespace OpenSim.Groups private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private GroupsService m_GroupsService; - private string m_SecretKey = String.Empty; - public GroupsServicePostHandler(GroupsService service, string key) : - base("POST", "/groups") + public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) : + base("POST", "/groups", auth) { m_GroupsService = service; - m_SecretKey = key; } protected override byte[] ProcessRequest(string path, Stream requestData, @@ -108,20 +109,6 @@ namespace OpenSim.Groups string method = request["METHOD"].ToString(); request.Remove("METHOD"); - if (!String.IsNullOrEmpty(m_SecretKey)) // Verification required - { - // Sender didn't send key - if (!request.ContainsKey("KEY") || (request["KEY"] == null)) - return FailureResult("This service requires a secret key"); - - // Sender sent wrong key - if (!m_SecretKey.Equals(request["KEY"])) - return FailureResult("Provided key does not match existing one"); - - // OK, key matches. Remove it. - request.Remove("KEY"); - } - m_log.DebugFormat("[Groups.Handler]: {0}", method); switch (method) { diff --git a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs index 950e1fd..5340bcd 100644 --- a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs +++ b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs @@ -66,7 +66,7 @@ namespace OpenSim.OfflineIM if (serviceLocation == string.Empty) m_OfflineIMService = new OfflineIMService(config); else - m_OfflineIMService = new OfflineIMServiceRemoteConnector(serviceLocation); + m_OfflineIMService = new OfflineIMServiceRemoteConnector(config); m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); m_log.DebugFormat("[OfflineIM.V2]: Offline messages enabled by {0}", Name); diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs index eb287a4..047b8be 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs @@ -32,6 +32,7 @@ using System.Reflection; using System.Text; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; @@ -46,6 +47,7 @@ namespace OpenSim.OfflineIM private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_ServerURI = string.Empty; + private IServiceAuth m_Auth; private object m_Lock = new object(); public OfflineIMServiceRemoteConnector(string url) @@ -65,6 +67,18 @@ namespace OpenSim.OfflineIM m_ServerURI = cnf.GetString("OfflineMessageURL", string.Empty); + /// This is from BaseServiceConnector + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", "Messaging" }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + m_Auth = new BasicHttpAuthentication(config, "Messaging"); + break; + } + /// + m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: Offline IM server at {0} with auth {1}", + m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString())); } #region IOfflineIMService @@ -143,7 +157,8 @@ namespace OpenSim.OfflineIM lock (m_Lock) reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/offlineim", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), + m_Auth); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs index ed5c742..c44b6cc 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs @@ -36,6 +36,7 @@ using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Handlers.Base; using log4net; using OpenMetaverse; @@ -59,7 +60,9 @@ namespace OpenSim.OfflineIM m_OfflineIMService = new OfflineIMService(config); - server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService, auth)); } } @@ -69,8 +72,8 @@ namespace OpenSim.OfflineIM private IOfflineIMService m_OfflineIMService; - public OfflineIMServicePostHandler(IOfflineIMService service) : - base("POST", "/offlineim") + public OfflineIMServicePostHandler(IOfflineIMService service, IServiceAuth auth) : + base("POST", "/offlineim", auth) { m_OfflineIMService = service; } -- cgit v1.1 From 1fa3a6f1bd7c60c5e4226c0d84ee175e1ccb4476 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 22 May 2014 18:23:19 +0300 Subject: When creating a new user, create the folders "Current Outfit", "Favorites", and the standard subfolders of "Calling Cards". (If we don't create them now then they'll be created later by the viewer, but why wait.) --- .../Services/HypergridService/HGSuitcaseInventoryService.cs | 11 ++++------- OpenSim/Services/InventoryService/XInventoryService.cs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 649e66c..d158537 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -164,8 +164,6 @@ namespace OpenSim.Services.HypergridService m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); return null; } - - m_Database.StoreFolder(suitcase); CreateSystemFolders(principalID, suitcase.folderID); } @@ -188,6 +186,10 @@ namespace OpenSim.Services.HypergridService CreateFolder(principalID, rootID, (int)AssetType.CallingCard, "Calling Cards"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) CreateFolder(principalID, rootID, (int)AssetType.Clothing, "Clothing"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) + CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) + CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) CreateFolder(principalID, rootID, (int)AssetType.Gesture, "Gestures"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) @@ -208,11 +210,6 @@ namespace OpenSim.Services.HypergridService CreateFolder(principalID, rootID, (int)AssetType.Texture, "Textures"); if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; })) CreateFolder(principalID, rootID, (int)AssetType.TrashFolder, "Trash"); - if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) - CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites"); - if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) - CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); - } public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 7c16ca9..362ff8f 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -122,10 +122,18 @@ namespace OpenSim.Services.InventoryService if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Bodypart, "Body Parts"); if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; })) - CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards"); + { + XInventoryFolder folder = CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards"); + folder = CreateFolder(principalID, folder.folderID, (int)AssetType.CallingCard, "Friends"); + CreateFolder(principalID, folder.folderID, (int)AssetType.CallingCard, "All"); + } if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Clothing, "Clothing"); - if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) + if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) + CreateFolder(principalID, rootFolder.ID, (int)AssetType.FavoriteFolder, "Favorites"); + if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Gesture, "Gestures"); if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) CreateFolder(principalID, rootFolder.ID, (int)AssetType.Landmark, "Landmarks"); -- cgit v1.1 From e68867c9b6efd72a72d158deab16484b37faab46 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 25 May 2014 11:47:04 +0300 Subject: When taking an object into inventory, set the inventory item's "Next Owner" permissions according to the permissions of the items in the object --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index c4a42bc..b4771fd 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -556,6 +556,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) { + // Changing ownership, so apply the "Next Owner" permissions to all of the + // inventory item's permissions. + uint perms = effectivePerms; PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); @@ -570,6 +573,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } else { + // Not changing ownership. + // In this case we apply the permissions in the object's items ONLY to the inventory + // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions. + // E.g., if the object contains a No-Transfer item then the item's "Next Owner" + // permissions are also No-Transfer. + PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms); + item.BasePermissions = effectivePerms; item.CurrentPermissions = effectivePerms; item.NextPermissions = allObjectsNextOwnerPerms & effectivePerms; -- cgit v1.1 From 5aeaa7fcdd733181454095a50f077d203f674668 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 25 May 2014 17:01:39 +0300 Subject: Prevent login to a region if the Telehub or Landing Point are in a banned parcel --- OpenSim/Region/Framework/Scenes/Scene.cs | 37 ++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7005c0a..eff24f8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3751,6 +3751,13 @@ namespace OpenSim.Region.Framework.Scenes RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); } + // Final permissions check; this time we don't allow changing the position + if (!IsPositionAllowed(acd.AgentID, acd.startpos, ref reason)) + { + m_authenticateHandler.RemoveCircuit(acd.circuitcode); + return false; + } + return true; } @@ -3760,6 +3767,13 @@ namespace OpenSim.Region.Framework.Scenes if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) { acd.startpos = land.LandData.UserLocation; + + // Final permissions check; this time we don't allow changing the position + if (!IsPositionAllowed(acd.AgentID, acd.startpos, ref reason)) + { + m_authenticateHandler.RemoveCircuit(acd.circuitcode); + return false; + } } } } @@ -3767,6 +3781,21 @@ namespace OpenSim.Region.Framework.Scenes return true; } + private bool IsPositionAllowed(UUID agentID, Vector3 pos, ref string reason) + { + ILandObject land = LandChannel.GetLandObject(pos); + if (land == null) + return true; + + if (land.IsBannedFromLand(agentID) || land.IsRestrictedFromLand(agentID)) + { + reason = "You are banned from the region."; + return false; + } + + return true; + } + public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) { if (posX < 0) @@ -5153,7 +5182,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); if (nearestPoint != null) { - Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); + m_log.Debug("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); return nearestPoint.Value; } @@ -5163,7 +5192,7 @@ namespace OpenSim.Region.Framework.Scenes nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); if (nearestPoint != null) { - Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); + m_log.Debug("They had a zero velocity, sending them to: " + nearestPoint.ToString()); return nearestPoint.Value; } @@ -5172,7 +5201,7 @@ namespace OpenSim.Region.Framework.Scenes { // Ultimate backup if we have no idea where they are and // the last allowed position was in another parcel - Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); + m_log.Debug("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); return avatar.lastKnownAllowedPosition; } @@ -5182,7 +5211,7 @@ namespace OpenSim.Region.Framework.Scenes //Go to the edge, this happens in teleporting to a region with no available parcels Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); - //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); + //m_log.Debug("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); return nearestRegionEdgePoint; } -- cgit v1.1 From 33cc847c4ac78b890f8ac175c479ab1b1c56cbbf Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 26 May 2014 15:19:20 +0300 Subject: When saving an OAR in "Publish" mode, also discard Group information --- .../Serialization/External/LandDataSerializer.cs | 18 +++++++++--------- .../Serialization/Tests/LandDataSerializerTests.cs | 3 ++- .../CoreModules/World/Archiver/Tests/ArchiverTests.cs | 3 ++- .../Scenes/Serialization/SceneObjectSerializer.cs | 13 ++++++++++--- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index 709b516..4b5326a 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs @@ -213,8 +213,13 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate)); xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice)); xtw.WriteElementString("GlobalID", landData.GlobalID.ToString()); - xtw.WriteElementString("GroupID", landData.GroupID.ToString()); - xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned)); + + UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : landData.GroupID; + xtw.WriteElementString("GroupID", groupID.ToString()); + + bool isGroupOwned = options.ContainsKey("wipe-owners") ? false : landData.IsGroupOwned; + xtw.WriteElementString("IsGroupOwned", Convert.ToString(isGroupOwned)); + xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap)); xtw.WriteElementString("Description", landData.Description); xtw.WriteElementString("Flags", Convert.ToString((uint)landData.Flags)); @@ -227,13 +232,8 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("MediaURL", landData.MediaURL); xtw.WriteElementString("MusicURL", landData.MusicURL); - UUID ownerIdToWrite; - if (options != null && options.ContainsKey("wipe-owners")) - ownerIdToWrite = UUID.Zero; - else - ownerIdToWrite = landData.OwnerID; - - xtw.WriteElementString("OwnerID", ownerIdToWrite.ToString()); + UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : landData.OwnerID; + xtw.WriteElementString("OwnerID", ownerID.ToString()); xtw.WriteStartElement("ParcelAccessList"); foreach (LandAccessEntry pal in landData.ParcelAccessList) diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs index ea100ee..e81cb78 100644 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs @@ -121,7 +121,8 @@ namespace OpenSim.Framework.Serialization.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - LandData ld = LandDataSerializer.Deserialize(LandDataSerializer.Serialize(this.land, null)); + Dictionary options = new Dictionary(); + LandData ld = LandDataSerializer.Deserialize(LandDataSerializer.Serialize(this.land, options)); Assert.That(ld, Is.Not.Null, "Deserialize(string) returned null"); // Assert.That(ld.AABBMax, Is.EqualTo(land.AABBMax)); // Assert.That(ld.AABBMin, Is.EqualTo(land.AABBMin)); diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index e08a42d..b31257d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -585,7 +585,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests ld.GlobalID = landID; string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); - tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, null)); + Dictionary options = new Dictionary(); + tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options)); tar.Close(); oarStream = new MemoryStream(oarStream.ToArray()); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 85650d6..e68f954 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1343,7 +1343,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); - WriteUUID(writer, "GroupID", sop.GroupID, options); + + UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.GroupID; + WriteUUID(writer, "GroupID", groupID, options); UUID ownerID = options.ContainsKey("wipe-owners") ? UUID.Zero : sop.OwnerID; WriteUUID(writer, "OwnerID", ownerID, options); @@ -1469,7 +1471,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("Description", item.Description); writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString()); writer.WriteElementString("Flags", item.Flags.ToString()); - WriteUUID(writer, "GroupID", item.GroupID, options); + + UUID groupID = options.ContainsKey("wipe-owners") ? UUID.Zero : item.GroupID; + WriteUUID(writer, "GroupID", groupID, options); + writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString()); writer.WriteElementString("InvType", item.InvType.ToString()); WriteUUID(writer, "ItemID", item.ItemID, options); @@ -1490,7 +1495,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteUUID(writer, "PermsGranter", item.PermsGranter, options); writer.WriteElementString("PermsMask", item.PermsMask.ToString()); writer.WriteElementString("Type", item.Type.ToString()); - writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower()); + + bool ownerChanged = options.ContainsKey("wipe-owners") ? false : item.OwnerChanged; + writer.WriteElementString("OwnerChanged", ownerChanged.ToString().ToLower()); writer.WriteEndElement(); // TaskInventoryItem } -- cgit v1.1 From 449548d7a4e3571597b5e4bec53e3f42ebdf6015 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 26 May 2014 08:13:49 -0700 Subject: Adds an optional redirect URL to the asset server handler for when assets are not found locally. --- .../Server/Handlers/Asset/AssetServerConnector.cs | 4 +++- .../Server/Handlers/Asset/AssetServerGetHandler.cs | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index df9a51b..ab81dd6 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -70,6 +70,8 @@ namespace OpenSim.Server.Handlers.Asset bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); + string redirectURL = serverConfig.GetString("RedirectURL", string.Empty); + AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; if (!allowDelete) @@ -86,7 +88,7 @@ namespace OpenSim.Server.Handlers.Asset IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); - server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth)); + server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth, redirectURL)); server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth)); server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth)); server.AddStreamHandler(new AssetsExistHandler(m_AssetService)); diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs index 500ec50..91c5c54 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs @@ -48,6 +48,7 @@ namespace OpenSim.Server.Handlers.Asset private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IAssetService m_AssetService; + private string m_RedirectURL; public AssetServerGetHandler(IAssetService service) : base("GET", "/assets") @@ -55,10 +56,13 @@ namespace OpenSim.Server.Handlers.Asset m_AssetService = service; } - public AssetServerGetHandler(IAssetService service, IServiceAuth auth) : + public AssetServerGetHandler(IAssetService service, IServiceAuth auth, string redirectURL) : base("GET", "/assets", auth) { m_AssetService = service; + m_RedirectURL = redirectURL; + if (!m_RedirectURL.EndsWith("/")) + m_RedirectURL = m_RedirectURL.TrimEnd('/'); } protected override byte[] ProcessRequest(string path, Stream request, @@ -71,9 +75,10 @@ namespace OpenSim.Server.Handlers.Asset if (p.Length == 0) return result; + string id = string.Empty; if (p.Length > 1) { - string id = p[0]; + id = p[0]; string cmd = p[1]; if (cmd == "data") @@ -124,7 +129,7 @@ namespace OpenSim.Server.Handlers.Asset { // Get the entire asset (metadata + data) - string id = p[0]; + id = p[0]; AssetBase asset = m_AssetService.Get(id); if (asset != null) @@ -151,6 +156,16 @@ namespace OpenSim.Server.Handlers.Asset result = new byte[0]; } + if (httpResponse.StatusCode == (int)HttpStatusCode.NotFound && !string.IsNullOrEmpty(m_RedirectURL) && !string.IsNullOrEmpty(id)) + { + httpResponse.StatusCode = (int)HttpStatusCode.Redirect; + string rurl = m_RedirectURL; + if (!path.StartsWith("/")) + rurl += "/"; + rurl += path; + httpResponse.AddHeader("Location", rurl); + m_log.DebugFormat("[ASSET GET HANDLER]: Asset not found, redirecting to {0} ({1})", rurl, httpResponse.StatusCode); + } return result; } } -- cgit v1.1 From d2877b9cd4749dd02c0040480db4f0a32b5fb17d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 26 May 2014 10:28:31 -0700 Subject: Don't report NPC presences. --- .../CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 516ad40..50c252c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -69,7 +69,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnMakeRootAgent(ScenePresence sp) { // m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); - m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID); + if (sp.PresenceType != PresenceType.Npc) + m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID); } public void OnNewClient(IClientAPI client) -- cgit v1.1 From fab0389cb17cd74e47156c58b52dd62b098c8494 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 26 May 2014 20:29:45 -0700 Subject: BulletSim: add locking of PhysObjects while processing simulation step updates and collisions. This is an attempt to fix a crash reported by Justin when doing high velocity teleports. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 34 +++++++++++++++---------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 9fa55ce..23bada9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -639,15 +639,18 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters { if (collidersCount > 0) { - for (int ii = 0; ii < collidersCount; ii++) + lock (PhysObjects) { - uint cA = m_collisionArray[ii].aID; - uint cB = m_collisionArray[ii].bID; - Vector3 point = m_collisionArray[ii].point; - Vector3 normal = m_collisionArray[ii].normal; - float penetration = m_collisionArray[ii].penetration; - SendCollision(cA, cB, point, normal, penetration); - SendCollision(cB, cA, point, -normal, penetration); + for (int ii = 0; ii < collidersCount; ii++) + { + uint cA = m_collisionArray[ii].aID; + uint cB = m_collisionArray[ii].bID; + Vector3 point = m_collisionArray[ii].point; + Vector3 normal = m_collisionArray[ii].normal; + float penetration = m_collisionArray[ii].penetration; + SendCollision(cA, cB, point, normal, penetration); + SendCollision(cB, cA, point, -normal, penetration); + } } } } @@ -658,14 +661,17 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters { if (updatedEntityCount > 0) { - for (int ii = 0; ii < updatedEntityCount; ii++) + lock (PhysObjects) { - EntityProperties entprop = m_updateArray[ii]; - BSPhysObject pobj; - if (PhysObjects.TryGetValue(entprop.ID, out pobj)) + for (int ii = 0; ii < updatedEntityCount; ii++) { - if (pobj.IsInitialized) - pobj.UpdateProperties(entprop); + EntityProperties entprop = m_updateArray[ii]; + BSPhysObject pobj; + if (PhysObjects.TryGetValue(entprop.ID, out pobj)) + { + if (pobj.IsInitialized) + pobj.UpdateProperties(entprop); + } } } } -- cgit v1.1 From e19c830a6cc3e9bf20bcd5208563628923689184 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 27 May 2014 10:13:24 -0700 Subject: Fixes a bug where map search results pertaining to varregions would only send the SW-most corner of the varregions; the other areas, when clicked, would result a blue circle, meaning that the viewer didn't know about those areas. This is still not quite right, as all the areas appear to be in the same coordinates, but it's good enough for now. --- .../CoreModules/World/WorldMap/MapSearchModule.cs | 44 +++++++++++++--------- .../CoreModules/World/WorldMap/WorldMapModule.cs | 4 +- .../Region/Framework/Interfaces/IWorldMapModule.cs | 5 +++ 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 1437b1b..de7ea6d 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -49,6 +49,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List m_scenes = new List(); List m_Clients; + IWorldMapModule m_WorldMap; + IWorldMapModule WorldMap + { + get + { + if (m_WorldMap == null) + m_WorldMap = m_scene.RequestModuleInterface(); + return m_WorldMap; + } + + } + #region ISharedRegionModule Members public void Initialise(IConfigSource source) { @@ -64,6 +76,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scenes.Add(scene); scene.EventManager.OnNewClient += OnNewClient; m_Clients = new List(); + } public void RemoveRegion(Scene scene) @@ -129,7 +142,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) { List blocks = new List(); - MapBlockData data; if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) { // final block, closing the search result @@ -173,24 +185,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { foreach (GridRegion info in regionInfos) { - data = new MapBlockData(); - data.Agents = 0; - data.Access = info.Access; - if (flags == 2) // V2 sends this - data.MapImageId = UUID.Zero; - else - data.MapImageId = info.TerrainImage; - // ugh! V2-3 is very sensitive about the result being - // exactly the same as the requested name - if (regionInfos.Count == 1 && (mapName != mapNameOrig)) - data.Name = mapNameOrig; + if ((flags & 2) == 2) // V2 sends this + { + List datas = WorldMap.Map2BlockFromGridRegion(info, flags); + // ugh! V2-3 is very sensitive about the result being + // exactly the same as the requested name + if (regionInfos.Count == 1 && (mapName != mapNameOrig)) + datas.ForEach(d => d.Name = mapNameOrig); + + blocks.AddRange(datas); + } else - data.Name = info.RegionName; - data.RegionFlags = 0; // TODO not used? - data.WaterHeight = 0; // not used - data.X = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocX); - data.Y = (ushort)Util.WorldToRegionLoc((uint)info.RegionLocY); - blocks.Add(data); + { + MapBlockData data = WorldMap.MapBlockFromGridRegion(info, flags); + } } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index a3b0f39..b98afbc 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1064,7 +1064,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } // Fill a passed MapBlockData from a GridRegion - protected MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag) + public MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag) { MapBlockData block = new MapBlockData(); @@ -1090,7 +1090,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return block; } - protected List Map2BlockFromGridRegion(GridRegion r, uint flag) + public List Map2BlockFromGridRegion(GridRegion r, uint flag) { List blocks = new List(); MapBlockData block = new MapBlockData(); diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs index 65c57a6..9c781e1 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs @@ -24,6 +24,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.Framework.Interfaces { @@ -33,5 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Generate a map tile for the scene. a terrain texture for this scene /// void GenerateMaptile(); + List Map2BlockFromGridRegion(GridRegion r, uint flag); + MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag); } } -- cgit v1.1 From d131c5797818f33a02acc2c98b096d51935fc963 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 May 2014 18:11:01 +0100 Subject: Update regression TestInventoryDescendentsFetch() to account for recent commit 1fa3a6f This was hidden in continuous integration because of another regression test issue. --- .../Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs index edc5016..ee1ea1a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs @@ -152,7 +152,7 @@ namespace OpenSim.Region.ClientStack.Linden.Caps.Tests // A sanity check that the response has the expected number of descendents for a default inventory // TODO: Need a more thorough check. - Assert.That((int)folderOsd["descendents"], Is.EqualTo(14)); + Assert.That((int)folderOsd["descendents"], Is.EqualTo(16)); } } } \ No newline at end of file -- cgit v1.1 From bcaacb4e41f10f4ebadc25d4aef98d60fe970770 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 May 2014 18:19:08 +0100 Subject: Temporarily print regression TestCastAndConcatString() script compile errors out to console to get a handle on what's going wrong. Does not fail for me locally and I failed to notice this test was failing on Jenkins. --- .../Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index badf82a..3647467 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -166,10 +166,11 @@ default m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); -// foreach (CompilerError compErr in m_compilerResults.Errors) -// { -// System.Console.WriteLine("Error: {0}", compErr); -// } + System.Console.WriteLine("ERRORS: {0}", m_compilerResults.Errors.Count); + foreach (CompilerError compErr in m_compilerResults.Errors) + { + System.Console.WriteLine("Error: {0}", compErr); + } Assert.AreEqual(0, m_compilerResults.Errors.Count); } -- cgit v1.1 From 394ec508f6b0b8c2731448d49cafedaaded273b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 May 2014 18:37:16 +0100 Subject: Make CompilerTest add same AssemblyResolver as XEngine to see if this solves the issue with different AppDomain BaseDirectory in local and Jenkins test runs --- .../Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 3647467..75b7244 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.IO; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -67,7 +68,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests m_CSCodeProvider = new CSharpCodeProvider(); m_compilerParameters = new CompilerParameters(); - string rootPath = Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory)); + string rootPath = System.AppDomain.CurrentDomain.BaseDirectory; + + System.AppDomain.CurrentDomain.AssemblyResolve += + new ResolveEventHandler( + AssemblyResolver.OnAssemblyResolve); + m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll")); -- cgit v1.1 From 5622cf68aad44d710648e63e879e597fd12402f6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 May 2014 18:47:25 +0100 Subject: In compiler tests, remove the ResolveEventHandlers after test exit --- .../Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 75b7244..713b280 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -49,6 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests private CSharpCodeProvider m_CSCodeProvider; private CompilerParameters m_compilerParameters; private CompilerResults m_compilerResults; + private ResolveEventHandler m_resolveEventHandler; /// /// Creates a temporary directory where build artifacts are stored. @@ -70,10 +71,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests string rootPath = System.AppDomain.CurrentDomain.BaseDirectory; - System.AppDomain.CurrentDomain.AssemblyResolve += - new ResolveEventHandler( - AssemblyResolver.OnAssemblyResolve); + m_resolveEventHandler = new ResolveEventHandler(AssemblyResolver.OnAssemblyResolve); + System.AppDomain.CurrentDomain.AssemblyResolve += m_resolveEventHandler; + m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll")); @@ -87,6 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests [TestFixtureTearDown] public void CleanUp() { + System.AppDomain.CurrentDomain.AssemblyResolve -= m_resolveEventHandler; + if (Directory.Exists(m_testDir)) { // Blow away the temporary directory with artifacts. -- cgit v1.1 From 464d31b70bc870bd0945cb26c51dc1df48c2ec2a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 May 2014 20:42:36 +0100 Subject: Stop appending redundant newline to console messages in Robust and pCampbot configs This is to fix an issue since recent commit fbcb763 where these are no longer removed automatically. OpenSim.*.config was already not appending these newlines --- bin/Robust.32BitLaunch.exe.config | 2 +- bin/Robust.exe.config | 2 +- bin/pCampBot.exe.config | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/Robust.32BitLaunch.exe.config b/bin/Robust.32BitLaunch.exe.config index 95061e1..0399a1b 100644 --- a/bin/Robust.32BitLaunch.exe.config +++ b/bin/Robust.32BitLaunch.exe.config @@ -17,7 +17,7 @@ - + diff --git a/bin/Robust.exe.config b/bin/Robust.exe.config index b9e01f1..3a978b2 100644 --- a/bin/Robust.exe.config +++ b/bin/Robust.exe.config @@ -17,7 +17,7 @@ - + diff --git a/bin/pCampBot.exe.config b/bin/pCampBot.exe.config index 7912991..89350b0 100755 --- a/bin/pCampBot.exe.config +++ b/bin/pCampBot.exe.config @@ -11,7 +11,7 @@ - + -- cgit v1.1 From 9ca86664bb6cd09e2f619ab882aaca30c08dc379 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 May 2014 23:15:50 +0100 Subject: Make RegionReady login disabled during initialization message a console messages instead of a warning message. Same justification as earlier commit 996a6c2. These are not warnings but should still be visible to the user at any log level. --- .../Scripting/RegionReadyModule/RegionReadyModule.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index d059b97..870c0bb 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -105,8 +105,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.LoginLock = true; m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; - // Warn level because the region cannot be used while logins are disabled - m_log.WarnFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); + // This should always show up to the user but should not trigger warn/errors as these messages are + // expected and are not simulator problems. Ideally, there would be a status level in log4net but + // failing that, we will print out to console instead. + MainConsole.Instance.OutputFormat("Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); if (m_uri != string.Empty) { -- cgit v1.1 From c32ccfb520cb979988c6bbdc195b0977cced3d06 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 May 2014 23:18:33 +0100 Subject: minor: Comment out 2 error level debugging message in authentication code --- .../Server/Handlers/Authentication/AuthenticationServerPostHandler.cs | 2 +- .../Connectors/Authentication/AuthenticationServicesConnector.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index e258dde..5d65f67 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs @@ -74,7 +74,7 @@ namespace OpenSim.Server.Handlers.Authentication protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - m_log.Error("[XXX]: Authenticating..."); +// m_log.Error("[XXX]: Authenticating..."); string[] p = SplitParams(path); if (p.Length > 0) diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs index 56b6434..c8a4912 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs @@ -108,7 +108,7 @@ namespace OpenSim.Services.Connectors public bool Verify(UUID principalID, string token, int lifetime) { - m_log.Error("[XXX]: Verify"); +// m_log.Error("[XXX]: Verify"); Dictionary sendData = new Dictionary(); sendData["LIFETIME"] = lifetime.ToString(); sendData["PRINCIPAL"] = principalID.ToString(); -- cgit v1.1