bunchofcaps config options are the same per region and nini reading is not light

This commit is contained in:
UbitUmarov
2024-04-16 23:10:30 +01:00
parent b9eb6bdd76
commit a5d6f2df02
3 changed files with 114 additions and 112 deletions

View File

@@ -88,6 +88,7 @@ namespace OpenSim.Region.ClientStack.Linden
private UUID m_scopeID; private UUID m_scopeID;
private Caps m_HostCapsObj; private Caps m_HostCapsObj;
private ModelCost m_ModelCost; private ModelCost m_ModelCost;
private BunchOfCapsConfigOptions ConfigOptions;
// private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
@@ -98,30 +99,11 @@ namespace OpenSim.Region.ClientStack.Linden
public ItemUpdatedCallback ItemUpdatedCall = null; public ItemUpdatedCallback ItemUpdatedCall = null;
public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null;
public GetClientDelegate GetClient = null; public GetClientDelegate GetClient = null;
private bool m_persistBakedTextures = false;
private IAssetService m_assetService; private IAssetService m_assetService;
private bool m_dumpAssetsToFile = false; private bool m_dumpAssetsToFile = false;
private string m_regionName; private string m_regionName;
private int m_levelUpload = 0;
private bool m_enableFreeTestUpload = false; // allows "TEST-" prefix hack
private bool m_ForceFreeTestUpload = false; // forces all uploads to be test
private bool m_enableModelUploadTextureToInventory = true; // place uploaded textures also in inventory
// may not be visible till relog
private bool m_RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!!
private UUID m_testAssetsCreatorID = UUID.Zero;
private float m_PrimScaleMin = 0.001f;
private bool m_AllowCapHomeLocation = true;
private bool m_AllowCapGroupMemberData = true;
private bool m_AllowCapLandResources = true;
private bool m_AllowCapAttachmentResources = true;
private IUserManagement m_UserManager; private IUserManagement m_UserManager;
private IUserAccountService m_userAccountService; private IUserAccountService m_userAccountService;
private IMoneyModule m_moneyModule; private IMoneyModule m_moneyModule;
@@ -135,74 +117,15 @@ namespace OpenSim.Region.ClientStack.Linden
} }
private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle;
public BunchOfCaps(Scene scene, UUID agentID, Caps caps) public BunchOfCaps(Scene scene, UUID agentID, Caps caps, BunchOfCapsConfigOptions configOptions)
{ {
m_Scene = scene; m_Scene = scene;
m_AgentID = agentID; m_AgentID = agentID;
m_HostCapsObj = caps; m_HostCapsObj = caps;
ConfigOptions = configOptions;
// create a model upload cost provider //cache model upload cost provider
m_ModelCost = new ModelCost(scene); m_ModelCost = configOptions.ModelCost;
m_PrimScaleMin = m_ModelCost.PrimScaleMin;
IConfigSource config = m_Scene.Config;
if (config is not null)
{
IConfig sconfig = config.Configs["Startup"];
if (sconfig is not null)
{
m_levelUpload = sconfig.GetInt("LevelUpload", 0);
}
if (m_levelUpload == 0)
{
IConfig pconfig = config.Configs["Permissions"];
if (pconfig is not null)
{
m_levelUpload = pconfig.GetInt("LevelUpload", 0);
}
}
IConfig appearanceConfig = config.Configs["Appearance"];
if (appearanceConfig is not null)
{
m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
}
// economy for model upload
IConfig EconomyConfig = config.Configs["Economy"];
if (EconomyConfig is not null)
{
m_ModelCost.Econfig(EconomyConfig);
m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", m_enableModelUploadTextureToInventory);
m_RestrictFreeTestUploadPerms = EconomyConfig.GetBoolean("m_RestrictFreeTestUploadPerms", m_RestrictFreeTestUploadPerms);
m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", m_enableFreeTestUpload);
m_ForceFreeTestUpload = EconomyConfig.GetBoolean("ForceFreeTestUpload", m_ForceFreeTestUpload);
string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", "");
if (!string.IsNullOrEmpty(testcreator))
{
if (UUID.TryParse(testcreator, out UUID id))
m_testAssetsCreatorID = id;
}
}
IConfig CapsConfig = config.Configs["ClientStack.LindenCaps"];
if (CapsConfig is not null)
{
string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost");
m_AllowCapHomeLocation = !string.IsNullOrEmpty(homeLocationUrl);
string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost");
m_AllowCapGroupMemberData = !string.IsNullOrEmpty(GroupMemberDataUrl);
string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost");
m_AllowCapLandResources = !string.IsNullOrEmpty(LandResourcesUrl);
string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost");
m_AllowCapAttachmentResources = !string.IsNullOrEmpty(AttachmentResourcesUrl);
}
}
m_assetService = m_Scene.AssetService; m_assetService = m_Scene.AssetService;
m_regionName = m_Scene.RegionInfo.RegionName; m_regionName = m_Scene.RegionInfo.RegionName;
@@ -212,7 +135,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (m_UserManager is null) if (m_UserManager is null)
m_log.Error("[CAPS]: GetDisplayNames disabled because user management component not found"); m_log.Error("[CAPS]: GetDisplayNames disabled because user management component not found");
UserAccount account = m_userAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, m_AgentID); UserAccount account = m_userAccountService?.GetUserAccount(m_Scene.RegionInfo.ScopeID, m_AgentID);
if (account is null) // Hypergrid? if (account is null) // Hypergrid?
m_scopeID = m_Scene.RegionInfo.ScopeID; m_scopeID = m_Scene.RegionInfo.ScopeID;
else else
@@ -263,25 +186,25 @@ namespace OpenSim.Region.ClientStack.Linden
m_HostCapsObj.RegisterSimpleHandler("ResourceCostSelected", m_HostCapsObj.RegisterSimpleHandler("ResourceCostSelected",
new SimpleOSDMapHandler("POST", GetNewCapPath(), ResourceCostSelected)); new SimpleOSDMapHandler("POST", GetNewCapPath(), ResourceCostSelected));
if(m_AllowCapHomeLocation) if(ConfigOptions.AllowCapHomeLocation)
{ {
m_HostCapsObj.RegisterSimpleHandler("HomeLocation", m_HostCapsObj.RegisterSimpleHandler("HomeLocation",
new SimpleStreamHandler(GetNewCapPath(), HomeLocation)); new SimpleStreamHandler(GetNewCapPath(), HomeLocation));
} }
if (m_AllowCapGroupMemberData) if (ConfigOptions.AllowCapGroupMemberData)
{ {
m_HostCapsObj.RegisterSimpleHandler("GroupMemberData", m_HostCapsObj.RegisterSimpleHandler("GroupMemberData",
new SimpleStreamHandler(GetNewCapPath(), GroupMemberData)); new SimpleStreamHandler(GetNewCapPath(), GroupMemberData));
} }
if (m_AllowCapLandResources) if (ConfigOptions.AllowCapLandResources)
{ {
m_HostCapsObj.RegisterSimpleHandler("LandResources", m_HostCapsObj.RegisterSimpleHandler("LandResources",
new SimpleOSDMapHandler("POST", GetNewCapPath(), LandResources)); new SimpleOSDMapHandler("POST", GetNewCapPath(), LandResources));
} }
if (m_AllowCapAttachmentResources) if (ConfigOptions.AllowCapAttachmentResources)
{ {
m_HostCapsObj.RegisterSimpleHandler("AttachmentResources", m_HostCapsObj.RegisterSimpleHandler("AttachmentResources",
new SimpleStreamHandler(GetNewCapPath(), AttachmentResources)); new SimpleStreamHandler(GetNewCapPath(), AttachmentResources));
@@ -505,7 +428,7 @@ namespace OpenSim.Region.ClientStack.Linden
// check user level // check user level
if (avatar is not null) if (avatar is not null)
{ {
if (avatar.GodController.UserLevel < m_levelUpload) if (avatar.GodController.UserLevel < ConfigOptions.levelUpload)
{ {
LLSDAssetUploadError resperror = new LLSDAssetUploadError(); LLSDAssetUploadError resperror = new LLSDAssetUploadError();
resperror.message = "Insufficient permissions to upload"; resperror.message = "Insufficient permissions to upload";
@@ -564,7 +487,7 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
// check for test upload // check for test upload
if (m_ForceFreeTestUpload) // all are test if (ConfigOptions.ForceFreeTestUpload) // all are test
{ {
if (!(assetName.Length > 5 && assetName.StartsWith("TEST-"))) // has normal name lets change it if (!(assetName.Length > 5 && assetName.StartsWith("TEST-"))) // has normal name lets change it
assetName = "TEST-" + assetName; assetName = "TEST-" + assetName;
@@ -572,7 +495,7 @@ namespace OpenSim.Region.ClientStack.Linden
IsAtestUpload = true; IsAtestUpload = true;
} }
else if (m_enableFreeTestUpload) // only if prefixed with "TEST-" else if (ConfigOptions.enableFreeTestUpload) // only if prefixed with "TEST-"
{ {
IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-")); IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-"));
@@ -600,7 +523,7 @@ namespace OpenSim.Region.ClientStack.Linden
} }
} }
} }
else if (m_enableFreeTestUpload) // only if prefixed with "TEST-" else if (ConfigOptions.enableFreeTestUpload) // only if prefixed with "TEST-"
{ {
IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-")); IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-"));
if(IsAtestUpload) if(IsAtestUpload)
@@ -619,7 +542,7 @@ namespace OpenSim.Region.ClientStack.Linden
string uploaderPath = GetNewCapPath(); string uploaderPath = GetNewCapPath();
UUID texturesFolder = UUID.Zero; UUID texturesFolder = UUID.Zero;
if(!IsAtestUpload && m_enableModelUploadTextureToInventory) if(!IsAtestUpload && ConfigOptions.enableModelUploadTextureToInventory)
texturesFolder = llsdRequest.texture_folder_id; texturesFolder = llsdRequest.texture_folder_id;
AssetUploader uploader = AssetUploader uploader =
@@ -688,12 +611,12 @@ namespace OpenSim.Region.ClientStack.Linden
UUID owner_id = m_HostCapsObj.AgentID; UUID owner_id = m_HostCapsObj.AgentID;
UUID creatorID; UUID creatorID;
bool istest = IsAtestUpload && m_enableFreeTestUpload; bool istest = IsAtestUpload && ConfigOptions.enableFreeTestUpload;
bool restrictPerms = m_RestrictFreeTestUploadPerms && istest; bool restrictPerms = ConfigOptions.RestrictFreeTestUploadPerms && istest;
if (istest && m_testAssetsCreatorID != UUID.Zero) if (istest && ConfigOptions.testAssetsCreatorID.IsNotZero())
creatorID = m_testAssetsCreatorID; creatorID = ConfigOptions.testAssetsCreatorID;
else else
creatorID = owner_id; creatorID = owner_id;
@@ -779,7 +702,7 @@ namespace OpenSim.Region.ClientStack.Linden
SceneObjectGroup grp = null; SceneObjectGroup grp = null;
// create and store texture assets // create and store texture assets
bool doTextInv = (!istest && m_enableModelUploadTextureToInventory && bool doTextInv = (!istest && ConfigOptions.enableModelUploadTextureToInventory &&
texturesFolder != UUID.Zero); texturesFolder != UUID.Zero);
@@ -904,6 +827,7 @@ namespace OpenSim.Region.ClientStack.Linden
} }
int skipedMeshs = 0; int skipedMeshs = 0;
float primScaleMin = m_ModelCost.PrimScaleMin;
// build prims from instances // build prims from instances
for (int i = 0; i < instance_list.Count; i++) for (int i = 0; i < instance_list.Count; i++)
{ {
@@ -912,7 +836,7 @@ namespace OpenSim.Region.ClientStack.Linden
// skip prims that are 2 small // skip prims that are 2 small
Vector3 scale = inner_instance_list["scale"].AsVector3(); Vector3 scale = inner_instance_list["scale"].AsVector3();
if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) if (scale.X < primScaleMin || scale.Y < primScaleMin || scale.Z < primScaleMin)
{ {
skipedMeshs++; skipedMeshs++;
continue; continue;
@@ -1553,12 +1477,8 @@ namespace OpenSim.Region.ClientStack.Linden
if (grp != null) if (grp != null)
{ {
haveone = true; haveone = true;
float linksetCost;
float linksetPhysCost;
float partCost;
float partPhysCost;
grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost); grp.GetResourcesCosts(part, out float linksetCost, out float linksetPhysCost, out float partCost, out float partPhysCost);
LLSDxmlEncode2.AddMap(uuid.ToString(), lsl); LLSDxmlEncode2.AddMap(uuid.ToString(), lsl);

View File

@@ -26,8 +26,6 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.Reflection;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
@@ -44,14 +42,35 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
namespace OpenSim.Region.ClientStack.Linden namespace OpenSim.Region.ClientStack.Linden
{ {
public class BunchOfCapsConfigOptions
{
public ModelCost ModelCost;
public bool persistBakedTextures = false;
public bool enableModelUploadTextureToInventory = true; // place uploaded textures also in inventory
// may not be visible till relog
public bool enableFreeTestUpload = false; // allows "TEST-" prefix hack
public bool ForceFreeTestUpload = false; // forces all uploads to be test
public bool RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!!
public int levelUpload = 0;
public bool AllowCapHomeLocation = true;
public bool AllowCapGroupMemberData = true;
public bool AllowCapLandResources = true;
public bool AllowCapAttachmentResources = true;
public UUID testAssetsCreatorID = UUID.Zero;
}
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BunchOfCapsModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BunchOfCapsModule")]
public class BunchOfCapsModule : INonSharedRegionModule public class BunchOfCapsModule : INonSharedRegionModule
{ {
// private static readonly ILog m_log = //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_Scene; private Scene m_Scene;
private BunchOfCapsConfigOptions ConfigOptions = new();
#region INonSharedRegionModule #region INonSharedRegionModule
@@ -68,7 +87,6 @@ namespace OpenSim.Region.ClientStack.Linden
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
m_Scene = scene; m_Scene = scene;
m_Scene.EventManager.OnRegisterCaps += OnRegisterCaps;
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@@ -77,6 +95,70 @@ namespace OpenSim.Region.ClientStack.Linden
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
ConfigOptions.ModelCost = new ModelCost(m_Scene);
IConfigSource config = m_Scene.Config;
if (config is not null)
{
IConfig sconfig = config.Configs["Startup"];
if (sconfig is not null)
ConfigOptions.levelUpload = sconfig.GetInt("LevelUpload", 0);
if (ConfigOptions.levelUpload == 0)
{
IConfig pconfig = config.Configs["Permissions"];
if (pconfig is not null)
ConfigOptions.levelUpload = pconfig.GetInt("LevelUpload", 0);
}
IConfig appearanceConfig = config.Configs["Appearance"];
if (appearanceConfig is not null)
{
ConfigOptions.persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", ConfigOptions.persistBakedTextures);
}
// economy for model upload
IConfig EconomyConfig = config.Configs["Economy"];
if (EconomyConfig is not null)
{
ConfigOptions.ModelCost.Econfig(EconomyConfig);
ConfigOptions.enableModelUploadTextureToInventory =
EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", ConfigOptions.enableModelUploadTextureToInventory);
ConfigOptions.RestrictFreeTestUploadPerms =
EconomyConfig.GetBoolean("m_RestrictFreeTestUploadPerms", ConfigOptions.RestrictFreeTestUploadPerms);
ConfigOptions.enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", ConfigOptions.enableFreeTestUpload);
ConfigOptions.ForceFreeTestUpload =
EconomyConfig.GetBoolean("ForceFreeTestUpload", ConfigOptions.ForceFreeTestUpload);
string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", "");
if (!string.IsNullOrEmpty(testcreator))
{
if (UUID.TryParse(testcreator, out UUID id))
ConfigOptions.testAssetsCreatorID = id;
}
}
IConfig CapsConfig = config.Configs["ClientStack.LindenCaps"];
if (CapsConfig is not null)
{
string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost");
ConfigOptions.AllowCapHomeLocation = !string.IsNullOrEmpty(homeLocationUrl);
string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost");
ConfigOptions.AllowCapGroupMemberData = !string.IsNullOrEmpty(GroupMemberDataUrl);
string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost");
ConfigOptions.AllowCapLandResources = !string.IsNullOrEmpty(LandResourcesUrl);
string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost");
ConfigOptions.AllowCapAttachmentResources = !string.IsNullOrEmpty(AttachmentResourcesUrl);
}
m_Scene.EventManager.OnRegisterCaps += OnRegisterCaps;
}
} }
public void PostInitialise() { } public void PostInitialise() { }
@@ -84,7 +166,7 @@ namespace OpenSim.Region.ClientStack.Linden
private void OnRegisterCaps(UUID agentID, Caps caps) private void OnRegisterCaps(UUID agentID, Caps caps)
{ {
new BunchOfCaps(m_Scene, agentID, caps); _ = new BunchOfCaps(m_Scene, agentID, caps, ConfigOptions);
} }
} }

View File

@@ -901,7 +901,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//TerrainBase1 //TerrainBase1
//TerrainBase2 //TerrainBase2
//TerrainBase3 //TerrainBase3
// this seem not obsolete, sending zero uuids // this seem now obsolete, sending zero uuids
// we should send the basic low resolution default ? // we should send the basic low resolution default ?
zc.AddZeros(16 * 4); zc.AddZeros(16 * 4);
//TerrainDetail0 //TerrainDetail0
@@ -5520,7 +5520,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
inner = $"{{'id':i{sop.LocalId},'od':[],'te':[]}}"; inner = $"{{'id':i{sop.LocalId},'od':[],'te':[]}}";
byte[] innerB = Util.UTF8NBGetbytes(inner); byte[] innerB = Util.UTF8NBGetbytes(inner);
if (innerB.Length > 4096 - 16) if (innerB.Length > UDPPacketBuffer.BUFFER_SIZE - 16)
{ {
m_log.Debug($"[LLCLIENTVIEW]: GenericStreamingMessage packet too large ({innerB.Length})"); m_log.Debug($"[LLCLIENTVIEW]: GenericStreamingMessage packet too large ({innerB.Length})");
continue; continue;