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.
bullet-2.82
Diva Canto 2014-05-04 20:54:42 -07:00
parent 7f570636f8
commit 13b2ac1425
3 changed files with 103 additions and 24 deletions

View File

@ -64,6 +64,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
private bool m_bypassPermissions = true; 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; // private bool m_Initialized = false;
#region INonSharedRegionModule #region INonSharedRegionModule
@ -99,6 +108,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true);
m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", 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 else
m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); 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) public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
{ {
string userAssetServer = string.Empty; string senderAssetServer = string.Empty;
if (IsForeignUser(sender, out userAssetServer) && userAssetServer != string.Empty) string receiverAssetServer = string.Empty;
m_assMapper.Get(item.AssetID, sender, userAssetServer); bool isForeignSender, isForeignReceiver;
isForeignSender = IsForeignUser(sender, out senderAssetServer);
isForeignReceiver = IsForeignUser(receiver, out receiverAssetServer);
if (IsForeignUser(receiver, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) // They're both local. Nothing to do.
m_assMapper.Post(item.AssetID, receiver, userAssetServer); 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 (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) public override bool IsForeignUser(UUID userID, out string assetServerURL)
{ {
assetServerURL = string.Empty; assetServerURL = string.Empty;
if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(userID)) if (UserManagementModule != null)
{ // foreign {
ScenePresence sp = null; if (!m_CheckSeparateAssets)
if (m_Scene.TryGetScenePresence(userID, out sp))
{ {
AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); if (!UserManagementModule.IsLocalGridUser(userID))
if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { // foreign
{ ScenePresence sp = null;
assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); if (m_Scene.TryGetScenePresence(userID, out sp))
assetServerURL = assetServerURL.Trim(new char[] { '/' }); {
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 else
{ {
assetServerURL = UserManagementModule.GetUserServerURL(userID, "AssetServerURI"); if (IsLocalInventoryAssetsUser(userID, out assetServerURL))
assetServerURL = assetServerURL.Trim(new char[] { '/' }); {
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; 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) protected override InventoryItemBase GetItem(UUID agentID, UUID itemID)
{ {
InventoryItemBase item = base.GetItem(agentID, itemID); InventoryItemBase item = base.GetItem(agentID, itemID);

View File

@ -125,13 +125,18 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
} }
}
public bool AddInventoryItem(InventoryItemBase item)
{
return AddInventoryItem(item, true);
} }
/// <summary> /// <summary>
/// Add the given inventory item to a user's inventory. /// Add the given inventory item to a user's inventory.
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
public bool AddInventoryItem(InventoryItemBase item) public bool AddInventoryItem(InventoryItemBase item, bool trigger)
{ {
if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) if (item.Folder != UUID.Zero && InventoryService.AddItem(item))
{ {
@ -140,7 +145,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
userlevel = 1; 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; return true;
} }
@ -179,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
userlevel = 1; 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) if (originalFolder != UUID.Zero)
{ {
@ -751,7 +758,7 @@ namespace OpenSim.Region.Framework.Scenes
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
if (invAccess != null) if (invAccess != null)
invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
AddInventoryItem(itemCopy); AddInventoryItem(itemCopy, false);
if (!Permissions.BypassPermissions()) if (!Permissions.BypassPermissions())
{ {

View File

@ -160,13 +160,21 @@
HomeURI = "http://mygridserver.com:8002" HomeURI = "http://mygridserver.com:8002"
Gatekeeper = "http://mygridserver.com:8002" Gatekeeper = "http://mygridserver.com:8002"
;; If you want to protect your assets from being copied by foreign visitors ;; 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. ;; set this to false. You may want to do this on sims that have licensed content.
; OutboundPermission = False ;; Default is true.
; OutboundPermission = True
;; Send visual reminder to local users that their inventories are unavailable while they are traveling ;; Send visual reminder to local users that their inventories are unavailable while they are traveling
;; and available when they return. True by default. ;; and available when they return. True by default.
;RestrictInventoryAccessAbroad = True ;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] [HGAssetService]
; ;