diff options
author | Diva Canto | 2014-05-04 20:54:42 -0700 |
---|---|---|
committer | Diva Canto | 2014-05-04 20:54:42 -0700 |
commit | 13b2ac14253a5f9ec75ec9712d1fd2fe17d1d005 (patch) | |
tree | 6f8da9dedee17d5e09de81b81c16d04149e854e2 /OpenSim/Region | |
parent | Please note: older simulators (0.7.6) still send the info about gzip in Conte... (diff) | |
download | opensim-SC-13b2ac14253a5f9ec75ec9712d1fd2fe17d1d005.zip opensim-SC-13b2ac14253a5f9ec75ec9712d1fd2fe17d1d005.tar.gz opensim-SC-13b2ac14253a5f9ec75ec9712d1fd2fe17d1d005.tar.bz2 opensim-SC-13b2ac14253a5f9ec75ec9712d1fd2fe17d1d005.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 100 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 15 |
2 files changed, 93 insertions, 22 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 | |||
64 | 64 | ||
65 | private bool m_bypassPermissions = true; | 65 | private bool m_bypassPermissions = true; |
66 | 66 | ||
67 | // This simple check makes it possible to support grids in which all the simulators | ||
68 | // share all central services of the Robust server EXCEPT assets. In other words, | ||
69 | // grids where the simulators' assets are kept in one DB and the users' inventory assets | ||
70 | // are kept on another. When users rez items from inventory or take objects from world, | ||
71 | // an HG-like asset copy takes place between the 2 servers, the world asset server and | ||
72 | // the user's asset server. | ||
73 | private bool m_CheckSeparateAssets = false; | ||
74 | private string m_LocalAssetsURL = string.Empty; | ||
75 | |||
67 | // private bool m_Initialized = false; | 76 | // private bool m_Initialized = false; |
68 | 77 | ||
69 | #region INonSharedRegionModule | 78 | #region INonSharedRegionModule |
@@ -99,6 +108,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
99 | 108 | ||
100 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); | 109 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); |
101 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); | 110 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); |
111 | m_CheckSeparateAssets = thisModuleConfig.GetBoolean("CheckSeparateAssets", false); | ||
112 | m_LocalAssetsURL = thisModuleConfig.GetString("RegionHGAssetServerURI", string.Empty); | ||
113 | m_LocalAssetsURL = m_LocalAssetsURL.Trim(new char[] { '/' }); | ||
114 | |||
102 | } | 115 | } |
103 | else | 116 | else |
104 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | 117 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); |
@@ -293,41 +306,92 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
293 | 306 | ||
294 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | 307 | public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) |
295 | { | 308 | { |
296 | string userAssetServer = string.Empty; | 309 | string senderAssetServer = string.Empty; |
297 | if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) | 310 | string receiverAssetServer = string.Empty; |
298 | m_assMapper.Get(item.AssetID, sender, userAssetServer); | 311 | bool isForeignSender, isForeignReceiver; |
312 | isForeignSender = IsForeignUser(sender, out senderAssetServer); | ||
313 | isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer); | ||
314 | |||
315 | // They're both local. Nothing to do. | ||
316 | if (!isForeignSender && !isForeignReceiver) | ||
317 | return; | ||
318 | |||
319 | // At least one of them is foreign. | ||
320 | // If both users have the same asset server, no need to transfer the asset | ||
321 | if (senderAssetServer.Equals(receiverAssetServer)) | ||
322 | { | ||
323 | m_log.DebugFormat("[HGScene]: Asset transfer between foreign users, but they have the same server. No transfer."); | ||
324 | return; | ||
325 | } | ||
299 | 326 | ||
300 | if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) | 327 | if (isForeignSender && senderAssetServer != string.Empty) |
301 | m_assMapper.Post(item.AssetID, receiver, userAssetServer); | 328 | m_assMapper.Get(item.AssetID, sender, senderAssetServer); |
329 | |||
330 | if (isForeignReceiver && receiverAssetServer != string.Empty && m_OutboundPermission) | ||
331 | m_assMapper.Post(item.AssetID, receiver, receiverAssetServer); | ||
302 | } | 332 | } |
303 | 333 | ||
304 | public override bool IsForeignUser(UUID userID, out string assetServerURL) | 334 | public override bool IsForeignUser(UUID userID, out string assetServerURL) |
305 | { | 335 | { |
306 | assetServerURL = string.Empty; | 336 | assetServerURL = string.Empty; |
307 | 337 | ||
308 | if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) | 338 | if (UserManagementModule != null) |
309 | { // foreign | 339 | { |
310 | ScenePresence sp = null; | 340 | if (!m_CheckSeparateAssets) |
311 | if (m_Scene.TryGetScenePresence(userID, out sp)) | ||
312 | { | 341 | { |
313 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 342 | if (!UserManagementModule.IsLocalGridUser(userID)) |
314 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | 343 | { // foreign |
315 | { | 344 | ScenePresence sp = null; |
316 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 345 | if (m_Scene.TryGetScenePresence(userID, out sp)) |
317 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 346 | { |
347 | AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
348 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | ||
349 | { | ||
350 | assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | ||
351 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
352 | } | ||
353 | } | ||
354 | else | ||
355 | { | ||
356 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | ||
357 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | ||
358 | } | ||
359 | return true; | ||
318 | } | 360 | } |
319 | } | 361 | } |
320 | else | 362 | else |
321 | { | 363 | { |
322 | assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); | 364 | if (IsLocalInventoryAssetsUser(userID, out assetServerURL)) |
323 | assetServerURL = assetServerURL.Trim(new char[] { '/' }); | 365 | { |
366 | m_log.DebugFormat("[HGScene]: user {0} has local assets {1}", userID, assetServerURL); | ||
367 | return false; | ||
368 | } | ||
369 | else | ||
370 | { | ||
371 | m_log.DebugFormat("[HGScene]: user {0} has foreign assets {1}", userID, assetServerURL); | ||
372 | return true; | ||
373 | } | ||
324 | } | 374 | } |
325 | return true; | ||
326 | } | 375 | } |
327 | |||
328 | return false; | 376 | return false; |
329 | } | 377 | } |
330 | 378 | ||
379 | private bool IsLocalInventoryAssetsUser(UUID uuid, out string assetsURL) | ||
380 | { | ||
381 | assetsURL = UserManagementModule.GetUserServerURL(uuid, "AssetServerURI"); | ||
382 | if (assetsURL == string.Empty) | ||
383 | { | ||
384 | AgentCircuitData agent = m_Scene.AuthenticateHandler.GetAgentCircuitData(uuid); | ||
385 | if (agent != null) | ||
386 | { | ||
387 | assetsURL = agent.ServiceURLs["AssetServerURI"].ToString(); | ||
388 | assetsURL = assetsURL.Trim(new char[] { '/' }); | ||
389 | } | ||
390 | } | ||
391 | return m_LocalAssetsURL.Equals(assetsURL); | ||
392 | } | ||
393 | |||
394 | |||
331 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) | 395 | protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) |
332 | { | 396 | { |
333 | InventoryItemBase item = base.GetItem(agentID, itemID); | 397 | 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 | |||
125 | 125 | ||
126 | return false; | 126 | return false; |
127 | } | 127 | } |
128 | } | ||
129 | |||
130 | public bool AddInventoryItem(InventoryItemBase item) | ||
131 | { | ||
132 | return AddInventoryItem(item, true); | ||
128 | } | 133 | } |
129 | 134 | ||
130 | /// <summary> | 135 | /// <summary> |
131 | /// Add the given inventory item to a user's inventory. | 136 | /// Add the given inventory item to a user's inventory. |
132 | /// </summary> | 137 | /// </summary> |
133 | /// <param name="item"></param> | 138 | /// <param name="item"></param> |
134 | public bool AddInventoryItem(InventoryItemBase item) | 139 | public bool AddInventoryItem(InventoryItemBase item, bool trigger) |
135 | { | 140 | { |
136 | if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) | 141 | if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) |
137 | { | 142 | { |
@@ -140,7 +145,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
140 | { | 145 | { |
141 | userlevel = 1; | 146 | userlevel = 1; |
142 | } | 147 | } |
143 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | 148 | if (trigger) |
149 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | ||
144 | 150 | ||
145 | return true; | 151 | return true; |
146 | } | 152 | } |
@@ -179,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
179 | { | 185 | { |
180 | userlevel = 1; | 186 | userlevel = 1; |
181 | } | 187 | } |
182 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | 188 | if (trigger) |
189 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); | ||
183 | 190 | ||
184 | if (originalFolder != UUID.Zero) | 191 | if (originalFolder != UUID.Zero) |
185 | { | 192 | { |
@@ -751,7 +758,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
751 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); | 758 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
752 | if (invAccess != null) | 759 | if (invAccess != null) |
753 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); | 760 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); |
754 | AddInventoryItem(itemCopy); | 761 | AddInventoryItem(itemCopy, false); |
755 | 762 | ||
756 | if (!Permissions.BypassPermissions()) | 763 | if (!Permissions.BypassPermissions()) |
757 | { | 764 | { |