Push up current work. Still needs some love but the restructering is done. I want to get this into VS Studio as well since some of the refactoring tools are better than what you get in VS Code

This commit is contained in:
Mike Dickson 2024-03-16 20:38:57 -04:00
parent abe6f390b9
commit 0957f55eac
90 changed files with 1425 additions and 1259 deletions

25
.dockerignore Normal file
View file

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

View file

@ -8,6 +8,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.9.3.0</Version>
<AssemblyVersion>0.9.3.0</AssemblyVersion>
<FileVersion>0.9.3.0</FileVersion>

View file

@ -36,7 +36,7 @@ namespace OpenSim.Data.MySQL
/// </summary>
public class MySQLHGTravelData : MySQLGenericTableHandler<HGTravelingData>, IHGTravelingData
{
public void Initialize(string connectionString, string realm)
public void Initialize(string? connectionString, string? realm)
{
base.Initialize(connectionString, realm, "HGTravelStore");
}

View file

@ -43,13 +43,17 @@ namespace OpenSim.Data.MySQL
private MySqlFolderHandler m_Folders;
private MySqlItemHandler m_Items;
public MySQLXInventoryData(string conn, string realm)
public MySQLXInventoryData()
{
}
public void Initialize(string connString, string realm)
{
m_Folders = new MySqlFolderHandler();
m_Folders.Initialize(conn, "inventoryfolders", "InventoryStore");
m_Folders.Initialize(connString, "inventoryfolders", "InventoryStore");
m_Items = new MySqlItemHandler();
m_Items.Initialize(conn, "inventoryitems", string.Empty);
m_Items.Initialize(connString, "inventoryitems", string.Empty);
}
public XInventoryFolder[] GetFolder(string field, string val)

View file

@ -50,6 +50,8 @@ namespace OpenSim.Data
/// </summary>
public interface IHGTravelingData
{
void Initialize(string? connString, string? realm);
HGTravelingData Get(UUID sessionID);
HGTravelingData[] GetSessions(UUID userID);
bool Store(HGTravelingData data);

View file

@ -78,6 +78,8 @@ namespace OpenSim.Data
public interface IXInventoryData
{
void Initialize(string connString, string realm);
XInventoryFolder[] GetFolder(string field, string val);
XInventoryFolder[] GetFolders(string[] fields, string[] vals);
XInventoryItem[] GetItems(string[] fields, string[] vals);

View file

@ -26,9 +26,7 @@
*/
using System.Net;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework.Servers.HttpServer;
@ -38,17 +36,25 @@ using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
public class AgentPreferencesModule : ISharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private List<Scene> m_scenes = new List<Scene>();
private readonly IConfiguration m_configuration;
private readonly ILogger m_logger;
public void Initialise(IConfiguration source)
public AgentPreferencesModule(IConfiguration config, ILogger<AgentPreferencesModule> logger)
{
m_configuration = config;
m_logger = logger;
}
public void Initialise( )
{
}
#region Region module
@ -63,6 +69,7 @@ namespace OpenSim.Region.ClientStack.Linden
{
lock (m_scenes)
m_scenes.Remove(scene);
scene.EventManager.OnRegisterCaps -= RegisterCaps;
scene = null;
}

View file

@ -27,8 +27,6 @@
using System.Collections.Specialized;
using System.Net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
@ -38,32 +36,30 @@ using OpenSim.Framework.Capabilities;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Net;
namespace OpenSim.Region.ClientStack.Linden
{
public class AvatarPickerSearchModule : ISharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private int m_nscenes;
private IPeople m_People = null;
private bool m_Enabled = false;
private string m_URL;
#region ISharedRegionModule Members
private readonly IConfiguration m_configuration;
private readonly ILogger<AvatarPickerSearchModule> m_logger;
public void Initialise(IConfiguration source)
public AvatarPickerSearchModule(IConfiguration configuration, ILogger<AvatarPickerSearchModule> logger)
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
return;
m_URL = config.GetString("Cap_AvatarPickerSearch", string.Empty);
// Cap doesn't exist
if (m_URL != string.Empty)
m_Enabled = true;
m_configuration = configuration;
m_logger = logger;
}
#region ISharedRegionModule Members
public void AddRegion(Scene s)
{
if (!m_Enabled)
@ -92,6 +88,17 @@ namespace OpenSim.Region.ClientStack.Linden
++m_nscenes;
}
public void Initialise()
{
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
m_URL = config.GetValue("Cap_AvatarPickerSearch", string.Empty);
if (string.IsNullOrEmpty(m_URL) is false)
m_Enabled = true;
}
public void PostInitialise()
{
}
@ -184,5 +191,6 @@ namespace OpenSim.Region.ClientStack.Linden
p.is_display_name_default = false;
return p;
}
}
}

View file

@ -25,22 +25,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Timers;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Threading;
using System.Reflection;
using System.Text;
using System.Web;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using Nini.Config;
using log4net;
using OpenSim.Framework;
using OpenSim.Framework.Capabilities;
@ -56,6 +49,9 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap;
using PermissionMask = OpenSim.Framework.PermissionMask;
using Timer = System.Threading.Timer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
public delegate void UpLoadedAsset(
@ -82,9 +78,6 @@ namespace OpenSim.Region.ClientStack.Linden
public partial class BunchOfCaps
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_Scene;
private UUID m_AgentID;
private UUID m_scopeID;
@ -135,10 +128,22 @@ namespace OpenSim.Region.ClientStack.Linden
waitUpload = 2,
processUpload = 3
}
private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle;
public BunchOfCaps(Scene scene, UUID agentID, Caps caps)
private readonly IConfiguration m_configuration;
private readonly ILogger m_logger;
public BunchOfCaps(
IConfiguration configuration,
ILogger logger,
Scene scene,
UUID agentID,
Caps caps)
{
m_configuration = configuration;
m_logger = logger;
m_Scene = scene;
m_AgentID = agentID;
m_HostCapsObj = caps;
@ -151,37 +156,40 @@ namespace OpenSim.Region.ClientStack.Linden
IConfiguration config = m_Scene.Config;
if (config != null)
{
IConfig sconfig = config.Configs["Startup"];
if (sconfig != null)
var sconfig = config.GetSection("Startup");
if (sconfig.Exists() is true)
{
m_levelUpload = sconfig.GetInt("LevelUpload", 0);
m_levelUpload = sconfig.GetValue<int>("LevelUpload", 0);
}
if (m_levelUpload == 0)
{
IConfig pconfig = config.Configs["Permissions"];
if (pconfig != null)
var pconfig = config.GetSection("Permissions");
if (pconfig.Exists() is true)
{
m_levelUpload = pconfig.GetInt("LevelUpload", 0);
m_levelUpload = pconfig.GetValue<int>("LevelUpload", 0);
}
}
IConfig appearanceConfig = config.Configs["Appearance"];
if (appearanceConfig != null)
var appearanceConfig = config.GetSection("Appearance");
if (appearanceConfig.Exists() is true)
{
m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
m_persistBakedTextures = appearanceConfig.GetValue<bool>("PersistBakedTextures", m_persistBakedTextures);
}
// economy for model upload
IConfig EconomyConfig = config.Configs["Economy"];
if (EconomyConfig != null)
var EconomyConfig = config.GetSection("Economy");
if (EconomyConfig.Exists() is true)
{
m_ModelCost.Econfig(EconomyConfig);
m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", m_enableModelUploadTextureToInventory);
m_enableModelUploadTextureToInventory = EconomyConfig.GetValue<bool>("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", "");
m_RestrictFreeTestUploadPerms = EconomyConfig.GetValue<bool>("m_RestrictFreeTestUploadPerms", m_RestrictFreeTestUploadPerms);
m_enableFreeTestUpload = EconomyConfig.GetValue<bool>("AllowFreeTestUpload", m_enableFreeTestUpload);
m_ForceFreeTestUpload = EconomyConfig.GetValue<bool>("ForceFreeTestUpload", m_ForceFreeTestUpload);
string testcreator = EconomyConfig.GetValue("TestAssetsCreatorID", string.Empty);
if (!string.IsNullOrEmpty(testcreator))
{
if (UUID.TryParse(testcreator, out UUID id))
@ -189,23 +197,23 @@ namespace OpenSim.Region.ClientStack.Linden
}
}
IConfig CapsConfig = config.Configs["ClientStack.LindenCaps"];
if (CapsConfig != null)
var CapsConfig = config.GetSection("ClientStack.LindenCaps");
if (CapsConfig.Exists() is true)
{
string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost");
if(homeLocationUrl.Length == 0)
string homeLocationUrl = CapsConfig.GetValue("Cap_HomeLocation", "localhost");
if(string.IsNullOrEmpty(homeLocationUrl))
m_AllowCapHomeLocation = false;
string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost");
if(GroupMemberDataUrl.Length == 0)
string GroupMemberDataUrl = CapsConfig.GetValue("Cap_GroupMemberData", "localhost");
if(string.IsNullOrEmpty(GroupMemberDataUrl))
m_AllowCapGroupMemberData = false;
string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost");
if (LandResourcesUrl.Length == 0)
string LandResourcesUrl = CapsConfig.GetValue("Cap_LandResources", "localhost");
if (string.IsNullOrEmpty(LandResourcesUrl))
m_AllowCapLandResources = false;
string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost");
if (AttachmentResourcesUrl.Length == 0)
string AttachmentResourcesUrl = CapsConfig.GetValue("Cap_AttachmentResources", "localhost");
if (string.IsNullOrEmpty(AttachmentResourcesUrl))
m_AllowCapAttachmentResources = false;
}
}
@ -215,8 +223,11 @@ namespace OpenSim.Region.ClientStack.Linden
m_UserManager = m_Scene.RequestModuleInterface<IUserManagement>();
m_userAccountService = m_Scene.RequestModuleInterface<IUserAccountService>();
m_moneyModule = m_Scene.RequestModuleInterface<IMoneyModule>();
if (m_UserManager == null)
m_log.Error("[CAPS]: GetDisplayNames disabled because user management component not found");
{
m_logger.LogError("[CAPS]: GetDisplayNames disabled because user management component not found");
}
UserAccount account = m_userAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, m_AgentID);
if (account == null) // Hypergrid?
@ -248,7 +259,7 @@ namespace OpenSim.Region.ClientStack.Linden
string seedcapsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath + "0000";
m_HostCapsObj.RegisterSimpleHandler("SEED", new SimpleStreamHandler(seedcapsBase, SeedCapRequest));
// m_log.DebugFormat(
// m_logger.DebugFormat(
// "[CAPS]: Registered seed capability {0} for {1}", seedcapsBase, m_HostCapsObj.AgentID);
RegisterRegionServiceHandlers();
@ -295,7 +306,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
catch (Exception e)
{
m_log.Error("[CAPS]: " + e.ToString());
m_logger.LogError("[CAPS]: " + e.ToString());
}
}
@ -354,7 +365,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
catch (Exception e)
{
m_log.Error("[CAPS]: " + e.ToString());
m_logger.LogError(e, "[CAPS]: RegisterInventoryServiceHandlers Exception");
}
}
@ -370,7 +381,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
catch (Exception e)
{
m_log.Error("[CAPS]: " + e.ToString());
m_logger.LogError(e, "[CAPS]: RegisterOtherHandlers");
}
}
/// <summary>
@ -385,8 +396,8 @@ namespace OpenSim.Region.ClientStack.Linden
public void SeedCapRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
UUID agentID = m_HostCapsObj.AgentID;
m_log.DebugFormat(
"[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, agentID);
m_logger.LogDebug($"[CAPS]: Received SEED caps request in {m_regionName} for agent {agentID}");
if(httpRequest.HttpMethod != "POST" || httpRequest.ContentType != "application/llsd+xml")
{
@ -403,9 +414,8 @@ namespace OpenSim.Region.ClientStack.Linden
if (!m_Scene.CheckClient(agentID, httpRequest.RemoteIPEndPoint))
{
m_log.WarnFormat(
"[CAPS]: Unauthorized CAPS client {0} from {1}",
agentID, httpRequest.RemoteIPEndPoint);
m_logger.LogWarning($"[CAPS]: Unauthorized CAPS client {agentID} from {httpRequest.RemoteIPEndPoint}");
httpResponse.StatusCode = (int)HttpStatusCode.Forbidden;
return;
}
@ -438,7 +448,7 @@ namespace OpenSim.Region.ClientStack.Linden
string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(true, validCaps));
httpResponse.RawBuffer = Util.UTF8NBGetbytes(result);
httpResponse.StatusCode = (int)HttpStatusCode.OK;
//m_log.DebugFormat("[CAPS] CapsRequest {0}", result);
//m_logger.DebugFormat("[CAPS] CapsRequest {0}", result);
m_HostCapsObj.Flags |= Caps.CapsFlags.SentSeeds;
}
@ -450,8 +460,8 @@ namespace OpenSim.Region.ClientStack.Linden
/// <returns></returns>
public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
{
//m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString());
//m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type);
//m_logger.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString());
//m_logger.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type);
// start by getting the client
IClientAPI client = null;
@ -678,9 +688,7 @@ namespace OpenSim.Region.ClientStack.Linden
lock (m_ModelCost)
m_FileAgentInventoryState = FileAgentInventoryState.processUpload;
m_log.DebugFormat(
"[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
assetID, inventoryItem, inventoryType, assetType);
m_logger.LogDebug($"[BUNCH OF CAPS]: Uploaded asset {assetID} for inventory item {inventoryItem}, inv type {inventoryType}, asset type {assetType}");
sbyte assType = 0;
sbyte inType = 0;
@ -731,7 +739,7 @@ namespace OpenSim.Region.ClientStack.Linden
{
inType = (sbyte)CustomInventoryType.AnimationSet;
assType = (sbyte)CustomAssetType.AnimationSet;
m_log.Debug("got animset upload request");
m_logger.LogDebug("got animset upload request");
}
else if (inventoryType == "wearable")
{
@ -1101,7 +1109,7 @@ namespace OpenSim.Region.ClientStack.Linden
else // not a mesh model
{
m_log.ErrorFormat("[CAPS Asset Upload] got unsuported assetType for object upload");
m_logger.LogError("[CAPS Asset Upload] got unsuported assetType for object upload");
return;
}
}
@ -1287,7 +1295,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
catch { }
m_log.Debug("[CAPS]: CreateInventoryCategory failed to process request");
m_logger.LogDebug("[CAPS]: CreateInventoryCategory failed to process request");
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
}
@ -1312,7 +1320,7 @@ namespace OpenSim.Region.ClientStack.Linden
UUID folderID = content["folder-id"].AsUUID();
UUID itemID = content["item-id"].AsUUID();
// m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, FolderID:{0}, ItemID:{1}, NotecardID:{2}, ObjectID:{3}", folderID, itemID, notecardID, objectID);
// m_logger.InfoFormat("[CAPS]: CopyInventoryFromNotecard, FolderID:{0}, ItemID:{1}, NotecardID:{2}, ObjectID:{3}", folderID, itemID, notecardID, objectID);
UUID noteAssetID = UUID.Zero;
UUID agentID = m_HostCapsObj.AgentID;
@ -1345,9 +1353,10 @@ namespace OpenSim.Region.ClientStack.Linden
if (copyItem == null)
throw new Exception("Failed to find notecard item" + notecardID.ToString());
m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
m_logger.LogInformation($"[CAPS]: CopyInventoryFromNotecard, ItemID:{copyItem.ID}, FolderID:{copyItem.Folder}");
if (client != null)
client.SendBulkUpdateInventory(copyItem);
return;
}
@ -1459,14 +1468,17 @@ namespace OpenSim.Region.ClientStack.Linden
if (!m_Scene.InventoryService.AddItem(item))
throw new Exception("Failed create the notecard item" + notecardID.ToString());
m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0} FolderID:{1}", item.ID, item.Folder);
m_logger.LogInformation($"[CAPS]: CopyInventoryFromNotecard, ItemID:{item.ID} FolderID:{item.Folder}");
if (client != null)
client.SendBulkUpdateInventory(item);
return;
}
catch (Exception e)
{
m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard : {0}", e.Message);
m_logger.LogError(e, $"[CAPS]: CopyInventoryFromNotecard");
copyItem = null;
}
@ -2336,9 +2348,6 @@ namespace OpenSim.Region.ClientStack.Linden
public class AssetUploader
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event UpLoadedAsset OnUpLoad;
private UpLoadedAsset handlerUpLoad = null;
@ -2482,17 +2491,18 @@ namespace OpenSim.Region.ClientStack.Linden
private void TimedOut(object sender, ElapsedEventArgs args)
{
m_log.InfoFormat("[CAPS]: Removing URL and handler for timed out mesh upload");
httpListener.RemoveStreamHandler("POST", uploaderPath);
}
private static void SaveAssetToFile(string filename, byte[] data)
{
string assetPath = "UserAssets";
if (!Directory.Exists(assetPath))
{
Directory.CreateDirectory(assetPath);
}
FileStream fs = File.Create(Path.Combine(assetPath, Util.SafeFileName(filename)));
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(data);
@ -2528,14 +2538,11 @@ namespace OpenSim.Region.ClientStack.Linden
public virtual void Timedout(object state)
{
Stop();
m_log.InfoFormat("[CAPS]: Removing URL and handler for timed out service");
}
}
public class ScriptResourceSummary : ExpiringCapBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private UUID m_agentID;
private int m_memory;
@ -2619,8 +2626,6 @@ namespace OpenSim.Region.ClientStack.Linden
public class ScriptResourceDetails : ExpiringCapBase
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private UUID m_agentID;
private List<ParcelScriptInfo> m_parcelsInfo;

View file

@ -25,8 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Nini.Config;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using OpenMetaverse;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@ -36,10 +39,18 @@ namespace OpenSim.Region.ClientStack.Linden
{
public class BunchOfCapsModule : INonSharedRegionModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_Scene;
private readonly IConfiguration m_configuration;
private readonly ILogger<BunchOfCapsModule> m_logger;
public BunchOfCapsModule(
IConfiguration configuration,
ILogger<BunchOfCapsModule> logger
)
{
m_configuration = configuration;
m_logger = logger;
}
#region INonSharedRegionModule
@ -47,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden
public Type ReplaceableInterface { get { return null; } }
public void Initialise(IConfiguration source)
public void Initialise()
{
}
@ -68,12 +79,12 @@ namespace OpenSim.Region.ClientStack.Linden
}
public void PostInitialise() { }
#endregion
private void OnRegisterCaps(UUID agentID, Caps caps)
{
new BunchOfCaps(m_Scene, agentID, caps);
new BunchOfCaps(m_configuration, m_logger, m_Scene, agentID, caps);
}
}
}

View file

@ -46,6 +46,7 @@ using OSDArray = OpenMetaverse.StructuredData.OSDArray;
using OSDMap = OpenMetaverse.StructuredData.OSDMap;
using Nini.Config;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Region.ClientStack.Linden
{
@ -111,14 +112,15 @@ namespace OpenSim.Region.ClientStack.Linden
ObjectLinkedPartsMax = scene.m_linksetCapacity;
}
public void Econfig(IConfig EconomyConfig)
public void Econfig(IConfigurationSection EconomyConfig)
{
ModelMeshCostFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", ModelMeshCostFactor);
ModelTextureCostFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", ModelTextureCostFactor);
ModelMinCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", ModelMinCostFactor);
ModelMeshCostFactor = EconomyConfig.GetValue<float>("MeshModelUploadCostFactor", ModelMeshCostFactor);
ModelTextureCostFactor = EconomyConfig.GetValue<float>("MeshModelUploadTextureCostFactor", ModelTextureCostFactor);
ModelMinCostFactor = EconomyConfig.GetValue<float>("MeshModelMinCostFactor", ModelMinCostFactor);
// next 2 are normalized so final cost is afected by modelUploadFactor above and normal cost
primCreationCost = EconomyConfig.GetFloat("ModelPrimCreationCost", primCreationCost);
bytecost = EconomyConfig.GetFloat("ModelMeshByteCost", bytecost);
primCreationCost = EconomyConfig.GetValue<float>("ModelPrimCreationCost", primCreationCost);
bytecost = EconomyConfig.GetValue<float>("ModelMeshByteCost", bytecost);
}
// storage for a single mesh asset cost parameters

View file

@ -27,9 +27,10 @@
using System.Globalization;
using System.Net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@ -37,27 +38,34 @@ using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Region.ClientStack.Linden
{
public class EstateAccessCapModule : INonSharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private bool m_Enabled = false;
private string m_capUrl;
private readonly IConfiguration m_configuration;
public EstateAccessCapModule(IConfiguration configuration)
{
m_configuration = configuration;
}
//IEstateModule m_EstateModule;
#region INonSharedRegionModule Members
public void Initialise(IConfiguration pSource)
public void Initialise()
{
IConfig config = pSource.Configs["ClientStack.LindenCaps"];
if (config == null)
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
m_capUrl = config.GetString("Cap_EstateAccess", string.Empty);
m_capUrl = config.GetValue("Cap_EstateAccess", string.Empty);
if (!String.IsNullOrEmpty(m_capUrl) && m_capUrl.Equals("localhost"))
m_Enabled = true;
}

View file

@ -26,39 +26,49 @@
*/
using System.Net;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
public class EstateChangeInfoCapModule : INonSharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private bool m_Enabled = false;
private string m_capUrl;
IEstateModule m_EstateModule;
private readonly IConfiguration m_configuration;
private readonly ILogger<EstateChangeInfoCapModule> m_logger;
public EstateChangeInfoCapModule(
IConfiguration configuration,
ILogger<EstateChangeInfoCapModule> logger
)
{
m_configuration = configuration;
m_logger = logger;
}
#region INonSharedRegionModule Members
public void Initialise(IConfiguration pSource)
public void Initialise()
{
IConfig config = pSource.Configs["ClientStack.LindenCaps"];
if (config == null)
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
m_capUrl = config.GetString("Cap_EstateChangeInfo", string.Empty);
m_capUrl = config.GetValue("Cap_EstateChangeInfo", string.Empty);
if (!String.IsNullOrEmpty(m_capUrl) && m_capUrl.Equals("localhost"))
m_Enabled = true;
}
@ -150,18 +160,20 @@ namespace OpenSim.Region.ClientStack.Linden
}
OSDMap r;
try
{
r = (OSDMap)OSDParser.Deserialize(request.InputStream);
}
catch (Exception ex)
{
m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString());
m_logger.LogError(ex, "[UPLOAD OBJECT ASSET MODULE]: Error deserializing message");
response.StatusCode = (int)HttpStatusCode.BadRequest;
return;
}
bool ok = true;
try
{
string estateName = r["estate_name"].AsString();

View file

@ -27,9 +27,7 @@
using System.Collections;
using System.Net;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
@ -39,6 +37,9 @@ using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
public struct QueueItem
@ -49,7 +50,6 @@ namespace OpenSim.Region.ClientStack.Linden
public partial class EventQueueGetModule : IEventQueue, INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[EVENT QUEUE GET MODULE]";
private const int KEEPALIVE = 60; // this could be larger now, but viewers expect it on opensim
@ -67,9 +67,19 @@ namespace OpenSim.Region.ClientStack.Linden
private readonly Dictionary<UUID, Queue<byte[]>> queues = new();
private readonly Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new();
protected readonly IConfiguration m_configuration;
protected readonly ILogger<EventQueueGetModule> m_logger;
public EventQueueGetModule(IConfiguration configuration, ILogger<EventQueueGetModule> logger)
{
m_configuration = configuration;
m_logger = logger;
}
#region INonSharedRegionModule methods
public virtual void Initialise(IConfiguration config)
public virtual void Initialise()
{
}
@ -173,9 +183,9 @@ namespace OpenSim.Region.ClientStack.Linden
return queue;
if (DebugLevel > 0)
m_log.DebugFormat(
"[EVENTQUEUE]: Adding new queue for agent {0} in region {1}",
agentId, m_scene.RegionInfo.RegionName);
{
m_logger.LogDebug($"[EVENTQUEUE]: Adding new queue for agent {agentId} in region {m_scene.RegionInfo.RegionName}");
}
queue = new Queue<byte[]>();
queues[agentId] = queue;
@ -196,6 +206,7 @@ namespace OpenSim.Region.ClientStack.Linden
{
if (queues.TryGetValue(agentId, out Queue<byte[]> queue))
return queue;
return null;
}
}
@ -216,14 +227,15 @@ namespace OpenSim.Region.ClientStack.Linden
}
else
{
m_log.Warn($"[EVENTQUEUE]: (Enqueue) No queue found for agent {avatarID} in region {m_scene.Name}");
m_logger.LogWarning($"[EVENTQUEUE]: (Enqueue) No queue found for agent {avatarID} in region {m_scene.Name}");
}
}
catch (NullReferenceException e)
{
m_log.Error($"[EVENTQUEUE] Caught exception: {e.Message}");
m_logger.LogError(e, $"[EVENTQUEUE] Caught NullReferenceException");
return false;
}
return true;
}
@ -270,14 +282,12 @@ namespace OpenSim.Region.ClientStack.Linden
}
else
{
m_log.WarnFormat(
"[EVENTQUEUE]: (Enqueue) No queue found for agent {0} in region {1}",
avatarID, m_scene.Name);
m_logger.LogWarning($"[EVENTQUEUE]: (Enqueue) No queue found for agent {avatarID} in region {m_scene.Name}");
}
}
catch (NullReferenceException e)
{
m_log.Error("[EVENTQUEUE] Caught exception: " + e);
m_logger.LogError(e, $"[EVENTQUEUE] Caught NullReferenceException");
return false;
}
return true;
@ -296,14 +306,12 @@ namespace OpenSim.Region.ClientStack.Linden
}
else
{
m_log.WarnFormat(
"[EVENTQUEUE]: (Enqueue) No queue found for agent {0} in region {1}",
avatarID, m_scene.Name);
m_logger.LogWarning($"[EVENTQUEUE]: (Enqueue) No queue found for agent {avatarID} in region {m_scene.Name}");
}
}
catch (NullReferenceException e)
{
m_log.Error("[EVENTQUEUE] Caught exception: " + e);
m_logger.LogError(e, $"[EVENTQUEUE] Caught NullReferenceException");
return false;
}
return true;
@ -344,8 +352,9 @@ namespace OpenSim.Region.ClientStack.Linden
// Register an event queue for the client
if (DebugLevel > 0)
m_log.Debug(
$"[EVENTQUEUE]: OnRegisterCaps: agentID {agentID} caps {caps} region {m_scene.Name}");
{
m_logger.LogDebug($"[EVENTQUEUE]: OnRegisterCaps: agentID {agentID} caps {caps} region {m_scene.Name}");
}
UUID eventQueueGetUUID;
lock (queues)
@ -382,7 +391,8 @@ namespace OpenSim.Region.ClientStack.Linden
// Its reuse caps path not queues those are been reused already
if (m_AvatarQueueUUIDMapping.TryGetValue(agentID, out eventQueueGetUUID))
{
m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
m_logger.LogDebug("[EVENTQUEUE]: Found Existing UUID!");
lock (m_ids)
{
// change to negative numbers so they are changed at end of sending first marker
@ -442,7 +452,7 @@ namespace OpenSim.Region.ClientStack.Linden
{
if (element is OSDMap ev)
{
m_log.Debug($"Eq OUT {ev["message"],-30} to {m_scene.GetScenePresence(agentId).Name,-20} {m_scene.Name,-20}");
m_logger.LogDebug($"Eq OUT {ev["message"],-30} to {m_scene.GetScenePresence(agentId).Name,-20} {m_scene.Name,-20}");
}
}
@ -456,7 +466,7 @@ namespace OpenSim.Region.ClientStack.Linden
public Hashtable GetEvents(UUID requestID, UUID pAgentId)
{
if (DebugLevel >= 2)
m_log.Warn($"POLLED FOR EQ MESSAGES BY {pAgentId} in {m_scene.Name}");
m_logger.LogWarning($"POLLED FOR EQ MESSAGES BY {pAgentId} in {m_scene.Name}");
Queue<byte[]> queue = GetQueue(pAgentId);
if (queue is null)

View file

@ -25,9 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Capabilities.Handlers;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
@ -37,6 +37,8 @@ using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Region.ClientStack.Linden
{
/// <summary>
@ -44,8 +46,6 @@ namespace OpenSim.Region.ClientStack.Linden
/// </summary>
public class FetchInventory2Module : ISharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public bool Enabled { get; private set; }
private int m_nScenes;
@ -58,18 +58,25 @@ namespace OpenSim.Region.ClientStack.Linden
private string m_fetchLib2Url;
private readonly IConfiguration m_configuration;
public FetchInventory2Module(IConfiguration configuration)
{
m_configuration = configuration;
}
#region ISharedRegionModule Members
public void Initialise(IConfiguration source)
public void Initialise()
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
m_fetchInventory2Url = config.GetString("Cap_FetchInventory2", string.Empty);
m_fetchLib2Url = config.GetString("Cap_FetchLib2", "localhost");
m_fetchInventory2Url = config.GetValue("Cap_FetchInventory2", string.Empty);
m_fetchLib2Url = config.GetValue("Cap_FetchLib2", "localhost");
if (m_fetchInventory2Url.Length > 0)
if (string.IsNullOrEmpty(m_fetchInventory2Url) is false)
Enabled = true;
}

View file

@ -26,18 +26,18 @@
*/
using System.Collections;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Capabilities.Handlers;
using Caps = OpenSim.Framework.Capabilities.Caps;
using OpenSim.Capabilities.Handlers;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Region.ClientStack.Linden
{
@ -53,15 +53,13 @@ namespace OpenSim.Region.ClientStack.Linden
public OSHttpRequest request;
}
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Control whether requests will be processed asynchronously.
/// </summary>
/// <remarks>
/// Defaults to true. Can currently not be changed once a region has been added to the module.
/// </remarks>
public bool ProcessQueuedRequestsAsync { get; private set; }
public bool ProcessQueuedRequestsAsync { get; set; }
/// <summary>
/// Number of inventory requests processed by this module.
@ -86,21 +84,22 @@ namespace OpenSim.Region.ClientStack.Linden
#region ISharedRegionModule Members
public FetchLibDescModule() : this(true) {}
protected readonly IConfiguration m_configuration;
public FetchLibDescModule(bool processQueuedResultsAsync)
public FetchLibDescModule(IConfiguration configuration, bool processQueuedResultsAsync = true)
{
m_configuration = configuration;
ProcessQueuedRequestsAsync = processQueuedResultsAsync;
}
public void Initialise(IConfiguration source)
public void Initialise()
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config == null)
return;
m_fetchLibDescendents2Url = config.GetString("Cap_FetchLibDescendents2", string.Empty);
m_Enabled = m_fetchLibDescendents2Url.Length > 0;
m_fetchLibDescendents2Url = config.GetValue("Cap_FetchLibDescendents2", string.Empty);
m_Enabled = string.IsNullOrEmpty(m_fetchLibDescendents2Url);
}
public void AddRegion(Scene s)
@ -172,8 +171,6 @@ namespace OpenSim.Region.ClientStack.Linden
private class PollServiceInventoryEventArgs : PollServiceEventArgs
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, Hashtable> responses = new Dictionary<UUID, Hashtable>();
private HashSet<UUID> dropedResponses = new HashSet<UUID>();

View file

@ -26,9 +26,9 @@
*/
using System.Collections;
using System.Reflection;
using log4net;
using Nini.Config;
using log4net.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using OpenMetaverse;
using OpenSim.Capabilities.Handlers;
using OpenSim.Framework;
@ -43,9 +43,6 @@ namespace OpenSim.Region.ClientStack.Linden
{
public class GetAssetsModule : INonSharedRegionModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private bool m_Enabled;
@ -66,8 +63,6 @@ namespace OpenSim.Region.ClientStack.Linden
public OSHttpResponse osresponse;
}
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static IAssetService m_assetService = null;
private static GetAssetsHandler m_getAssetHandler;
private static ObjectJobEngine m_workerpool = null;
@ -75,6 +70,15 @@ namespace OpenSim.Region.ClientStack.Linden
private static object m_loadLock = new object();
protected IUserManagement m_UserManagement = null;
protected readonly IConfiguration m_configuration;
protected readonly ILogger<GetAssetsModule> m_logger;
public GetAssetsModule(IConfiguration configuration, ILogger<GetAssetsModule> logger)
{
m_configuration = configuration;
m_logger = logger;
}
#region Region Module interfaceBase Members
public Type ReplaceableInterface
@ -82,26 +86,26 @@ namespace OpenSim.Region.ClientStack.Linden
get { return null; }
}
public void Initialise(IConfiguration source)
public void Initialise()
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
m_GetTextureURL = config.GetString("Cap_GetTexture", string.Empty);
if (m_GetTextureURL != string.Empty)
m_GetTextureURL = config.GetValue("Cap_GetTexture", string.Empty);
if (string.IsNullOrEmpty(m_GetTextureURL) is false)
m_Enabled = true;
m_GetMeshURL = config.GetString("Cap_GetMesh", string.Empty);
if (m_GetMeshURL != string.Empty)
m_GetMeshURL = config.GetValue("Cap_GetMesh", string.Empty);
if (string.IsNullOrEmpty(m_GetMeshURL) is false)
m_Enabled = true;
m_GetMesh2URL = config.GetString("Cap_GetMesh2", string.Empty);
if (m_GetMesh2URL != string.Empty)
m_GetMesh2URL = config.GetValue("Cap_GetMesh2", string.Empty);
if (string.IsNullOrEmpty(m_GetMesh2URL) is false)
m_Enabled = true;
m_GetAssetURL = config.GetString("Cap_GetAsset", string.Empty);
if (m_GetAssetURL != string.Empty)
m_GetAssetURL = config.GetValue("Cap_GetAsset", string.Empty);
if (string.IsNullOrEmpty(m_GetAssetURL) is false)
m_Enabled = true;
}

View file

@ -27,6 +27,7 @@
using System.Net;
using System.Text;
using Microsoft.Extensions.Configuration;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@ -43,9 +44,6 @@ namespace OpenSim.Region.ClientStack.Linden
/// </summary>
public class MeshUploadFlagModule : INonSharedRegionModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Is this module enabled?
/// </summary>
@ -53,23 +51,27 @@ namespace OpenSim.Region.ClientStack.Linden
private Scene m_scene;
private readonly IConfiguration m_configuration;
#region ISharedRegionModule Members
public MeshUploadFlagModule()
public MeshUploadFlagModule(IConfiguration configuration)
{
m_configuration = configuration;
Enabled = true;
}
public void Initialise(IConfiguration source)
public void Initialise()
{
IConfig config = source.Configs["Mesh"];
if (config == null)
var config = m_configuration.GetSection("Mesh");
if (config.Exists() is false)
{
return;
}
else
{
Enabled = config.GetBoolean("AllowMeshUpload", Enabled);
Enabled = config.GetValue<bool>("AllowMeshUpload", Enabled);
}
}

View file

@ -26,9 +26,10 @@
*/
using System.Net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@ -36,16 +37,24 @@ using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Region.ClientStack.Linden
{
public class ObjectAdd : INonSharedRegionModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IConfiguration m_configuration;
public ObjectAdd(IConfiguration configuration)
{
m_configuration = configuration;
}
#region INonSharedRegionModule Members
public void Initialise(IConfiguration pSource)
public void Initialise()
{
}

View file

@ -26,9 +26,7 @@
*/
using System.Net;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.Messages.Linden;
using OpenSim.Framework;
@ -40,14 +38,24 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
using OSDMap = OpenMetaverse.StructuredData.OSDMap;
using ExtraParamType = OpenMetaverse.ExtraParamType;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
public class UploadObjectAssetModule : INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private readonly IConfiguration m_configuration;
private readonly ILogger<UploadObjectAssetModule> m_logger;
public UploadObjectAssetModule(IConfiguration configuration, ILogger<UploadObjectAssetModule> logger)
{
m_configuration = configuration;
m_logger = logger;
}
#region Region Module interfaceBase Members
public Type ReplaceableInterface
@ -55,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden
get { return null; }
}
public void Initialise(IConfiguration source)
public void Initialise()
{
}
@ -123,7 +131,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
catch (Exception ex)
{
m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString());
m_logger.LogError(ex, "[UPLOAD OBJECT ASSET MODULE]: Error deserializing message");
message = null;
}

View file

@ -27,9 +27,10 @@
using System.Collections.Concurrent;
using System.Net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers.HttpServer;
@ -38,14 +39,12 @@ using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Region.ClientStack.Linden
{
public class RegionConsoleModule : INonSharedRegionModule, IRegionConsole
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IEventQueue m_eventQueue;
private Commands m_commands = new Commands();
@ -53,9 +52,16 @@ namespace OpenSim.Region.ClientStack.Linden
ConcurrentDictionary<UUID, OnOutputDelegate> currentConsoles = new ConcurrentDictionary<UUID, OnOutputDelegate>();
protected readonly IConfiguration m_configuration;
public RegionConsoleModule(IConfiguration configuration)
{
m_configuration = configuration;
}
public event ConsoleMessage OnConsoleMessage;
public void Initialise(IConfiguration source)
public void Initialise()
{
m_commands.AddCommand( "Help", false, "help", "help [<item>]", "Display help on a particular command or on a list of commands in a category", Help);
}

View file

@ -27,24 +27,32 @@
// Dedicated to Quill Littlefeather
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
class ServerReleaseNotesModule : ISharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_enabled;
private string m_ServerReleaseNotesURL;
private readonly IConfiguration m_configuration;
private readonly ILogger<ServerReleaseNotesModule> m_logger;
public ServerReleaseNotesModule(IConfiguration configuration, ILogger<ServerReleaseNotesModule> logger)
{
m_configuration = configuration;
m_logger = logger;
}
public string Name { get { return "ServerReleaseNotesModule"; } }
@ -53,29 +61,30 @@ namespace OpenSim.Region.ClientStack.Linden
get { return null; }
}
public void Initialise(IConfiguration source)
public void Initialise()
{
m_enabled = false; // whatever
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
string capURL = config.GetString("Cap_ServerReleaseNotes", string.Empty);
string capURL = config.GetValue("Cap_ServerReleaseNotes", string.Empty);
if (string.IsNullOrEmpty(capURL) || capURL != "localhost")
return;
config = source.Configs["ServerReleaseNotes"];
if (config == null)
config = m_configuration.GetSection("ServerReleaseNotes");
if (config.Exists() is false)
return;
m_ServerReleaseNotesURL = config.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
m_ServerReleaseNotesURL = config.GetValue("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
if (string.IsNullOrEmpty(m_ServerReleaseNotesURL))
return;
Uri dummy;
if(!Uri.TryCreate(m_ServerReleaseNotesURL,UriKind.Absolute, out dummy))
if (Uri.TryCreate(m_ServerReleaseNotesURL,UriKind.Absolute, out dummy) is false)
{
m_log.Error("[Cap_ServerReleaseNotes]: Invalid ServerReleaseNotesURL. Cap Disabled");
m_logger.LogError("[Cap_ServerReleaseNotes]: Invalid ServerReleaseNotesURL. Cap Disabled");
return;
}

View file

@ -26,12 +26,11 @@
*/
using System.Net;
using System.Reflection;
using System.Text;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@ -39,6 +38,9 @@ using OpenSim.Region.Framework.Scenes;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
/// <summary>
@ -54,8 +56,6 @@ namespace OpenSim.Region.ClientStack.Linden
/// </remarks>
public class SimulatorFeaturesModule : INonSharedRegionModule, ISimulatorFeaturesModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
private Scene m_scene;
@ -67,22 +67,30 @@ namespace OpenSim.Region.ClientStack.Linden
private bool m_ExportSupported = false;
private bool m_doScriptSyntax;
private bool m_doScriptSyntax = true;
static private readonly object m_scriptSyntaxLock = new();
static private UUID m_scriptSyntaxID = UUID.Zero;
static private byte[] m_scriptSyntaxXML = null;
private readonly IConfiguration m_configuration;
private readonly ILogger<SimulatorFeaturesModule> m_logger;
public SimulatorFeaturesModule(IConfiguration configuration, ILogger<SimulatorFeaturesModule> logger)
{
m_configuration = configuration;
m_logger = logger;
}
#region ISharedRegionModule Members
public void Initialise(IConfiguration source)
{
IConfig config = source.Configs["SimulatorFeatures"];
m_doScriptSyntax = true;
if (config != null)
public void Initialise()
{
var config = m_configuration.GetSection("SimulatorFeatures");
if (config.Exists() is true)
{
m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported);
m_doScriptSyntax = config.GetBoolean("ScriptSyntax", m_doScriptSyntax);
m_ExportSupported = config.GetValue<bool>("ExportSupported", m_ExportSupported);
m_doScriptSyntax = config.GetValue<bool>("ScriptSyntax", m_doScriptSyntax);
}
ReadScriptSyntax();
@ -331,7 +339,7 @@ namespace OpenSim.Region.ClientStack.Linden
Dictionary<string, object> extraFeatures = scene.GridService.GetExtraFeatures();
if (extraFeatures.ContainsKey("Result") && extraFeatures["Result"] != null && extraFeatures["Result"].ToString() == "Failure")
{
m_log.WarnFormat("[SIMULATOR FEATURES MODULE]: Unable to retrieve grid-wide features");
m_logger.LogWarning("[SIMULATOR FEATURES MODULE]: Unable to retrieve grid-wide features");
return;
}
@ -434,9 +442,10 @@ namespace OpenSim.Region.ClientStack.Linden
m_scriptSyntaxID = id;
}
}
catch
catch (Exception e)
{
m_log.Error("[SIMULATOR FEATURES MODULE] fail read ScriptSyntax.xml file");
m_logger.LogError(e, "[SIMULATOR FEATURES MODULE] fail read ScriptSyntax.xml file");
m_scriptSyntaxID = UUID.Zero;
m_scriptSyntaxXML = null;
}

View file

@ -26,11 +26,10 @@
*/
using System.Net;
using System.Reflection;
using System.Timers;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@ -39,24 +38,33 @@ using OpenSim.Framework.Capabilities;
using Caps = OpenSim.Framework.Capabilities.Caps;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Region.ClientStack.Linden
{
public class UploadBakedTextureModule : ISharedRegionModule
{
private static readonly ILog m_log =LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private int m_nscenes;
IAssetCache m_assetCache = null;
private string m_URL;
public void Initialise(IConfiguration source)
protected readonly IConfiguration m_configuration;
protected readonly ILogger<UploadBakedTextureModule> m_logger;
public UploadBakedTextureModule(IConfiguration configuration, ILogger<UploadBakedTextureModule> logger)
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
m_configuration = configuration;
m_logger = logger;
}
public void Initialise()
{
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty);
m_URL = config.GetValue("Cap_UploadBakedTexture", string.Empty);
}
public void AddRegion(Scene s)
@ -66,6 +74,7 @@ namespace OpenSim.Region.ClientStack.Linden
public void RemoveRegion(Scene s)
{
s.EventManager.OnRegisterCaps -= RegisterCaps;
--m_nscenes;
if(m_nscenes <= 0)
m_assetCache = null;
@ -75,6 +84,7 @@ namespace OpenSim.Region.ClientStack.Linden
{
if (m_assetCache == null)
m_assetCache = s.RequestModuleInterface <IAssetCache>();
if (m_assetCache != null)
{
++m_nscenes;
@ -143,7 +153,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
catch (Exception e)
{
m_log.ErrorFormat("[UPLOAD BAKED TEXTURE HANDLER]: Error: {0}", e.Message);
m_logger.LogError(e, "[UPLOAD BAKED TEXTURE HANDLER] UploadBakedTexture");
}
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
}

View file

@ -26,10 +26,9 @@
*/
using System.Collections;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
@ -41,6 +40,8 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
using OpenSim.Capabilities.Handlers;
using OpenSim.Framework.Monitoring;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Region.ClientStack.Linden
{
/// <summary>
@ -55,8 +56,6 @@ namespace OpenSim.Region.ClientStack.Linden
public OSHttpRequest request;
}
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Control whether requests will be processed asynchronously.
/// </summary>
@ -92,23 +91,25 @@ namespace OpenSim.Region.ClientStack.Linden
private static int m_NumberScenes = 0;
protected readonly IConfiguration m_configuration;
#region ISharedRegionModule Members
public WebFetchInvDescModule() : this(true) {}
public WebFetchInvDescModule(bool processQueuedResultsAsync)
public WebFetchInvDescModule(IConfiguration configuratioon, bool processQueuedResultsAsync = true)
{
m_configuration = configuratioon;
ProcessQueuedRequestsAsync = processQueuedResultsAsync;
}
public void Initialise(IConfiguration source)
public void Initialise()
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
var config = m_configuration.GetSection("ClientStack.LindenCaps");
if (config.Exists() is false)
return;
m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty);
m_Enabled = m_fetchInventoryDescendents2Url.Length > 0;
m_fetchInventoryDescendents2Url = config.GetValue("Cap_FetchInventoryDescendents2", string.Empty);
m_Enabled = string.IsNullOrEmpty(m_fetchInventoryDescendents2Url) is false;
}
public void AddRegion(Scene s)

View file

@ -382,7 +382,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
TickCountResolution += (float)(now - start);
}
m_log.Info($"[LLUDPSERVER]: Average Environment.TickCount resolution: {TickCountResolution * 0.1f}ms");
m_logger.LogInformation($"[LLUDPSERVER]: Average Environment.TickCount resolution: {TickCountResolution * 0.1f}ms");
TickCountResolution = 0f;
for (int i = 0; i < 100; i++)
@ -395,7 +395,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
TickCountResolution = MathF.Round(TickCountResolution * 0.01f,6,MidpointRounding.AwayFromZero);
m_log.Info($"[LLUDPSERVER]: Average Util.GetTimeStampMS resolution: {TickCountResolution}ms");
m_logger.LogInformation($"[LLUDPSERVER]: Average Util.GetTimeStampMS resolution: {TickCountResolution}ms");
#endregion Environment.TickCount Measurement
@ -468,7 +468,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void StartInbound()
{
m_log.Info("[LLUDPSERVER]: Starting inbound packet processing for the LLUDP server");
m_logger.LogInformation("[LLUDPSERVER]: Starting inbound packet processing for the LLUDP server");
base.StartInbound(m_recvBufferSize);
@ -485,7 +485,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public override void StartOutbound()
{
m_log.Info("[LLUDPSERVER]: Starting outbound packet processing for the LLUDP server");
m_logger.LogInformation("[LLUDPSERVER]: Starting outbound packet processing for the LLUDP server");
base.StartOutbound();
@ -501,7 +501,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void Stop()
{
m_log.Info($"[LLUDPSERVER]: Shutting down the LLUDP server for {Scene.Name}");
m_logger.LogInformation($"[LLUDPSERVER]: Shutting down the LLUDP server for {Scene.Name}");
base.StopOutbound();
base.StopInbound();
//IpahEngine.Stop();
@ -517,13 +517,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
if (Scene is not null)
{
m_log.Error("[LLUDPSERVER]: AddScene() called on an LLUDPServer that already has a scene");
m_logger.LogError("[LLUDPSERVER]: AddScene() called on an LLUDPServer that already has a scene");
return;
}
if (scene is not OpenSim.Region.Framework.Scenes.Scene)
{
m_log.Error($"[LLUDPSERVER]: AddScene() called with an unrecognized scene type {scene.GetType()}");
m_logger.LogError($"[LLUDPSERVER]: AddScene() called with an unrecognized scene type {scene.GetType()}");
return;
}
@ -692,7 +692,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int packetCount = datas.Length;
if (packetCount < 1)
m_log.Error($"[LLUDPSERVER]: Failed to split {packet.Type} with estimated length {packet.Length}");
m_logger.LogError($"[LLUDPSERVER]: Failed to split {packet.Type} with estimated length {packet.Length}");
for (int i = 0; i < packetCount; i++)
SendPacketData(udpClient, datas[i], packet.Type, category, method);
@ -785,7 +785,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// The packet grew larger than the bufferSize while zerocoding.
// Remove the MSG_ZEROCODED flag and send the unencoded data
// instead
m_log.Debug($"[LLUDPSERVER]: Packet exceeded buffer size ({buffer.Data.Length}) during zerocoding for {type}. DataLength={dataLength}. Removing MSG_ZEROCODED flag");
m_logger.LogDebug($"[LLUDPSERVER]: Packet exceeded buffer size ({buffer.Data.Length}) during zerocoding for {type}. DataLength={dataLength}. Removing MSG_ZEROCODED flag");
data[0] = (byte)(data[0] & ~Helpers.MSG_ZEROCODED);
}
}
@ -800,7 +800,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
else
{
m_log.Error($"[LLUDPSERVER]: Packet exceeded MTU ({LLUDPServer.MTU}) Type={type}, DataLength={dataLength}");
m_logger.LogError($"[LLUDPSERVER]: Packet exceeded MTU ({LLUDPServer.MTU}) Type={type}, DataLength={dataLength}");
// buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, dataLength);
buffer = GetNewUDPBuffer(udpClient.RemoteEndPoint);
Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength);
@ -1048,7 +1048,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void ResendUnacked(OutgoingPacket outgoingPacket)
{
//m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed",
//m_logger.LogDebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed",
// outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount);
// Set the resent flag
@ -1144,20 +1144,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
if (udpClient.DebugDataOutLevel > 0)
m_log.Debug(
m_logger.LogDebug(
$"[LLUDPSERVER]: Sending packet #{outgoingPacket.SequenceNumber} (rel: {isReliable}, res: {isResend}) to {udpClient.AgentID} from {Scene.Name}");
}
protected void RecordMalformedInboundPacket(IPEndPoint endPoint)
{
//if (m_malformedCount < 100)
// m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.Message);
// m_logger.LogDebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.Message);
IncomingMalformedPacketCount++;
if ((IncomingMalformedPacketCount % 10000) == 0)
m_log.Warn(
$"[LLUDPSERVER]: Received {IncomingMalformedPacketCount} malformed packets so far, probable network attack. Last was from {endPoint}");
{
m_logger.LogWarning(
$"[LLUDPSERVER]: Received {IncomingMalformedPacketCount} malformed packets so far, " +
"probable network attack. Last was from {endPoint}");
}
}
public override void PacketReceived(UDPPacketBuffer buffer)
@ -1165,7 +1168,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Debugging/Profiling
//try { Thread.CurrentThread.Name = "PacketReceived (" + m_scene.RegionInfo.RegionName + ")"; }
//catch (Exception) { }
//m_log.DebugFormat(
//m_logger.LogDebugFormat(
// "[LLUDPSERVER]: Packet received from {0} in {1}", buffer.RemoteEndPoint, m_scene.RegionInfo.RegionName);
Packet packet = null;
@ -1224,7 +1227,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
catch (Exception e)
{
if (IncomingMalformedPacketCount < 100)
m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString());
m_logger.LogDebug(e, "[LLUDPSERVER]: Dropped malformed packet");
}
// Fail-safe check
@ -1232,8 +1235,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
if (IncomingMalformedPacketCount < 100)
{
m_log.WarnFormat("[LLUDPSERVER]: Malformed data, cannot parse {0} byte packet from {1}, data {2}:",
buffer.DataLength, buffer.RemoteEndPoint, Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
m_logger.LogWarning($"[LLUDPSERVER]: Malformed data, cannot parse {buffer.DataLength} " +
$"byte packet from {buffer.RemoteEndPoint}, data {Utils.BytesToHexString(buffer.Data, buffer.DataLength, null)}");
}
RecordMalformedInboundPacket(endPoint);
@ -1258,7 +1261,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
}
//m_log.DebugFormat("[LLUDPSERVER]: Enqueued a {0} packet into the pending queue", packet.Type);
//m_logger.LogDebugFormat("[LLUDPSERVER]: Enqueued a {0} packet into the pending queue", packet.Type);
queue.Enqueue(buffer);
return;
}
@ -1294,13 +1297,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Determine which agent this packet came from
if (client == null || client is not LLClientView)
{
//m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
//m_logger.LogDebug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
IncomingOrphanedPacketCount++;
if ((IncomingOrphanedPacketCount % 10000) == 0)
m_log.Warn(
$"[LLUDPSERVER]: Received {IncomingOrphanedPacketCount} orphaned packets so far. Last was from {endPoint}");
{
m_logger.LogWarning($"[LLUDPSERVER]: Received {IncomingOrphanedPacketCount} orphaned packets so far. Last was from {endPoint}");
}
return;
}
@ -1309,7 +1313,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!udpClient.IsConnected)
{
m_log.Debug($"[LLUDPSERVER]: Received a {packet.Type} packet for a unConnected client in {Scene.Name}");
m_logger.LogDebug($"[LLUDPSERVER]: Received a {packet.Type} packet for a unConnected client in {Scene.Name}");
return;
}
@ -1326,7 +1330,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Handle appended ACKs
if (packet.Header.AppendedAcks && packet.Header.AckList != null)
{
// m_log.DebugFormat(
// m_logger.LogDebugFormat(
// "[LLUDPSERVER]: Handling {0} appended acks from {1} in {2}",
// packet.Header.AckList.Length, client.Name, m_scene.Name);
@ -1339,7 +1343,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
PacketAckPacket ackPacket = (PacketAckPacket)packet;
// m_log.DebugFormat(
// m_logger.LogDebugFormat(
// "[LLUDPSERVER]: Handling {0} packet acks for {1} in {2}",
// ackPacket.Packets.Length, client.Name, m_scene.Name);
@ -1356,7 +1360,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (packet.Header.Reliable)
{
//m_log.DebugFormat(
//m_logger.LogDebugFormat(
// "[LLUDPSERVER]: Adding ack request for {0} {1} from {2} in {3}",
// packet.Type, packet.Header.Sequence, client.Name, m_scene.Name);
@ -1389,11 +1393,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (packet.Header.Reliable && !udpClient.PacketArchive.TryEnqueue(packet.Header.Sequence))
{
if (packet.Header.Resent)
m_log.Debug(
{
m_logger.LogDebug(
$"[LLUDPSERVER]: Received a resend of already processed packet #{packet.Header.Sequence}, type {packet.Type} from {client.Name}");
else
m_log.Warn(
}
else
{
m_logger.LogWarning(
$"[LLUDPSERVER]: Received a duplicate (not marked as resend) of packet #{packet.Header.Sequence}, type {packet.Type} from {client.Name}");
}
// Avoid firing a callback twice for the same packet
return;
@ -1409,7 +1417,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (packet.Type == PacketType.StartPingCheck)
{
//m_log.DebugFormat("[LLUDPSERVER]: Handling ping from {0} in {1}", client.Name, m_scene.Name);
//m_logger.LogDebugFormat("[LLUDPSERVER]: Handling ping from {0} in {1}", client.Name, m_scene.Name);
// We don't need to do anything else with ping checks
StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
@ -1500,12 +1508,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
uint type = (uint)packetType;
type |= (uint)flags << 24;
// m_log.Debug("1 LogPacketHeader(): Outside lock");
// m_logger.LogDebug("1 LogPacketHeader(): Outside lock");
lock (binStatsLogLock)
{
DateTime now = DateTime.Now;
// m_log.Debug("2 LogPacketHeader(): Inside lock. now is " + now.Ticks);
// m_logger.LogDebug("2 LogPacketHeader(): Inside lock. now is " + now.Ticks);
try
{
if (PacketLog == null || (now > PacketLog.StartTime + binStatsMaxFilesize))
@ -1538,7 +1546,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
catch (Exception ex)
{
m_log.Error($"Packet statistics gathering failed: {ex.Message}");
m_logger.LogError(ex, $"Packet statistics gathering failed");
if (PacketLog.Log != null)
{
PacketLog.Log.Close();
@ -1561,7 +1569,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
endPoint = (IPEndPoint)array[0];
UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
m_log.DebugFormat(
m_logger.LogDebug(
$"[LLUDPSERVER]: Handling UseCircuitCode request for circuit {uccp.CircuitCode.Code} to {Scene.Name} from IP {endPoint}");
if (IsClientAuthorized(uccp, out AuthenticateResponse sessionInfo))
@ -1573,11 +1581,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
IPAddress aIP = IPAddress.Parse(aCircuit.IPAddress);
if(!endPoint.Address.Equals(aIP))
m_log.Debug($"[LLUDPSERVER]: HandleUseCircuitCode IP mismatch {endPoint.Address} != {aCircuit.IPAddress}");
m_logger.LogDebug($"[LLUDPSERVER]: HandleUseCircuitCode IP mismatch {endPoint.Address} != {aCircuit.IPAddress}");
}
catch
{
m_log.Debug($"[LLUDPSERVER]: HandleUseCircuitCode could not compare IP {endPoint.Address} {aCircuit.IPAddress}");
m_logger.LogDebug($"[LLUDPSERVER]: HandleUseCircuitCode could not compare IP {endPoint.Address} {aCircuit.IPAddress}");
}
}
@ -1606,7 +1614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
}
m_log.Debug("[LLUDPSERVER]: Client created");
m_logger.LogDebug("[LLUDPSERVER]: Client created");
Queue<UDPPacketBuffer> queue = null;
lock (m_pendingCache)
@ -1614,13 +1622,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (m_pendingCache.TryGetValue(endPoint, out queue))
m_pendingCache.Remove(endPoint);
else
m_log.Debug("[LLUDPSERVER]: HandleUseCircuitCode with no pending queue present");
m_logger.LogDebug("[LLUDPSERVER]: HandleUseCircuitCode with no pending queue present");
}
// Reinject queued packets
if(queue != null)
{
m_log.Debug($"[LLUDPSERVER]: processing UseCircuitCode pending queue, {queue.Count} entries");
m_logger.LogDebug($"[LLUDPSERVER]: processing UseCircuitCode pending queue, {queue.Count} entries");
while (queue.Count > 0)
{
UDPPacketBuffer buf = queue.Dequeue();
@ -1635,28 +1643,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
else
{
// Don't create clients for unauthorized requesters.
m_log.WarnFormat(
"[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}",
uccp.CircuitCode.ID, Scene.RegionInfo.RegionName, uccp.CircuitCode.Code, endPoint);
m_logger.LogWarning(
$"[LLUDPSERVER]: Ignoring connection request for {uccp.CircuitCode.ID} to {Scene.RegionInfo.RegionName} "+
$"with unknown circuit code {uccp.CircuitCode.Code} from IP {endPoint}");
lock (m_pendingCache)
m_pendingCache.Remove(endPoint);
}
//m_log.DebugFormat(
//m_logger.LogDebugFormat(
// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[LLUDPSERVER]: UseCircuitCode handling from endpoint {0}, client {1} {2} failed. Exception {3}{4}",
endPoint != null ? endPoint.ToString() : "n/a",
client != null ? client.Name : "unknown",
client != null ? client.AgentId.ToString() : "unknown",
e.Message,
e.StackTrace);
m_logger.LogError(
e, $"[LLUDPSERVER]: UseCircuitCode handling from endpoint {(endPoint != null ? endPoint : "n/a")}, " +
$"client {(client != null ? client.Name : "unknown")} {(client != null ? client.AgentId.ToString() : "unknown")} failed.");
}
}
@ -1761,9 +1765,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
ClientLogoutsDueToNoReceives++;
if (client.SceneAgent != null)
{
m_log.WarnFormat(
"[LLUDPSERVER]: No packets received from {0} agent of {1} for {2}ms in {3}. Disconnecting.",
client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, timeoutTicks, Scene.Name);
m_logger.LogWarning(
$"[LLUDPSERVER]: No packets received from {(client.SceneAgent.IsChildAgent ? "child" : "root")} "+
$"agent of {client.Name} for {timeoutTicks}ms in {Scene.Name}. Disconnecting.");
}
if (!Scene.CloseAgent(client.AgentId, true))
@ -1797,14 +1801,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
*/
catch (Exception ex)
{
m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex);
m_logger.LogError("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex);
}
Watchdog.UpdateThread();
}
if (packetInbox.Count > 0)
m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets");
{
m_logger.LogWarning($"[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping {packetInbox.Count} packets");
}
packetInbox.Dispose();
Watchdog.RemoveThread();
@ -1883,7 +1890,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
catch (Exception ex)
{
m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex);
m_logger.LogError("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex);
}
}
@ -1920,7 +1927,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
catch (Exception ex)
{
m_log.Error(
m_logger.LogError(
string.Format("[LLUDPSERVER]: OutgoingPacketHandler iteration for {0} threw ", client.Name), ex);
}
}
@ -1966,13 +1973,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
catch(ThreadAbortException)
{
// If something is trying to abort the packet processing thread, take that as a hint that it's time to shut down
m_log.Info("[LLUDPSERVER]: Caught a thread abort, shutting down the LLUDP server");
m_logger.LogInformation("[LLUDPSERVER]: Caught a thread abort, shutting down the LLUDP server");
Stop();
}
catch(Exception e)
{
// Don't let a failure in an individual client thread crash the whole sim.
m_log.Error(
m_logger.LogError(
string.Format(
"[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw ",
client.Name,packet.Type),

View file

@ -25,14 +25,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Concurrent;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using log4net;
using Microsoft.Extensions.Logging;
using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
namespace OpenMetaverse
{
@ -41,14 +37,15 @@ namespace OpenMetaverse
/// </summary>
public abstract class OpenSimUDPBase
{
private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// This method is called when an incoming packet is received
/// </summary>
/// <param name="buffer">Incoming packet buffer</param>
public abstract void PacketReceived(UDPPacketBuffer buffer);
// Logging Extensions;
protected ILogger m_logger;
/// <summary>UDP port to bind to in server mode</summary>
protected int m_udpPort;
@ -181,7 +178,7 @@ namespace OpenMetaverse
{
if (!IsRunningInbound)
{
m_log.DebugFormat("[UDPBASE]: Starting inbound UDP loop");
m_logger.LogDebug("[UDPBASE]: Starting inbound UDP loop");
const int SIO_UDP_CONNRESET = -1744830452;
@ -197,7 +194,7 @@ namespace OpenMetaverse
}
catch (SocketException)
{
m_log.Debug("[UDPBASE]: Failed to increase default TTL");
m_logger.LogDebug("[UDPBASE]: Failed to increase default TTL");
}
try
@ -206,7 +203,7 @@ namespace OpenMetaverse
}
catch
{
m_log.Debug("[UDPBASE]: SIO_UDP_CONNRESET flag not supported on this platform, ignoring");
m_logger.LogDebug("[UDPBASE]: SIO_UDP_CONNRESET flag not supported on this platform, ignoring");
}
// On at least Mono 3.2.8, multiple UDP sockets can bind to the same port by default. At the moment
@ -244,7 +241,7 @@ namespace OpenMetaverse
/// </summary>
public virtual void StartOutbound()
{
m_log.DebugFormat("[UDPBASE]: Starting outbound UDP loop");
m_logger.LogDebug("[UDPBASE]: Starting outbound UDP loop");
IsRunningOutbound = true;
}
@ -253,7 +250,7 @@ namespace OpenMetaverse
{
if (IsRunningInbound)
{
m_log.DebugFormat("[UDPBASE]: Stopping inbound UDP loop");
m_logger.LogDebug("[UDPBASE]: Stopping inbound UDP loop");
IsRunningInbound = false;
m_udpSocket.Close();
@ -262,7 +259,7 @@ namespace OpenMetaverse
public virtual void StopOutbound()
{
m_log.DebugFormat("[UDPBASE]: Stopping outbound UDP loop");
m_logger.LogDebug("[UDPBASE]: Stopping outbound UDP loop");
IsRunningOutbound = false;
}
@ -291,7 +288,7 @@ namespace OpenMetaverse
{
if (e.SocketErrorCode == SocketError.ConnectionReset)
{
m_log.Warn("[UDPBASE]: SIO_UDP_CONNRESET was ignored, attempting to salvage the UDP listener on port " + m_udpPort);
m_logger.LogWarning("[UDPBASE]: SIO_UDP_CONNRESET was ignored, attempting to salvage the UDP listener on port " + m_udpPort);
{
try
{
@ -310,12 +307,12 @@ namespace OpenMetaverse
catch (SocketException) { }
catch (ObjectDisposedException) { return; }
}
m_log.Warn("[UDPBASE]: Salvaged the UDP listener on port " + m_udpPort);
m_logger.LogWarning("[UDPBASE]: Salvaged the UDP listener on port " + m_udpPort);
}
}
catch (Exception e)
{
m_log.Error(
m_logger.LogError(
string.Format("[UDPBASE]: Error processing UDP begin receive {0}. Exception ", UdpReceives), e);
}
}
@ -363,7 +360,7 @@ namespace OpenMetaverse
}
catch (SocketException se)
{
m_log.Error(
m_logger.LogError(
string.Format(
"[UDPBASE]: Error processing UDP end receive {0}, socket error code {1}. Exception ",
UdpReceives, se.ErrorCode),
@ -372,7 +369,7 @@ namespace OpenMetaverse
catch(ObjectDisposedException) { }
catch (Exception e)
{
m_log.Error(
m_logger.LogError(
string.Format("[UDPBASE]: Error processing UDP end receive {0}. Exception ", UdpReceives), e);
}
finally
@ -400,7 +397,7 @@ namespace OpenMetaverse
}
catch (SocketException e)
{
m_log.WarnFormat("[UDPBASE]: sync send SocketException {0} {1}", buf.RemoteEndPoint, e.Message);
m_logger.LogWarning(e, $"[UDPBASE]: sync send SocketException {buf.RemoteEndPoint} {1}", buf.RemoteEndPoint);
}
catch (ObjectDisposedException) { }
}

View file

@ -31,7 +31,7 @@ using System.Linq;
using System.Text;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OMV = OpenMetaverse;

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OMV = OpenMetaverse;

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OMV = OpenMetaverse;

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OMV = OpenMetaverse;

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OMV = OpenMetaverse;

View file

@ -30,7 +30,7 @@ using System.Reflection;
using log4net;
using OMV = OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.BulletS
{

View file

@ -36,7 +36,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.BulletS
{

View file

@ -29,7 +29,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.Text;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
using Nini.Config;

View file

@ -30,7 +30,7 @@ using System.Text;
using OMV = OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.BulletS
{

View file

@ -25,15 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Xml;
using log4net;
using OMV = OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.BulletS
{
@ -41,7 +36,6 @@ namespace OpenSim.Region.PhysicsModule.BulletS
[Serializable]
public class BSPrim : BSPhysObject
{
protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[BULLETS PRIM]";
// _size is what the user passed. Scale is what we pass to the physics engine with the mesh.

View file

@ -31,7 +31,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OMV = OpenMetaverse;

View file

@ -71,7 +71,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
base.Destroy();
}
public override void link(OpenSim.Region.PhysicsModules.SharedBase.PhysicsActor obj)
public override void link(SharedBase.PhysicsActor obj)
{
BSPrimLinkable parent = obj as BSPrimLinkable;
if (parent != null)

View file

@ -30,7 +30,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;

View file

@ -24,12 +24,8 @@
* (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 System.Text;
using OMV = OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
namespace OpenSim.Region.PhysicsModule.BulletS
{

View file

@ -25,12 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenSim.Region.PhysicsModule.Meshing;
using OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet;

View file

@ -30,7 +30,7 @@ using System.Text;
using OpenSim.Framework;
using OpenSim.Region.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using Nini.Config;
using log4net;

View file

@ -24,16 +24,8 @@
* (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 System.Text;
using OpenSim.Framework;
using OpenSim.Region.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using Nini.Config;
using log4net;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;

View file

@ -30,7 +30,7 @@ using System.Text;
using OpenSim.Framework;
using OpenSim.Region.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using Nini.Config;
using log4net;

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using OpenMetaverse;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenSim.Region.PhysicsModule.Meshing;
public class Vertex : IComparable<Vertex>

View file

@ -29,7 +29,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using PrimMesher;
using OpenMetaverse;

View file

@ -30,7 +30,7 @@ using System.Reflection;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using System.Drawing;

View file

@ -28,7 +28,7 @@
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.POS
{

View file

@ -30,7 +30,7 @@ using System.Collections.Generic;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.POS
{

View file

@ -27,7 +27,7 @@
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using Microsoft.Extensions.Configuration;

View file

@ -34,7 +34,7 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using log4net;
namespace OpenSim.Region.PhysicsModule.ubOde

View file

@ -1,5 +1,5 @@
using OpenMetaverse;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using System;
using System.Runtime.CompilerServices;

View file

@ -42,7 +42,7 @@
using System;
using OpenMetaverse;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.ubOde
{

View file

@ -3,7 +3,7 @@
*/
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
using Microsoft.Extensions.Configuration;

View file

@ -32,7 +32,7 @@ using System.Runtime.CompilerServices;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
namespace OpenSim.Region.PhysicsModule.ubOde
{

View file

@ -32,7 +32,7 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using log4net;
using OpenMetaverse;

View file

@ -34,7 +34,7 @@ using System.Runtime.InteropServices;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
using Microsoft.Extensions.Configuration;

View file

@ -27,7 +27,7 @@
// Ubit Umarov 2012
using System;
using System.Collections.Generic;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
namespace OpenSim.Region.PhysicsModule.ubOde

View file

@ -25,15 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using OpenSim.Region.PhysicsModules.SharedBase;
using PrimMesher;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace OpenSim.Region.PhysicsModule.ubODEMeshing
{

View file

@ -29,8 +29,7 @@
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet;
using OpenSim.Region.PhysicsModule.SharedBase;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using System.Drawing;

View file

@ -0,0 +1,21 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app
USER app
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG configuration=Release
WORKDIR /src
COPY ["Source/OpenSim.Server.GridServer/OpenSim.Server.GridServer.csproj", "Source/OpenSim.Server.GridServer/"]
RUN dotnet restore "Source/OpenSim.Server.GridServer/OpenSim.Server.GridServer.csproj"
COPY . .
WORKDIR "/src/Source/OpenSim.Server.GridServer"
RUN dotnet build "OpenSim.Server.GridServer.csproj" -c $configuration -o /app/build
FROM build AS publish
ARG configuration=Release
RUN dotnet publish "OpenSim.Server.GridServer.csproj" -c $configuration -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "OpenSim.Server.GridServer.dll"]

View file

@ -29,39 +29,40 @@ using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
namespace OpenSim.Server.GridServer
{
public class GridServer
public partial class GridServer
{
private bool m_NoVerifyCertChain = false;
private bool m_NoVerifyCertHostname = false;
private OpenSimServer m_baseServer = null;
private OpenSimServer m_baseServer;
protected List<IServiceConnector> m_ServiceConnectors = new();
protected Dictionary<string,uint> portMapping = new();
private readonly IServiceProvider m_serviceProvider;
protected Dictionary<string,ServiceEntry> serviceList = new();
private readonly IComponentContext m_context;
private readonly ILogger<GridServer> m_logger;
private readonly IConfiguration m_configuration;
public GridServer(
IServiceProvider serviceProvider,
IComponentContext componentContext,
IConfiguration configuration,
ILogger<GridServer> logger,
OpenSimServer openSimServer
)
{
m_serviceProvider = serviceProvider;
m_context = componentContext;
m_configuration = configuration;
m_logger = logger;
m_baseServer = openSimServer;
@ -97,7 +98,7 @@ namespace OpenSim.Server.GridServer
{
using (StreamReader readFile = File.OpenText(fileName))
{
string currentLine;
string? currentLine;
while ((currentLine = readFile.ReadLine()) is not null)
{
m_logger.LogInformation("[!]" + currentLine);
@ -122,32 +123,27 @@ namespace OpenSim.Server.GridServer
m_baseServer.Startup();
if (LoadConfiguration() <= 0)
return 1;
using (var scope = m_serviceProvider.CreateScope())
if (LoadServices() <= 0)
{
foreach (var servicesConnector in scope.ServiceProvider.GetServices<IServiceConnector>())
throw new Exception("GridServer.Startup - No Services Defined");
}
foreach (var kvp in serviceList)
{
try
{
uint port;
string typeName = servicesConnector.GetType().Name;
var service = m_context.ResolveNamed<IServiceConnector>(kvp.Value.ModuleName);
var server = MainServer.Instance;
// if (kvp.Value.Port != 0)
// server = MainServer.GetHttpServer()
m_logger.LogInformation($"Searching for {typeName} as {servicesConnector.ConfigName}");
if (portMapping.TryGetValue(typeName, out port) == true)
{
IHttpServer server = MainServer.Instance;
if (port != 0)
server = MainServer.GetHttpServer(scope, port);
servicesConnector.Initialize(server);
m_ServiceConnectors.Add(servicesConnector);
}
else
{
m_logger.LogError($"Configuration for {typeName} not found.");
}
service.Initialize(server);
m_ServiceConnectors.Add(service);
}
catch (Exception e)
{
m_logger.LogError(e, $"Configuration for {kvp.Key} not found.");
}
}
// if (friendlyName == "LLLoginServiceInConnector")
@ -181,76 +177,26 @@ namespace OpenSim.Server.GridServer
return 0;
}
private int LoadConfiguration()
private int LoadServices()
{
var startupConfig = m_configuration.GetSection("Startup");
var connList = startupConfig.GetValue<string>("ServiceConnectors", string.Empty);
var registryLocation = startupConfig.GetValue<string>("RegistryLocation", ".");
var servicesConfig = m_configuration.GetSection("ServiceList");
List<string> servicesList = new();
if (!string.IsNullOrEmpty(connList))
servicesList.Add(connList);
foreach (var k in servicesConfig.AsEnumerable())
if (servicesConfig.Exists() is false)
{
string[] keyparts = k.Key.Split(":");
if ((keyparts.Length > 1) && (keyparts[0] == "ServiceList"))
{
string v = servicesConfig.GetValue<string>(keyparts[1]);
if (!string.IsNullOrEmpty(v))
servicesList.Add(v);
}
throw new Exception("LoadConfiguration: No ServiceList found");
}
foreach (string c in servicesList)
var services = servicesConfig.AsEnumerable();
foreach (var kvp in services)
{
if (string.IsNullOrEmpty(c))
if ((kvp.Key == "ServiceList") && (kvp.Value == null))
continue;
string configName = string.Empty;
string conn = c;
uint port = 0;
string[] split1 = conn.Split(new char[] { '/' });
if (split1.Length > 1)
{
conn = split1[1];
string[] split2 = split1[0].Split(new char[] { '@' });
if (split2.Length > 1)
{
configName = split2[0];
port = Convert.ToUInt32(split2[1]);
}
else
{
port = Convert.ToUInt32(split1[0]);
}
}
string[] parts = conn.Split(new char[] { ':' });
string moduleName = string.Empty;
string friendlyName = parts[0];
if (parts.Length > 1)
{
moduleName = parts[0];
friendlyName = parts[1];
}
if (portMapping.ContainsKey(friendlyName))
{
m_logger.LogInformation($"Loading configuration, {friendlyName} already found");
}
else
{
portMapping.Add(friendlyName, port);
}
string serviceName = kvp.Key.Split(new char[] { ':' })[1];
ServiceEntry entry = new ServiceEntry(kvp.Value);
serviceList.Add(serviceName, entry);
}
return 1;
return serviceList.Count;
}
public void Work()

View file

@ -0,0 +1,20 @@
namespace OpenSim.Server.GridServer
{
public partial class GridServer
{
public struct ServiceEntry
{
public ServiceEntry(uint port, string module) { Port = port; ModuleName = module; }
public ServiceEntry(string entry)
{
string[] split = entry.Split(new char[] { ':' });
Port = Convert.ToUInt32(split[0]);
ModuleName = string.IsNullOrEmpty(split[1]) ? string.Empty : split[1];
}
public uint Port { get; }
public string ModuleName { get; }
}
}
}

View file

@ -34,11 +34,11 @@ namespace OpenSim.Server.Handlers
.AsImplementedInterfaces();
builder.RegisterType<AssetServiceConnector>()
.Named<IServiceConnector>("AssetService")
.Named<IServiceConnector>("AssetServiceConnector")
.AsImplementedInterfaces();
builder.RegisterType<AuthenticationServiceConnector>()
.Named<IServiceConnector>("AuthenticationService")
.Named<IServiceConnector>("AuthenticationServiceConnector")
.AsImplementedInterfaces();
builder.RegisterType<OpenIdServerConnector>()
@ -66,7 +66,7 @@ namespace OpenSim.Server.Handlers
.AsImplementedInterfaces();
builder.RegisterType<FriendsServiceConnector>()
.Named<IServiceConnector>("FriendsService")
.Named<IServiceConnector>("GridInfoServerInConnector")
.AsImplementedInterfaces();
builder.RegisterType<GridInfoServerInConnector>()
@ -74,7 +74,7 @@ namespace OpenSim.Server.Handlers
.AsImplementedInterfaces();
builder.RegisterType<GridServiceConnector>()
.Named<IServiceConnector>("GridService")
.Named<IServiceConnector>("GridServiceConnector")
.AsImplementedInterfaces();
builder.RegisterType<GridUserServiceConnector>()
@ -106,7 +106,7 @@ namespace OpenSim.Server.Handlers
.AsImplementedInterfaces();
builder.RegisterType<XInventoryInConnector>()
.Named<IServiceConnector>("InventoryService")
.Named<IServiceConnector>("XInventoryInConnector")
.AsImplementedInterfaces();
// builder.RegisterType<LandServiceInConnector>()

View file

@ -28,7 +28,6 @@
using OpenMetaverse;
using OpenSim.Services.Interfaces;
using System.Reflection;
using OpenSim.Data;
using Microsoft.Extensions.Configuration;

View file

@ -31,7 +31,6 @@ using System.Text;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Data;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
@ -49,13 +48,11 @@ namespace OpenSim.Services.GridService
private const string _ConfigName = "GridService";
private bool m_DeleteOnUnregister = true;
private static GridService m_RootInstance = null;
protected static HypergridLinker m_HypergridLinker;
protected HypergridLinker m_HypergridLinker;
protected IAuthenticationService m_AuthenticationService = null;
protected IAuthenticationService m_AuthenticationService;
protected bool m_AllowDuplicateNames = false;
protected bool m_AllowHypergridMapSearch = false;
protected bool m_suppressConsoleCommands = false;
protected readonly IComponentContext m_context;
protected readonly IConfiguration m_configuration;
@ -104,70 +101,57 @@ namespace OpenSim.Services.GridService
m_AllowDuplicateNames = gridConfig.GetValue<bool>("AllowDuplicateNames", m_AllowDuplicateNames);
m_AllowHypergridMapSearch = gridConfig.GetValue<bool>("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
// This service is also used locally by a simulator running in grid mode. This switches prevents
// inappropriate console commands from being registered
m_suppressConsoleCommands = gridConfig.GetValue<bool>("SuppressConsoleCommands", m_suppressConsoleCommands);
}
m_Database.Initialize(connString, realm);
m_logger.LogDebug("[GRID SERVICE]: Starting...");
if (m_RootInstance == null)
{
m_RootInstance = this;
MainConsole.Instance.Commands.AddCommand("Regions", true,
"deregister region id",
"deregister region id <region-id>+",
"Deregister a region manually.",
String.Empty,
HandleDeregisterRegion);
if (!m_suppressConsoleCommands && MainConsole.Instance != null)
{
MainConsole.Instance.Commands.AddCommand("Regions", true,
"deregister region id",
"deregister region id <region-id>+",
"Deregister a region manually.",
String.Empty,
HandleDeregisterRegion);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show regions",
"show regions",
"Show details on all regions",
String.Empty,
HandleShowRegions);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show regions",
"show regions",
"Show details on all regions",
String.Empty,
HandleShowRegions);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region name",
"show region name <Region name>",
"Show details on a region",
String.Empty,
HandleShowRegion);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region name",
"show region name <Region name>",
"Show details on a region",
String.Empty,
HandleShowRegion);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region at",
"show region at <x-coord> <y-coord>",
"Show details on a region at the given co-ordinate.",
"For example, show region at 1000 1000",
HandleShowRegionAt);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region at",
"show region at <x-coord> <y-coord>",
"Show details on a region at the given co-ordinate.",
"For example, show region at 1000 1000",
HandleShowRegionAt);
MainConsole.Instance.Commands.AddCommand("General", true,
"show grid size",
"show grid size",
"Show the current grid size (excluding hyperlink references)",
String.Empty,
HandleShowGridSize);
MainConsole.Instance.Commands.AddCommand("General", true,
"show grid size",
"show grid size",
"Show the current grid size (excluding hyperlink references)",
String.Empty,
HandleShowGridSize);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"set region flags",
"set region flags <Region name> <flags>",
"Set database flags for region",
String.Empty,
HandleSetFlags);
SetExtraServiceURLs(config);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"set region flags",
"set region flags <Region name> <flags>",
"Set database flags for region",
String.Empty,
HandleSetFlags);
}
if (!m_suppressConsoleCommands)
SetExtraServiceURLs(config);
m_HypergridLinker = new HypergridLinker(config, this, m_Database);
}
m_HypergridLinker = new HypergridLinker(config, this, m_Database);
}
private void SetExtraServiceURLs(IConfiguration config)

View file

@ -27,11 +27,8 @@
using System.Collections;
using System.Net;
using System.Reflection;
using System.Xml;
using Nini.Config;
using log4net;
using OpenSim.Framework;
using OpenSim.Data;
using OpenSim.Server.Base;
@ -39,31 +36,39 @@ using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.Hypergrid;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Services.GridService
{
public class HypergridLinker : IHypergridLinker
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static uint m_autoMappingX = 0;
private static uint m_autoMappingY = 0;
private static bool m_enableAutoMapping = false;
protected IRegionData m_Database;
protected GridService m_GridService;
protected IAssetService m_AssetService;
protected GatekeeperServiceConnector m_GatekeeperConnector;
protected UUID m_ScopeID = UUID.Zero;
// protected bool m_Check4096 = true;
protected string m_MapTileDirectory = string.Empty;
protected GridInfo m_ThisGridInfo;
public HypergridLinker(IConfiguration config, GridService gridService, IRegionData db)
protected readonly IConfiguration m_configuration;
protected readonly ILogger<HypergridLinker> m_logger;
protected readonly IRegionData m_Database;
protected readonly IGridService m_GridService;
public HypergridLinker(
IConfiguration config,
ILogger<HypergridLinker> logger,
IGridService gridService,
IRegionData db)
{
m_configuration = config;
m_logger = logger;
var gridConfig = config.GetSection("GridService");
if (gridConfig.Exists() is false)
return;
@ -73,9 +78,9 @@ namespace OpenSim.Services.GridService
m_Database = db;
m_GridService = gridService;
m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());
m_logger.LogDebug($"[HYPERGRID LINKER]: Starting with db {db.GetType()}");
string assetService = gridConfig.GetValue("AssetService", string.Empty);
string? assetService = gridConfig.GetValue("AssetService", string.Empty);
object[] args = new object[] { config };
@ -94,11 +99,11 @@ namespace OpenSim.Services.GridService
if(!m_ThisGridInfo.HasHGConfig)
throw new Exception("missing HyperGrid configuration");
m_log.DebugFormat("[HYPERGRID LINKER]: Local Gatekeeper: {0}", m_ThisGridInfo.GateKeeperURL);
m_logger.LogDebug($"[HYPERGRID LINKER]: Local Gatekeeper: {m_ThisGridInfo.GateKeeperURL}");
m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");
m_logger.LogDebug("[HYPERGRID LINKER]: Loaded all services...");
if (!string.IsNullOrEmpty(m_MapTileDirectory))
{
@ -108,7 +113,7 @@ namespace OpenSim.Services.GridService
}
catch (Exception e)
{
m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
m_logger.LogWarning(e, $"[HYPERGRID LINKER]: Could not create map tile storage directory {m_MapTileDirectory}");
m_MapTileDirectory = string.Empty;
}
}
@ -135,44 +140,46 @@ namespace OpenSim.Services.GridService
#region Link Region
// from map search
public GridRegion LinkRegion(UUID scopeID, string regionDescriptor)
public GridRegion? LinkRegion(UUID scopeID, string regionDescriptor)
{
string reason = string.Empty;
uint xloc = Util.RegionToWorldLoc((uint)Random.Shared.Next(0, Int16.MaxValue));
return TryLinkRegionToCoords(scopeID, regionDescriptor, (int)xloc, 0, out reason);
}
public GridRegion LinkRegion(UUID scopeID, RegionURI rurl)
public GridRegion? LinkRegion(UUID scopeID, RegionURI rurl)
{
if(!rurl.IsValid)
return null;
if (rurl.IsLocalGrid)
{
m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
m_logger.LogInformation($"[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
return null;
}
int xloc = Random.Shared.Next(0, short.MaxValue) << 8;
if(TryCreateLinkImpl(scopeID, xloc, 0, rurl, UUID.Zero, out GridRegion regInfo))
if(TryCreateLinkImpl(scopeID, xloc, 0, rurl, UUID.Zero, out GridRegion? regInfo))
return regInfo;
return null;
}
private static readonly IPEndPoint dummyIP = new IPEndPoint(0,0);
private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, RegionURI rurl, UUID ownerID, out GridRegion regInfo)
private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, RegionURI rurl, UUID ownerID, out GridRegion? regInfo)
{
m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
rurl.HostUrl, rurl.RegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
m_logger.LogInformation(
$"[HYPERGRID LINKER]: Link to {rurl.HostUrl} {rurl.RegionName}, " +
$" in <{Util.WorldToRegionLoc((uint)xloc)},{Util.WorldToRegionLoc((uint)yloc)}>");
// Check for free coordinates
GridRegion region = m_GridService.GetRegionByPosition(scopeID, xloc, yloc);
if (region != null)
{
m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}",
Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc),
region.RegionName, region.RegionID);
m_logger.LogWarning(
$"[HYPERGRID LINKER]: Coordinates <{Util.WorldToRegionLoc((uint)xloc)},{Util.WorldToRegionLoc((uint)yloc)}> " +
$"are already occupied by region {region.RegionName} with uuid {region.RegionID}");
regInfo = null;
return false;
}
@ -198,19 +205,20 @@ namespace OpenSim.Services.GridService
string imageURL = string.Empty;
int sizeX = (int)Constants.RegionSize;
int sizeY = (int)Constants.RegionSize;
if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out string reason, out sizeX, out sizeY))
return false;
if (regionID.IsZero())
{
m_log.Warn("[HYPERGRID LINKER]: Unable to link region: " + reason);
m_logger.LogWarning("[HYPERGRID LINKER]: Unable to link region: " + reason);
return false;
}
region = m_GridService.GetRegionByUUID(scopeID, regionID);
if (region != null)
{
m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
m_logger.LogDebug("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
regInfo = region;
return true;
@ -225,7 +233,7 @@ namespace OpenSim.Services.GridService
else
regInfo.RegionName = externalName;
m_log.DebugFormat("[HYPERGRID LINKER]: naming linked region {0}, handle {1}", regInfo.RegionName, handle.ToString());
m_logger.LogDebug($"[HYPERGRID LINKER]: naming linked region {regInfo.RegionName}, handle {handle}");
// Get the map image
regInfo.TerrainImage = GetMapImage(regionID, imageURL);
@ -234,8 +242,11 @@ namespace OpenSim.Services.GridService
regInfo.RegionSecret = handle.ToString();
AddHyperlinkRegion(regInfo, handle);
m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}",
regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage);
m_logger.LogInformation(
$"[HYPERGRID LINKER]: Successfully linked to region {regInfo.RegionName} " +
$"at <{Util.WorldToRegionLoc((uint)regInfo.RegionLocX)},{Util.WorldToRegionLoc((uint)regInfo.RegionLocY)}> " +
$"with image {regInfo.TerrainImage}");
return true;
}
@ -288,12 +299,13 @@ namespace OpenSim.Services.GridService
private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
{
m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
m_logger.LogInformation(
$"[HYPERGRID LINKER]: Link to {(serverURI ?? externalHostName + ":" + externalPort)} {1}, in <{2},{3}>",
(serverURI ?? externalHostName + ":" + externalPort),
remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
reason = string.Empty;
Uri uri = null;
Uri? uri = null;
regInfo = new GridRegion();
if (externalPort > 0)
@ -326,7 +338,7 @@ namespace OpenSim.Services.GridService
if(IsLocalGrid(regInfo.ServerURI))
{
m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
m_logger.LogInformation($"[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
reason = "Cannot hyperlink to regions on the same grid";
return false;
}
@ -335,9 +347,10 @@ namespace OpenSim.Services.GridService
GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);
if (region != null)
{
m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}",
Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY),
region.RegionName, region.RegionID);
m_logger.LogWarning(
$"[HYPERGRID LINKER]: Coordinates <{Util.WorldToRegionLoc((uint)regInfo.RegionLocX)},{Util.WorldToRegionLoc((uint)regInfo.RegionLocY)}> " +
$"are already occupied by region {region.RegionName} with uuid {region.RegionID}");
reason = "Coordinates are already in use";
return false;
}
@ -348,7 +361,7 @@ namespace OpenSim.Services.GridService
}
catch (Exception e)
{
m_log.Warn("[HYPERGRID LINKER]: Wrong format for link-region: " + e.Message);
m_logger.LogWarning("[HYPERGRID LINKER]: Wrong format for link-region: " + e.Message);
reason = "Internal error";
return false;
}
@ -365,7 +378,7 @@ namespace OpenSim.Services.GridService
if (regionID.IsZero())
{
m_log.Warn("[HYPERGRID LINKER]: Unable to link region");
m_logger.LogWarning("[HYPERGRID LINKER]: Unable to link region");
reason = "Remote region could not be found";
return false;
}
@ -373,8 +386,10 @@ namespace OpenSim.Services.GridService
region = m_GridService.GetRegionByUUID(scopeID, regionID);
if (region != null)
{
m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
m_logger.LogDebug(
$"[HYPERGRID LINKER]: Region already exists in coordinates " +
$"<{Util.WorldToRegionLoc((uint)region.RegionLocX)},{Util.WorldToRegionLoc((uint)region.RegionLocY)}>");
regInfo = region;
return true;
}
@ -388,7 +403,7 @@ namespace OpenSim.Services.GridService
// {
// //RemoveHyperlinkRegion(regInfo.RegionID);
// reason = "Region is too far (" + x + ", " + y + ")";
// m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")");
// m_logger.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")");
// //return false;
// }
@ -401,7 +416,7 @@ namespace OpenSim.Services.GridService
else
regInfo.RegionName = externalName;
m_log.DebugFormat("[HYPERGRID LINKER]: naming linked region {0}, handle {1}", regInfo.RegionName, handle.ToString());
m_logger.LogDebug($"[HYPERGRID LINKER]: naming linked region {regInfo.RegionName}, handle {handle}");
// Get the map image
regInfo.TerrainImage = GetMapImage(regionID, imageURL);
@ -410,15 +425,19 @@ namespace OpenSim.Services.GridService
regInfo.RegionSecret = handle.ToString();
AddHyperlinkRegion(regInfo, handle);
m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}",
regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage);
m_logger.LogInformation(
$"[HYPERGRID LINKER]: Successfully linked to region {regInfo.RegionName} at " +
$"<{Util.WorldToRegionLoc((uint)regInfo.RegionLocX)},{Util.WorldToRegionLoc((uint)regInfo.RegionLocY)}> " +
$"with image {regInfo.TerrainImage}");
return true;
}
public bool TryUnlinkRegion(string mapName)
{
m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName);
GridRegion regInfo = null;
m_logger.LogDebug($"[HYPERGRID LINKER]: Request to unlink {mapName}");
GridRegion? regInfo = null;
List<RegionData> regions = m_Database.Get(Util.EscapeForLike(mapName), m_ScopeID);
if (regions != null && regions.Count > 0)
@ -439,7 +458,7 @@ namespace OpenSim.Services.GridService
}
else
{
m_log.InfoFormat("[HYPERGRID LINKER]: Region {0} not found", mapName);
m_logger.LogInformation($"[HYPERGRID LINKER]: Region {mapName} not found");
return false;
}
}
@ -732,25 +751,24 @@ namespace OpenSim.Services.GridService
}
catch (Exception e)
{
m_log.Error(e.ToString());
m_logger.LogError(e, "LoadXmlLinkFile: ");
}
}
private void ReadLinkFromConfig(IConfig config)
private void ReadLinkFromConfig(IConfigurationSection config)
{
GridRegion regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
string? externalHostName;
uint realXLoc, realYLoc;
xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
externalHostName = config.GetString("externalHostName", "");
realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
xloc = Convert.ToUInt32(config.GetValue("xloc", "0"));
yloc = Convert.ToUInt32(config.GetValue("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetValue("externalPort", "0"));
externalHostName = config.GetValue("externalHostName", "");
realXLoc = Convert.ToUInt32(config.GetValue("real-xloc", "0"));
realYLoc = Convert.ToUInt32(config.GetValue("real-yloc", "0"));
if (m_enableAutoMapping)
{
@ -768,14 +786,13 @@ namespace OpenSim.Services.GridService
if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc,
string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
{
regInfo.RegionName = config.GetString("localName", "");
regInfo.RegionName = config.GetValue("localName", "");
}
else
MainConsole.Instance.Output("Unable to link " + externalHostName + ": " + reason);
}
}
private void LinkRegionCmdUsage()
{
MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]");
@ -790,6 +807,5 @@ namespace OpenSim.Services.GridService
}
#endregion
}
}

View file

@ -48,8 +48,8 @@ namespace OpenSim.Services.HypergridService
public class HGFSAssetService : FSAssetConnector, IAssetService
{
private string m_HomeURL;
private IUserAccountService m_UserAccountService;
private readonly IUserAccountService m_UserAccountService;
private UserAccountCache m_Cache;
private AssetPermissions m_AssetPerms;
@ -58,6 +58,7 @@ namespace OpenSim.Services.HypergridService
IComponentContext componentContext,
IConfiguration config,
ILogger<HGFSAssetService> logger,
IUserAccountService accountService,
IFSAssetDataPlugin dataPlugin
) : base(componentContext, config, logger, dataPlugin)
{
@ -66,14 +67,16 @@ namespace OpenSim.Services.HypergridService
if (assetConfig.Exists() is false)
throw new Exception("No HGAssetService configuration");
string? userAccountsDll = assetConfig.GetValue("UserAccountsService", string.Empty);
if (string.IsNullOrEmpty(userAccountsDll))
throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
m_UserAccountService = accountService;
Object[] args = new Object[] { config };
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
if (m_UserAccountService == null)
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
// string? userAccountsDll = assetConfig.GetValue("UserAccountsService", string.Empty);
// if (string.IsNullOrEmpty(userAccountsDll))
// throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
// Object[] args = new Object[] { config };
// m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
// if (m_UserAccountService == null)
// throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
new string[] { "Startup", "Hypergrid", _ConfigName }, string.Empty);

View file

@ -24,21 +24,16 @@
* (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 System.IO;
using System.Reflection;
using System.Xml;
using Nini.Config;
using log4net;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Serialization.External;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Services.AssetService;
namespace OpenSim.Services.HypergridService
{
@ -49,10 +44,7 @@ namespace OpenSim.Services.HypergridService
/// </summary>
public class HGRemoteAssetService : IAssetService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private const string _ConfigName = "HGAssetService";
private string m_HomeURL;
private IUserAccountService m_UserAccountService;
private IAssetService m_assetConnector;
@ -61,45 +53,55 @@ namespace OpenSim.Services.HypergridService
private AssetPermissions m_AssetPerms;
public HGRemoteAssetService(IConfiguration config, string configName)
private readonly IComponentContext m_context;
private readonly IConfiguration m_configuration;
private readonly ILogger<HGRemoteAssetService> m_logger;
public HGRemoteAssetService(
IComponentContext componentContext,
IConfiguration config,
ILogger<HGRemoteAssetService> logger
)
{
m_log.Debug("[HGRemoteAsset Service]: Starting");
IConfig assetConfig = config.Configs[configName];
if (assetConfig == null)
m_context = componentContext;
m_configuration = config;
m_logger = logger;
m_logger.LogDebug("[HGRemoteAsset Service]: Starting");
var assetConfig = config.GetSection(_ConfigName);
if (assetConfig.Exists() is false)
throw new Exception("No HGAssetService configuration");
Object[] args = new Object[] { config };
string assetConnectorDll = assetConfig.GetString("AssetConnector", String.Empty);
if (assetConnectorDll.Length == 0)
string? assetConnectorService = assetConfig.GetValue("AssetConnector", String.Empty);
if (string.IsNullOrEmpty(assetConnectorService))
throw new Exception("Please specify AssetConnector in HGAssetService configuration");
m_assetConnector = ServerUtils.LoadPlugin<IAssetService>(assetConnectorDll, args);
m_assetConnector = m_context.ResolveNamed<IAssetService>(assetConnectorService);
if (m_assetConnector == null)
throw new Exception(String.Format("Unable to create AssetConnector from {0}", assetConnectorDll));
throw new Exception($"Unable to create AssetConnector from {assetConnectorService}");
string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty);
if (userAccountsDll.Length == 0)
string? userAccountsService = assetConfig.GetValue("UserAccountsService", string.Empty);
if (string.IsNullOrEmpty(userAccountsService))
throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
m_UserAccountService = m_context.ResolveNamed<IUserAccountService>(userAccountsService);
if (m_UserAccountService == null)
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsService));
m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
new string[] { "Startup", "Hypergrid", configName }, string.Empty);
if (m_HomeURL.Length == 0)
var sections = new string[] { "Startup", "Hypergrid", _ConfigName };
m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", sections, string.Empty);
if (string.IsNullOrEmpty(m_HomeURL))
throw new Exception("[HGAssetService] No HomeURI specified");
m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
// Permissions
m_AssetPerms = new AssetPermissions(assetConfig);
}
#region IAssetService overrides
public AssetBase Get(string id)
public AssetBase? Get(string id)
{
AssetBase asset = m_assetConnector.Get(id);
@ -117,12 +119,12 @@ namespace OpenSim.Services.HypergridService
return asset;
}
public AssetBase Get(string id, string ForeignAssetService, bool dummy)
public AssetBase? Get(string id, string ForeignAssetService, bool dummy)
{
return null;
}
public AssetMetadata GetMetadata(string id)
public AssetMetadata? GetMetadata(string id)
{
AssetMetadata meta = m_assetConnector.GetMetadata(id);
@ -134,9 +136,9 @@ namespace OpenSim.Services.HypergridService
return meta;
}
public byte[] GetData(string id)
public byte[]? GetData(string id)
{
AssetBase asset = Get(id);
AssetBase? asset = Get(id);
if (asset == null)
return null;
@ -253,7 +255,7 @@ namespace OpenSim.Services.HypergridService
return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero));
}
public AssetBase GetCached(string id)
public AssetBase? GetCached(string id)
{
return Get(id);
}

View file

@ -25,20 +25,19 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using OpenMetaverse;
using log4net;
using Nini.Config;
using System.Reflection;
using OpenSim.Services.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Services.InventoryService;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Server.Base;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace OpenSim.Services.HypergridService
{
/// <summary>
@ -50,51 +49,44 @@ namespace OpenSim.Services.HypergridService
/// </summary>
public class HGSuitcaseInventoryService : XInventoryService, IInventoryService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
// private string m_HomeURL;
private IUserAccountService m_UserAccountService;
private IAvatarService m_AvatarService;
// private UserAccountCache m_Cache;
private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>();
private ExpiringCache<UUID, AvatarAppearance> m_Appearances = new ExpiringCache<UUID, AvatarAppearance>();
public HGSuitcaseInventoryService(IConfiguration config, string configName)
: base(config, configName)
public HGSuitcaseInventoryService(
IComponentContext componentContext,
IConfiguration config,
ILogger<HGSuitcaseInventoryService> logger)
: base(componentContext, config, logger)
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Starting with config name {0}", configName);
if (configName != string.Empty)
m_ConfigName = configName;
m_logger.LogDebug($"[HG SUITCASE INVENTORY SERVICE]: Starting with config name {_ConfigName}");
if (m_Database == null)
m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: m_Database is null!");
m_logger.LogError("[HG SUITCASE INVENTORY SERVICE]: m_Database is null!");
//
// Try reading the [InventoryService] section, if it exists
//
IConfig invConfig = config.Configs[m_ConfigName];
if (invConfig != null)
var invConfig = config.GetSection(_ConfigName);
if (invConfig.Exists() is true)
{
string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
if (userAccountsDll.Length == 0)
string? userAccountsService = invConfig.GetValue("UserAccountsService", string.Empty);
if (string.IsNullOrEmpty(userAccountsService) is true)
throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
Object[] args = new Object[] { config };
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
m_UserAccountService = m_context.ResolveNamed<IUserAccountService>(userAccountsService);
if (m_UserAccountService == null)
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
throw new Exception($"Unable to create UserAccountService from {userAccountsService}");
string avatarDll = invConfig.GetString("AvatarService", string.Empty);
if (avatarDll.Length == 0)
string? avatarService = invConfig.GetValue("AvatarService", string.Empty);
if (string.IsNullOrEmpty(avatarService) is true)
throw new Exception("Please specify AvatarService in HGInventoryService configuration");
m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarDll, args);
m_AvatarService = m_context.ResolveNamed<IAvatarService>(avatarService);
if (m_AvatarService == null)
throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
throw new Exception($"Unable to create m_AvatarService from {avatarService}");
// m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty);
@ -102,7 +94,7 @@ namespace OpenSim.Services.HypergridService
// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
}
m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Starting...");
m_logger.LogDebug("[HG SUITCASE INVENTORY SERVICE]: Starting...");
}
public override bool CreateUserInventory(UUID principalID)
@ -117,7 +109,7 @@ namespace OpenSim.Services.HypergridService
if (suitcase == null)
{
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for inventory skeleton", principalID);
m_logger.LogWarning($"[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {principalID} when looking for inventory skeleton");
return null;
}
@ -139,14 +131,14 @@ namespace OpenSim.Services.HypergridService
public override InventoryFolderBase GetRootFolder(UUID principalID)
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
m_logger.LogDebug($"[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {principalID}");
// Let's find out the local root folder
XInventoryFolder root = GetRootXFolder(principalID);
if (root == null)
{
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID);
m_logger.LogWarning($"[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {principalID}");
return null;
}
@ -155,13 +147,14 @@ namespace OpenSim.Services.HypergridService
if (suitcase == null)
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID);
m_logger.LogDebug($"[HG SUITCASE INVENTORY SERVICE]: User {principalID} does not have a Suitcase folder. Creating it...");
// Create the My Suitcase folder under the user's root folder.
// In the DB we tag it as type 100, but we use type 8 (Folder) outside, as this affects the sort order.
suitcase = CreateFolder(principalID, root.folderID, (int)FolderType.Suitcase, InventoryFolderBase.SUITCASE_FOLDER_NAME);
if (suitcase == null)
{
m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
m_logger.LogError("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
return null;
}
@ -175,7 +168,8 @@ namespace OpenSim.Services.HypergridService
protected void CreateSystemFolders(UUID principalID, UUID rootID)
{
m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase...");
m_logger.LogDebug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase...");
XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootID);
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Animation) return true; return false; }))
@ -216,12 +210,12 @@ namespace OpenSim.Services.HypergridService
public override InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
{
//m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
m_logger.LogDebug($"[HG INVENTORY SERVICE]: GetFolderForType for {principalID} {type}");
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
if (suitcase == null)
{
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for child type folder {1}", principalID, type);
m_logger.LogWarning($"[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {principalID} when looking for child type folder {type}");
return null;
}
@ -231,13 +225,13 @@ namespace OpenSim.Services.HypergridService
if (folders.Length == 0)
{
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID);
m_logger.LogWarning($"[HG SUITCASE INVENTORY SERVICE]: Found no folder for type {type} for user {principalID}");
return null;
}
m_log.DebugFormat(
"[HG SUITCASE INVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}",
folders[0].folderName, folders[0].folderID, type, principalID);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: Found folder {folders[0].folderName} {folders[0].folderID} " +
$"for type {type} for user {principalID}");
return ConvertToOpenSim(folders[0]);
}
@ -248,7 +242,10 @@ namespace OpenSim.Services.HypergridService
if (!IsWithinSuitcaseTree(principalID, folderID))
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {folderID} " +
$"(user {principalID}) is not within Suitcase tree");
return new InventoryCollection();
}
@ -256,7 +253,7 @@ namespace OpenSim.Services.HypergridService
if (coll == null)
{
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Something wrong with user {0}'s suitcase folder", principalID);
m_logger.LogWarning("[HG SUITCASE INVENTORY SERVICE]: Something wrong with user {0}'s suitcase folder", principalID);
coll = new InventoryCollection();
}
return coll;
@ -268,7 +265,10 @@ 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} (user {1}) is not within Suitcase tree", folderID, principalID);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {folderID} " +
$"(user {principalID}) is not within Suitcase tree");
return new List<InventoryItemBase>();
}
@ -283,7 +283,10 @@ namespace OpenSim.Services.HypergridService
if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {folder.ParentID} " +
$"(user {folder.Owner}) is not within Suitcase tree");
return false;
}
@ -305,8 +308,11 @@ 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} (user {2}) is not within Suitcase tree", folder.Name, folder.ID, folder.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {folder.Name}/{folder.ID} " +
$"(user {folder.Owner}) is not within Suitcase tree");
return false;
}
// For all others
@ -317,13 +323,19 @@ namespace OpenSim.Services.HypergridService
{
if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {folder.ID} "+
$"(user {folder.Owner}) is not within Suitcase tree");
return false;
}
if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {folder.ParentID} " +
$"(user {folder.Owner}) is not within Suitcase tree");
return false;
}
@ -348,7 +360,10 @@ 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} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {item.Folder} " +
$"(user {item.Owner}) is not within Suitcase tree");
return false;
}
@ -361,7 +376,10 @@ namespace OpenSim.Services.HypergridService
{
if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {item.Folder} " +
$"(user {item.Owner}) is not within Suitcase tree");
return false;
}
@ -377,7 +395,10 @@ namespace OpenSim.Services.HypergridService
{
if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {item.Folder} " +
$"(user {item.Owner}) is not within Suitcase tree");
return false;
}
}
@ -388,7 +409,10 @@ namespace OpenSim.Services.HypergridService
InventoryItemBase originalItem = base.GetItem(item.Owner, item.ID);
if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder))
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {item.Folder} " +
$"(user {item.Owner}) is not within Suitcase tree");
return false;
}
}
@ -403,18 +427,19 @@ namespace OpenSim.Services.HypergridService
public override InventoryItemBase GetItem(UUID principalID, UUID itemID)
{
InventoryItemBase it = base.GetItem(principalID, itemID);
InventoryItemBase? it = base.GetItem(principalID, itemID);
if (it == null)
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve item {0}",
itemID);
m_logger.LogDebug($"[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve item {itemID}");
return null;
}
if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID))
{
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);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: GetItem: item {it.Name}/{it.ID} " +
$"(folder {it.Folder}) (user {it.Owner}) is not within Suitcase tree or Appearance");
return null;
}
@ -430,14 +455,16 @@ namespace OpenSim.Services.HypergridService
public new InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
{
InventoryFolderBase f = base.GetFolder(principalID, folderID);
InventoryFolderBase? f = base.GetFolder(principalID, folderID);
if (f != null)
{
if (!IsWithinSuitcaseTree(f.Owner, 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);
m_logger.LogDebug(
$"[HG SUITCASE INVENTORY SERVICE]: GetFolder: folder {f.Name}/{f.ID} " +
$"(user {f.Owner}) is not within Suitcase tree");
return null;
}
}
@ -582,7 +609,8 @@ namespace OpenSim.Services.HypergridService
if (suitcase == null)
{
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID);
m_logger.LogWarning($"[HG SUITCASE INVENTORY SERVICE]: User {principalID} does not have a Suitcase folder");
return false;
}
@ -595,10 +623,7 @@ namespace OpenSim.Services.HypergridService
if (folder != null)
tree.Add(folder);
XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
{
return (fl.folderID == folderID);
});
XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) { return (fl.folderID == folderID); });
return (f != null);
}

View file

@ -25,8 +25,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
@ -40,8 +38,10 @@ using OpenSim.Server.Base;
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using OpenMetaverse;
using log4net;
using Nini.Config;
using Microsoft.Extensions.Configuration;
using log4net.Core;
using Microsoft.Extensions.Logging;
using Autofac;
namespace OpenSim.Services.HypergridService
{
@ -51,142 +51,180 @@ namespace OpenSim.Services.HypergridService
/// needs to do it for them.
/// Once we have better clients, this shouldn't be needed.
/// </summary>
public class UserAgentService : UserAgentServiceBase, IUserAgentService
public class UserAgentService : IUserAgentService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// This will need to go into a DB table
//static Dictionary<UUID, TravelingAgentInfo> m_Database = new Dictionary<UUID, TravelingAgentInfo>();
static bool m_Initialized = false;
protected readonly IGridUserService m_GridUserService;
protected readonly IGridService m_GridService;
protected readonly GatekeeperServiceConnector m_GatekeeperConnector;
protected readonly IGatekeeperService m_GatekeeperService;
protected readonly IFriendsService m_FriendsService;
protected readonly IPresenceService m_PresenceService;
protected readonly IUserAccountService m_UserAccountService;
protected readonly IFriendsSimConnector m_FriendsLocalSimConnector; // standalone, points to HGFriendsModule
protected static IGridUserService m_GridUserService;
protected static IGridService m_GridService;
protected static GatekeeperServiceConnector m_GatekeeperConnector;
protected static IGatekeeperService m_GatekeeperService;
protected static IFriendsService m_FriendsService;
protected static IPresenceService m_PresenceService;
protected static IUserAccountService m_UserAccountService;
protected static IFriendsSimConnector m_FriendsLocalSimConnector; // standalone, points to HGFriendsModule
protected static FriendsSimConnector m_FriendsSimConnector; // grid
protected readonly string? m_GridName;
protected readonly string? m_MyExternalIP = "";
protected static string m_GridName;
protected static string m_MyExternalIP = "";
protected readonly int m_LevelOutsideContacts;
protected readonly bool m_ShowDetails;
protected static int m_LevelOutsideContacts;
protected static bool m_ShowDetails;
protected readonly bool m_BypassClientVerification;
protected static bool m_BypassClientVerification;
private readonly Dictionary<int, bool> m_ForeignTripsAllowed = new();
private readonly Dictionary<int, List<string>> m_TripsAllowedExceptions = new();
private readonly Dictionary<int, List<string>> m_TripsDisallowedExceptions = new();
private static readonly Dictionary<int, bool> m_ForeignTripsAllowed = new();
private static readonly Dictionary<int, List<string>> m_TripsAllowedExceptions = new();
private static readonly Dictionary<int, List<string>> m_TripsDisallowedExceptions = new();
protected readonly IComponentContext m_context;
protected readonly IConfiguration m_config;
protected readonly ILogger<UserAgentService> m_logger;
protected readonly IHGTravelingData m_Database;
protected readonly IFriendsSimConnector m_FriendsSimConnector; // grid
public UserAgentService(IConfiguration config) : this(config, null)
public UserAgentService(
IComponentContext componentContext,
IConfiguration config,
ILogger<UserAgentService> logger,
IHGTravelingData hGTravelingData,
IFriendsSimConnector friendsConnector)
{
}
m_context = componentContext;
m_config = config;
m_logger = logger;
m_Database = hGTravelingData;
m_FriendsSimConnector = friendsConnector;
string? connString = String.Empty;
string? realm = "hg_traveling_data";
// Try reading the [DatabaseService] section, if it exists
var dbConfig = config.GetSection("DatabaseService");
if (dbConfig.Exists() is true)
{
connString = dbConfig.GetValue("ConnectionString", String.Empty);
}
// [UserAgentService] section overrides [DatabaseService], if it exists
var gridConfig = config.GetSection("UserAgentService");
if (gridConfig.Exists() is true)
{
connString = gridConfig.GetValue("ConnectionString", connString);
realm = gridConfig.GetValue("Realm", realm);
}
m_Database.Initialize(connString, realm);
public UserAgentService(IConfiguration config, IFriendsSimConnector friendsConnector)
: base(config)
{
// Let's set this always, because we don't know the sequence
// of instantiations
if (friendsConnector is not null)
m_FriendsLocalSimConnector = friendsConnector;
if (!m_Initialized)
m_logger.LogDebug("[HOME USERS SECURITY]: Starting...");
string? gridService = gridConfig.GetValue("GridService", String.Empty);
string? gridUserService = gridConfig.GetValue("GridUserService", String.Empty);
string? gatekeeperService = gridConfig.GetValue("GatekeeperService", String.Empty);
string? friendsService = gridConfig.GetValue("FriendsService", String.Empty);
string? presenceService = gridConfig.GetValue("PresenceService", String.Empty);
string? userAccountService = gridConfig.GetValue("UserAccountService", String.Empty);
m_BypassClientVerification = gridConfig.GetValue<bool>("BypassClientVerification", false);
if (string.IsNullOrEmpty(gridService) ||
string.IsNullOrEmpty(gridUserService) ||
string.IsNullOrEmpty(gatekeeperService))
{
m_Initialized = true;
m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
m_FriendsSimConnector = new FriendsSimConnector();
IConfig serverConfig = config.Configs["UserAgentService"];
if (serverConfig is null)
throw new Exception(String.Format("No section UserAgentService in config file"));
string gridService = serverConfig.GetString("GridService", String.Empty);
string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
string gatekeeperService = serverConfig.GetString("GatekeeperService", String.Empty);
string friendsService = serverConfig.GetString("FriendsService", String.Empty);
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
string userAccountService = serverConfig.GetString("UserAccountService", String.Empty);
m_BypassClientVerification = serverConfig.GetBoolean("BypassClientVerification", false);
if (gridService.Length == 0 || gridUserService.Length == 0 || gatekeeperService.Length == 0)
throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function."));
Object[] args = new Object[] { config };
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
m_GatekeeperConnector = new GatekeeperServiceConnector();
m_GatekeeperService = ServerUtils.LoadPlugin<IGatekeeperService>(gatekeeperService, args);
m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(friendsService, args);
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args);
m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0);
m_ShowDetails = serverConfig.GetBoolean("ShowUserDetailsInHGProfile", true);
LoadTripPermissionsFromConfig(serverConfig, "ForeignTripsAllowed");
LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions);
LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_TripsDisallowedExceptions);
m_GridName = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
new string[] { "Startup", "Hypergrid", "UserAgentService" }, String.Empty);
if (string.IsNullOrEmpty(m_GridName)) // Legacy. Remove soon.
{
m_GridName = serverConfig.GetString("ExternalName", string.Empty);
if (m_GridName.Length == 0)
{
serverConfig = config.Configs["GatekeeperService"];
m_GridName = serverConfig.GetString("ExternalName", string.Empty);
}
}
if (!string.IsNullOrEmpty(m_GridName))
{
m_GridName = m_GridName.ToLowerInvariant();
if (!m_GridName.EndsWith("/"))
m_GridName += "/";
if (!Uri.TryCreate(m_GridName, UriKind.Absolute, out Uri gateURI))
throw new Exception(String.Format("[UserAgentService] could not parse gatekeeper uri"));
string host = gateURI.DnsSafeHost;
IPAddress ip = Util.GetHostFromDNS(host);
if(ip is null)
throw new Exception(String.Format("[UserAgentService] failed to resolve gatekeeper host"));
m_MyExternalIP = ip.ToString();
}
// Finally some cleanup
m_Database.DeleteOld();
throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function."));
}
m_GatekeeperConnector = m_context.Resolve<GatekeeperServiceConnector>();
m_GridService = m_context.ResolveNamed<IGridService>(gridService);
m_GridUserService = m_context.ResolveNamed<IGridUserService>(gridUserService);
m_GatekeeperService = m_context.ResolveNamed<IGatekeeperService>(gatekeeperService);
if (string.IsNullOrEmpty(friendsService) is false)
m_FriendsService = m_context.ResolveNamed<IFriendsService>(friendsService);
if (string.IsNullOrEmpty(presenceService) is false)
m_PresenceService = m_context.ResolveNamed<IPresenceService>(presenceService);
if (string.IsNullOrEmpty(userAccountService)is false)
m_UserAccountService = m_context.ResolveNamed<IUserAccountService>(userAccountService);
m_LevelOutsideContacts = gridConfig.GetValue<int>("LevelOutsideContacts", 0);
m_ShowDetails = gridConfig.GetValue<bool>("ShowUserDetailsInHGProfile", true);
LoadTripPermissionsFromConfig(gridConfig, "ForeignTripsAllowed");
LoadDomainExceptionsFromConfig(gridConfig, "AllowExcept", m_TripsAllowedExceptions);
LoadDomainExceptionsFromConfig(gridConfig, "DisallowExcept", m_TripsDisallowedExceptions);
m_GridName = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
new string[] { "Startup", "Hypergrid", "UserAgentService" }, String.Empty);
if (string.IsNullOrEmpty(m_GridName)) // Legacy. Remove soon.
{
m_GridName = gridConfig.GetValue("ExternalName", string.Empty);
if (string.IsNullOrEmpty(m_GridName))
{
var serverConfig = config.GetSection("GatekeeperService");
m_GridName = gridConfig.GetValue("ExternalName", string.Empty);
}
}
if (!string.IsNullOrEmpty(m_GridName))
{
m_GridName = m_GridName.ToLowerInvariant();
if (!m_GridName.EndsWith("/"))
m_GridName += "/";
if (!Uri.TryCreate(m_GridName, UriKind.Absolute, out Uri gateURI))
throw new Exception(String.Format("[UserAgentService] could not parse gatekeeper uri"));
string host = gateURI.DnsSafeHost;
IPAddress ip = Util.GetHostFromDNS(host);
if(ip is null)
throw new Exception(String.Format("[UserAgentService] failed to resolve gatekeeper host"));
m_MyExternalIP = ip.ToString();
}
// Finally some cleanup
m_Database.DeleteOld();
}
protected void LoadTripPermissionsFromConfig(IConfig config, string variable)
// XXX MCD
protected void LoadTripPermissionsFromConfig(
IConfigurationSection config,
string variable)
{
foreach (string keyName in config.GetKeys())
if (config.Exists() is false)
return;
foreach (var kvp in config.AsEnumerable())
{
if (keyName.StartsWith(variable + "_Level_"))
if (kvp.Key.StartsWith(variable + "_Level_"))
{
if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out int level))
m_ForeignTripsAllowed.Add(level, config.GetBoolean(keyName, true));
if (Int32.TryParse(kvp.Key.Replace(variable + "_Level_", ""), out int level))
m_ForeignTripsAllowed.Add(level, config.GetValue<bool>(kvp.Key, true));
}
}
}
protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, Dictionary<int, List<string>> exceptions)
protected void LoadDomainExceptionsFromConfig(
IConfigurationSection config,
string variable,
Dictionary<int, List<string>> exceptions)
{
foreach (string keyName in config.GetKeys())
if (config.Exists() is false)
return;
foreach (var kvp in config.AsEnumerable())
{
if (keyName.StartsWith(variable + "_Level_"))
if (kvp.Key.StartsWith(variable + "_Level_"))
{
if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out int level) && !exceptions.ContainsKey(level))
if (Int32.TryParse(kvp.Key.Replace(variable + "_Level_", ""), out int level) && !exceptions.ContainsKey(level))
{
exceptions.Add(level, new List<string>());
string value = config.GetString(keyName, string.Empty);
string value = config.GetValue(kvp.Key, string.Empty);
string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in parts)
@ -194,6 +232,7 @@ namespace OpenSim.Services.HypergridService
string ss = s.Trim();
if(!ss.EndsWith("/"))
ss += '/';
exceptions[level].Add(ss);
}
}
@ -205,9 +244,9 @@ namespace OpenSim.Services.HypergridService
{
position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;
m_log.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID);
m_logger.LogDebug($"[USER AGENT SERVICE]: Request to get home region of user {userID}");
GridRegion home = null;
GridRegion? home = null;
GridUserInfo uinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
if (uinfo is not null)
{
@ -230,15 +269,19 @@ namespace OpenSim.Services.HypergridService
public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI);
m_logger.LogDebug(
$"[USER AGENT SERVICE]: Request to login user {agentCircuit.firstname} {agentCircuit.lastname} " +
$"(@{(fromLogin ? agentCircuit.IPAddress : "stored IP")} to grid {gatekeeper.ServerURI}");
string gridName = gatekeeper.ServerURI.ToLowerInvariant();
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID);
if (account is null)
{
m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname);
m_logger.LogWarning(
$"[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here " +
$"{agentCircuit.firstname} {agentCircuit.lastname}");
reason = "Forbidden to launch your agents from here";
return false;
}
@ -259,7 +302,8 @@ namespace OpenSim.Services.HypergridService
if (!allowed)
{
reason = "Your world does not allow you to visit the destination";
m_log.InfoFormat("[USER AGENT SERVICE]: Agents not permitted to visit {0}. Refusing service.", gridName);
m_logger.LogInformation($"[USER AGENT SERVICE]: Agents not permitted to visit {gridName}. Refusing service.");
return false;
}
}
@ -283,15 +327,15 @@ namespace OpenSim.Services.HypergridService
if(!fromLogin && old is not null && !string.IsNullOrEmpty(old.ClientIPAddress))
{
m_log.DebugFormat("[USER AGENT SERVICE]: stored IP = {0}. Old circuit IP: {1}", old.ClientIPAddress, agentCircuit.IPAddress);
m_logger.LogDebug($"[USER AGENT SERVICE]: stored IP = {old.ClientIPAddress}. Old circuit IP: {agentCircuit.IPAddress}");
agentCircuit.IPAddress = old.ClientIPAddress;
}
bool success;
m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID);
m_logger.LogDebug($"[USER AGENT SERVICE]: this grid: {m_GridName}, desired grid: {gridName}, desired region: {region.RegionID}");
if (m_GridName.Equals(gridName, StringComparison.InvariantCultureIgnoreCase))
if (m_GridName is not null && m_GridName.Equals(gridName, StringComparison.InvariantCultureIgnoreCase))
{
success = m_GatekeeperService.LoginAgent(source, agentCircuit, finalDestination, out reason);
}
@ -304,8 +348,9 @@ namespace OpenSim.Services.HypergridService
if (!success)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}",
agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
m_logger.LogDebug(
$"[USER AGENT SERVICE]: Unable to login user {agentCircuit.firstname} {agentCircuit.lastname} " +
$"to grid {region.ServerURI}, reason: {reason}");
if (old is not null)
StoreTravelInfo(old);
@ -359,13 +404,16 @@ namespace OpenSim.Services.HypergridService
public void LogoutAgent(UUID userID, UUID sessionID)
{
m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID);
m_logger.LogDebug($"[USER AGENT SERVICE]: User {userID} logged out", userID);
m_Database.Delete(sessionID);
GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
if (guinfo is not null)
{
m_GridUserService.LoggedOut(userID.ToString(), sessionID, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);
}
}
// We need to prevent foreign users with the same UUID as a local user
@ -384,8 +432,7 @@ namespace OpenSim.Services.HypergridService
if (m_BypassClientVerification)
return true;
m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
sessionID, reportedIP);
m_logger.LogDebug($"[USER AGENT SERVICE]: Verifying Client session {sessionID} with reported IP {reportedIP}.");
HGTravelingData hgt = m_Database.Get(sessionID);
if (hgt is null)
@ -397,8 +444,9 @@ namespace OpenSim.Services.HypergridService
if(!result && !string.IsNullOrEmpty(m_MyExternalIP))
result = reportedIP == m_MyExternalIP; // NATed
m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {2}; result is {3}",
reportedIP, travel.ClientIPAddress, m_MyExternalIP, result);
m_logger.LogDebug(
$"[USER AGENT SERVICE]: Comparing {reportedIP} with login IP {travel.ClientIPAddress} " +
$"and MyIP {m_MyExternalIP}; result is {result}");
return result;
}
@ -408,12 +456,12 @@ namespace OpenSim.Services.HypergridService
HGTravelingData hgt = m_Database.Get(sessionID);
if (hgt is null)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID);
m_logger.LogDebug($"[USER AGENT SERVICE]: Token verification for session {sessionID}: no such session");
return false;
}
TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, travel.ServiceToken);
m_logger.LogDebug($"[USER AGENT SERVICE]: Verifying agent token {token} against {travel.ServiceToken}");
return travel.ServiceToken == token;
}
@ -422,13 +470,13 @@ namespace OpenSim.Services.HypergridService
{
if (m_FriendsService == null || m_PresenceService == null)
{
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
m_logger.LogWarning($"[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
return new List<UUID>();
}
List<UUID> localFriendsOnline = new();
m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);
m_logger.LogDebug($"[USER AGENT SERVICE]: Status notification: foreign user {foreignUserID} wants to notify {friends.Count} local friends");
// First, let's double check that the reported friends are, indeed, friends of that user
// And let's check that the secret matches
@ -450,7 +498,7 @@ namespace OpenSim.Services.HypergridService
}
// Now, let's send the notifications
m_log.DebugFormat("[USER AGENT SERVICE]: Status notification: user has {0} local friends", usersToBeNotified.Count);
m_logger.LogDebug($"[USER AGENT SERVICE]: Status notification: user has {usersToBeNotified.Count} local friends");
// First, let's send notifications to local users who are online in the home grid
PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray());
@ -483,7 +531,7 @@ namespace OpenSim.Services.HypergridService
// {
// string url = m_Database[id].GridExternalName;
// // forward
// m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
// m_logger.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
// }
//}
@ -503,7 +551,7 @@ namespace OpenSim.Services.HypergridService
{
if (m_FriendsLocalSimConnector is not null)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline"));
m_logger.LogDebug($"[USER AGENT SERVICE]: Local Notify, user {foreignUserID} is {(online ? "online" : "offline")}");
m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online);
}
else
@ -511,8 +559,11 @@ namespace OpenSim.Services.HypergridService
GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID);
if (region is not null)
{
m_log.DebugFormat("[USER AGENT SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline"));
m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID.ToString(), online);
m_logger.LogDebug(
$"[USER AGENT SERVICE]: Remote Notify to region {region.RegionName}, user {foreignUserID} " +
$"is {(online ? "online" : "offline")}");
m_FriendsSimConnector.StatusNotify(/* MCD XXX region,*/ foreignUserID, userID, online);
}
}
}
@ -524,11 +575,11 @@ namespace OpenSim.Services.HypergridService
if (m_FriendsService is null || m_PresenceService is null)
{
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get online friends because friends or presence services are missing");
m_logger.LogWarning("[USER AGENT SERVICE]: Unable to get online friends because friends or presence services are missing");
return online;
}
m_log.DebugFormat("[USER AGENT SERVICE]: Foreign user {0} wants to know status of {1} local friends", foreignUserID, friends.Count);
m_logger.LogDebug($"[USER AGENT SERVICE]: Foreign user {foreignUserID} wants to know status of {friends.Count} local friends");
// First, let's double check that the reported friends are, indeed, friends of that user
// And let's check that the secret matches and the rights
@ -551,7 +602,7 @@ namespace OpenSim.Services.HypergridService
}
// Now, let's find out their status
m_log.DebugFormat("[USER AGENT SERVICE]: GetOnlineFriends: user has {0} local friends with status rights", usersToBeNotified.Count);
m_logger.LogDebug($"[USER AGENT SERVICE]: GetOnlineFriends: user has {usersToBeNotified.Count} local friends with status rights");
// First, let's send notifications to local users who are online in the home grid
PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray());
@ -573,7 +624,8 @@ namespace OpenSim.Services.HypergridService
if (m_UserAccountService is null)
{
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get user flags because user account service is missing");
m_logger.LogWarning($"[USER AGENT SERVICE]: Unable to get user flags because user account service is missing");
info["result"] = "fail";
info["message"] = "UserAccountService is missing!";
return info;
@ -608,9 +660,11 @@ namespace OpenSim.Services.HypergridService
{
if (m_UserAccountService is null)
{
m_log.WarnFormat("[USER AGENT SERVICE]: Unable to get server URLs because user account service is missing");
m_logger.LogWarning($"[USER AGENT SERVICE]: Unable to get server URLs because user account service is missing");
return new Dictionary<string, object>();
}
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero /*!!!*/, userID);
if (account != null)
return account.ServiceURLs;

View file

@ -1,81 +0,0 @@
/*
* 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 Nini.Config;
using OpenSim.Data;
using OpenSim.Services.Base;
namespace OpenSim.Services.HypergridService
{
public class UserAgentServiceBase : ServiceBase
{
protected IHGTravelingData m_Database = null;
public UserAgentServiceBase(IConfiguration config)
: base(config)
{
string dllName = String.Empty;
string connString = String.Empty;
string realm = "hg_traveling_data";
//
// Try reading the [DatabaseService] section, if it exists
//
IConfig dbConfig = config.Configs["DatabaseService"];
if (dbConfig is not null)
{
if (dllName.Length == 0)
dllName = dbConfig.GetString("StorageProvider", String.Empty);
if (connString.Length == 0)
connString = dbConfig.GetString("ConnectionString", String.Empty);
}
//
// [UserAgentService] section overrides [DatabaseService], if it exists
//
IConfig gridConfig = config.Configs["UserAgentService"];
if (gridConfig is not null)
{
dllName = gridConfig.GetString("StorageProvider", dllName);
connString = gridConfig.GetString("ConnectionString", connString);
realm = gridConfig.GetString("Realm", realm);
}
//
// We tried, but this doesn't exist. We can't proceed.
//
if (string.IsNullOrEmpty(dllName))
throw new Exception("No StorageProvider configured");
m_Database = LoadPlugin<IHGTravelingData>(dllName, new Object[] { connString, realm });
if (m_Database is null)
throw new Exception("Could not find a storage interface in the given module");
}
}
}

View file

@ -27,16 +27,16 @@
using System.Xml;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
using PermissionMask = OpenSim.Framework.PermissionMask;
using Microsoft.Extensions.Configuration;
using log4net.Core;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic;
namespace OpenSim.Services.InventoryService
{
@ -46,7 +46,7 @@ namespace OpenSim.Services.InventoryService
/// </summary>
public class LibraryService : ILibraryService
{
private static readonly UUID libOwner = Constants.m_MrOpenSimID;
private static readonly UUID libOwner = Framework.Constants.m_MrOpenSimID;
private const string m_LibraryRootFolderIDstr = "00000112-000f-0000-0000-000100bba000";
private static readonly UUID m_LibraryRootFolderID = new UUID(m_LibraryRootFolderIDstr);
@ -72,13 +72,15 @@ namespace OpenSim.Services.InventoryService
static readonly uint m_GroupPermissions = 0;
protected const string _ConfigName = "LibraryService";
protected readonly IConfiguration m_configuration;
protected readonly ILogger<LibraryService> m_logger;
public LibraryService(
IConfiguration config,
ILogger<LibraryService> logger
)
ILogger<LibraryService> logger)
{
m_configuration = config;
m_logger = logger;
lock(m_rootLock)
@ -92,7 +94,7 @@ namespace OpenSim.Services.InventoryService
string? pLibrariesLocation = Path.Combine("inventory", "Libraries.xml");
string? pLibName = "OpenSim Library";
var libConfig = config.GetSection(_ConfigName);
var libConfig = m_configuration.GetSection(_ConfigName);
if (libConfig.Exists())
{
pLibrariesLocation = libConfig.GetValue("DefaultLibrary", pLibrariesLocation);
@ -145,57 +147,76 @@ namespace OpenSim.Services.InventoryService
/// <param name="assets"></param>
protected void LoadLibraries(string? librariesControlPath)
{
m_logger.LogInformation($"[LIBRARY INVENTORY]: Loading library control file {librariesControlPath}");
LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
if (string.IsNullOrEmpty(librariesControlPath) is false)
{
m_logger.LogInformation($"[LIBRARY INVENTORY]: Loading library control file {librariesControlPath}");
LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
}
else
{
throw new Exception("LoadLibraries: librariesControlPath is null or uninitialized");
}
}
/// <summary>
/// Read a library set from config
/// </summary>
/// <param name="config"></param>
protected void ReadLibraryFromConfig(IConfig config, string path)
protected void ReadLibraryFromConfig(IConfiguration config, string path)
{
string basePath = Path.GetDirectoryName(path);
if (config.Contains("RootVersion"))
string? basePath = Path.GetDirectoryName(path);
// XXX MCD
// if (config.Contains("RootVersion"))
// {
// m_LibraryRootFolder.Version = config.GetValue<ushort>("RootVersion", m_LibraryRootFolder.Version);
// return;
// }
if (basePath is not null)
{
m_LibraryRootFolder.Version = (ushort)config.GetInt("RootVersion", m_LibraryRootFolder.Version);
return;
string? foldersFile = config.GetValue("foldersFile", String.Empty);
if (foldersFile is not null)
{
string foldersPath = Path.Combine(basePath, foldersFile);
LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
}
string? itemsFile = config.GetValue("itemsFile", String.Empty);
if (itemsFile is not null)
{
string itemsPath = Path.Combine( basePath, itemsFile);
LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
}
}
string foldersPath = Path.Combine(basePath, config.GetString("foldersFile", String.Empty));
LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
string itemsPath = Path.Combine( basePath, config.GetString("itemsFile", String.Empty));
LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
}
/// <summary>
/// Read a library inventory folder from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadFolderFromConfig(IConfig config, string path)
private void ReadFolderFromConfig(IConfiguration config, string path)
{
InventoryFolderImpl folderInfo = new InventoryFolderImpl();
folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolderIDstr));
folderInfo.Name = config.GetString("name", "unknown");
folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolderIDstr));
folderInfo.Type = (short)config.GetInt("type", 8);
folderInfo.Version = (ushort)config.GetInt("version", 1);
folderInfo.ID = new UUID(config.GetValue("folderID", m_LibraryRootFolderIDstr));
folderInfo.Name = config.GetValue("name", "unknown");
folderInfo.ParentID = new UUID(config.GetValue("parentFolderID", m_LibraryRootFolderIDstr));
folderInfo.Type = config.GetValue<short>("type", 8);
folderInfo.Version = config.GetValue<ushort>("version", 1);
folderInfo.Owner = libOwner;
if (libraryFolders.TryGetValue(folderInfo.ParentID, out InventoryFolderImpl parentFolder))
if (libraryFolders.TryGetValue(folderInfo.ParentID, out InventoryFolderImpl? parentFolder))
{
libraryFolders.Add(folderInfo.ID, folderInfo);
parentFolder.AddChildFolder(folderInfo);
//m_logger.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
m_logger.LogDebug($"[LIBRARY INVENTORY]: Adding folder {folderInfo.Name} ({folderInfo.ID})");
}
else
{
m_logger.WarnFormat(
"[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
folderInfo.Name, folderInfo.ID, folderInfo.ParentID);
m_logger.LogWarning(
$"[LIBRARY INVENTORY]: Couldn't add folder {folderInfo.Name} ({folderInfo.ID}) " +
$"since parent folder with ID {folderInfo.ParentID} does not exist!");
}
}
@ -203,28 +224,28 @@ namespace OpenSim.Services.InventoryService
/// Read a library inventory item metadata from a loaded configuration
/// </summary>
/// <param name="source"></param>
private void ReadItemFromConfig(IConfig config, string path)
private void ReadItemFromConfig(IConfiguration config, string path)
{
InventoryItemBase item = new InventoryItemBase();
item.Owner = libOwner;
item.CreatorId = libOwner.ToString();
UUID itID = new UUID(config.GetString("inventoryID", m_LibraryRootFolderIDstr));
UUID itID = new UUID(config.GetValue("inventoryID", m_LibraryRootFolderIDstr));
item.ID = itID;
item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString()));
item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolderIDstr));
item.Name = config.GetString("name", String.Empty);
item.Description = config.GetString("description", item.Name);
item.InvType = config.GetInt("inventoryType", 0);
item.AssetType = config.GetInt("assetType", item.InvType);
item.CurrentPermissions = (uint)config.GetLong("currentPermissions", m_CurrentPermissions);
item.NextPermissions = (uint)config.GetLong("nextPermissions", m_NextPermissions);
item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", m_EveryOnePermissions);
item.BasePermissions = (uint)config.GetLong("basePermissions", m_BasePermissions);
item.GroupPermissions = (uint)config.GetLong("basePermissions", m_GroupPermissions);
item.Flags = (uint)config.GetInt("flags", 0);
item.AssetID = new UUID(config.GetValue("assetID", item.ID.ToString()));
item.Folder = new UUID(config.GetValue("folderID", m_LibraryRootFolderIDstr));
item.Name = config.GetValue("name", String.Empty);
item.Description = config.GetValue("description", item.Name);
item.InvType = config.GetValue<int>("inventoryType", 0);
item.AssetType = config.GetValue<int>("assetType", item.InvType);
item.CurrentPermissions = config.GetValue<uint>("currentPermissions", m_CurrentPermissions);
item.NextPermissions = (uint)config.GetValue<uint>("nextPermissions", m_NextPermissions);
item.EveryOnePermissions = config.GetValue<uint>("everyonePermissions", m_EveryOnePermissions);
item.BasePermissions = config.GetValue<uint>("basePermissions", m_BasePermissions);
item.GroupPermissions = config.GetValue<uint>("basePermissions", m_GroupPermissions);
item.Flags = config.GetValue<uint>("flags", 0);
if (libraryFolders.TryGetValue(item.Folder, out InventoryFolderImpl parentFolder))
if (libraryFolders.TryGetValue(item.Folder, out InventoryFolderImpl? parentFolder))
{
if(!parentFolder.Items.ContainsKey(itID))
{
@ -233,18 +254,18 @@ namespace OpenSim.Services.InventoryService
}
else
{
m_logger.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name);
m_logger.LogWarning($"[LIBRARY INVENTORY] Item {item.Name} [{item.ID}] not added, duplicate item");
}
}
else
{
m_logger.WarnFormat(
"[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
item.Name, item.ID, item.Folder);
m_logger.LogWarning(
$"[LIBRARY INVENTORY]: Couldn't add item {item.Name} ({item.ID}) " +
$"since parent folder with ID {item.Folder} does not exist!");
}
}
private delegate void ConfigAction(IConfig config, string path);
private delegate void ConfigAction(IConfiguration config, string path);
/// <summary>
/// Load the given configuration at a path and perform an action on each Config contained within it
@ -252,22 +273,29 @@ namespace OpenSim.Services.InventoryService
/// <param name="path"></param>
/// <param name="fileDescription"></param>
/// <param name="action"></param>
private static void LoadFromFile(string path, string fileDescription, ConfigAction action)
private void LoadFromFile(string path, string fileDescription, ConfigAction action)
{
if (File.Exists(path))
{
try
{
XmlConfigSource source = new XmlConfigSource(path);
IConfigurationBuilder builder = new ConfigurationBuilder().AddXmlFile(path, optional: false, reloadOnChange: true);
IConfigurationRoot root = builder.Build();
for (int i = 0; i < source.Configs.Count; i++)
foreach (var source in root.GetChildren())
{
action(source.Configs[i], path);
action(source, path);
}
//XmlConfigSource source = new XmlConfigSource(path);
// for (int i = 0; i < source.Configs.Count; i++)
// {
// action(source.Configs[i], path);
// }
}
catch (XmlException e)
{
m_logger.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e);
m_logger.LogError(e, $"[LIBRARY INVENTORY]: Error loading {path}");
}
}
else
@ -305,19 +333,19 @@ namespace OpenSim.Services.InventoryService
return folders;
}
public InventoryItemBase GetItem(UUID itemID)
public InventoryItemBase? GetItem(UUID itemID)
{
if(m_items.TryGetValue(itemID, out InventoryItemBase it))
if(m_items.TryGetValue(itemID, out InventoryItemBase? it))
return it;
return null;
}
public InventoryItemBase[] GetMultipleItems(UUID[] ids)
public InventoryItemBase[]? GetMultipleItems(UUID[] ids)
{
List<InventoryItemBase> items = new(ids.Length);
foreach (UUID id in ids.AsSpan())
{
if (m_items.TryGetValue(id, out InventoryItemBase it))
if (m_items.TryGetValue(id, out InventoryItemBase? it))
items.Add(it);
}

View file

@ -32,41 +32,46 @@ using OpenSim.Data;
using OpenSim.Framework;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Autofac;
namespace OpenSim.Services.InventoryService
{
public class XInventoryService : IInventoryService
{
protected const string _ConfigName = "InventoryService";
protected IXInventoryData m_Database;
protected bool m_AllowDelete = true;
protected string m_ConfigName = "InventoryService";
public XInventoryService(IConfiguration config)
: this(config, "InventoryService")
protected readonly IComponentContext m_context;
protected readonly IConfiguration m_configuration;
protected readonly ILogger<XInventoryService> m_logger;
public XInventoryService(
IComponentContext componentContext,
IConfiguration config,
ILogger<XInventoryService> logger
)
{
}
m_context = componentContext;
m_configuration = config;
m_logger = logger;
public XInventoryService(IConfiguration config, string configName) : base(config)
{
if (configName != string.Empty)
m_ConfigName = configName;
string dllName = String.Empty;
string connString = String.Empty;
//string realm = "Inventory"; // OSG version doesn't use this
string? connString = string.Empty;
string? realm = string.Empty;
string? dataModule = string.Empty;
//
// Try reading the [InventoryService] section first, if it exists
//
var authConfig = config.GetSection(m_ConfigName);
var authConfig = config.GetSection(_ConfigName);
if (authConfig.Exists())
{
dllName = authConfig.GetValue("StorageProvider", dllName);
connString = authConfig.GetValue("ConnectionString", connString);
realm = authConfig.GetValue("Realm", realm);
dataModule = authConfig.GetValue("LocalDataModule", string.Empty);
m_AllowDelete = authConfig.GetValue<bool>("AllowDelete", true);
// realm = authConfig.GetString("Realm", realm);
}
//
@ -75,22 +80,20 @@ namespace OpenSim.Services.InventoryService
var dbConfig = config.GetSection("DatabaseService");
if (dbConfig.Exists())
{
if (string.IsNullOrEmpty(dllName))
dllName = dbConfig.GetValue("StorageProvider", String.Empty);
if (string.IsNullOrEmpty(connString))
connString = dbConfig.GetValue("ConnectionString", String.Empty);
if (string.IsNullOrEmpty(realm))
realm = dbConfig.GetValue("Realm", String.Empty);
}
//
// We tried, but this doesn't exist. We can't proceed.
//
if (string.IsNullOrEmpty(dllName))
throw new Exception("No StorageProvider configured");
m_Database = LoadPlugin<IXInventoryData>(dllName, new Object[] {connString, String.Empty});
if (string.IsNullOrEmpty(dataModule))
throw new Exception($"Missing LocalDataModule configuration for {_ConfigName}");
m_Database = m_context.ResolveNamed<IXInventoryData>(dataModule);
if (m_Database == null)
throw new Exception("Could not find a storage interface in the given module");
m_Database.Initialize(connString, realm);
}
public virtual bool CreateUserInventory(UUID principalID)
@ -101,8 +104,7 @@ namespace OpenSim.Services.InventoryService
//
bool result = false;
InventoryFolderBase rootFolder = GetRootFolder(principalID);
InventoryFolderBase? rootFolder = GetRootFolder(principalID);
if (rootFolder == null)
{
rootFolder = ConvertToOpenSim(CreateFolder(principalID, UUID.Zero, (int)FolderType.Root, InventoryFolderBase.ROOT_FOLDER_NAME));
@ -193,7 +195,7 @@ namespace OpenSim.Services.InventoryService
return sysFolders;
}
public virtual List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
public virtual List<InventoryFolderBase>? GetInventorySkeleton(UUID principalID)
{
XInventoryFolder[] allFolders = m_Database.GetFolders(
new string[] { "agentID" },
@ -213,7 +215,7 @@ namespace OpenSim.Services.InventoryService
return folders;
}
public virtual InventoryFolderBase GetRootFolder(UUID principalID)
public virtual InventoryFolderBase? GetRootFolder(UUID principalID)
{
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "agentID", "parentFolderID"},
@ -222,8 +224,8 @@ namespace OpenSim.Services.InventoryService
if (folders.Length == 0)
return null;
XInventoryFolder root = null;
foreach (XInventoryFolder folder in folders)
XInventoryFolder? root = null;
foreach (var folder in folders)
{
if (folder.folderName == InventoryFolderBase.ROOT_FOLDER_NAME)
{
@ -237,25 +239,22 @@ namespace OpenSim.Services.InventoryService
return ConvertToOpenSim(root);
}
public virtual InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
public virtual InventoryFolderBase? GetFolderForType(UUID principalID, FolderType type)
{
// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
InventoryFolderBase rootFolder = GetRootFolder(principalID);
InventoryFolderBase? rootFolder = GetRootFolder(principalID);
if (rootFolder == null)
{
m_log.WarnFormat(
"[XINVENTORY]: Found no root folder for {0} in GetFolderForType() when looking for {1}",
principalID, type);
m_logger.LogWarning($"[XINVENTORY]: Found no root folder for {principalID} in GetFolderForType() when looking for {type}");
return null;
}
return GetSystemFolderForType(rootFolder, type);
}
private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, FolderType type)
private InventoryFolderBase? GetSystemFolderForType(InventoryFolderBase rootFolder, FolderType type)
{
//m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0}", type);
@ -313,7 +312,7 @@ namespace OpenSim.Services.InventoryService
inventory.Items.Add(ConvertToOpenSim(i));
}
InventoryFolderBase f = GetFolder(principalID, folderID);
InventoryFolderBase? f = GetFolder(principalID, folderID);
if (f != null)
{
inventory.Version = f.Version;
@ -356,34 +355,30 @@ namespace OpenSim.Services.InventoryService
{
// m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID);
InventoryFolderBase check = GetFolder(folder.Owner, folder.ID);
InventoryFolderBase? check = GetFolder(folder.Owner, folder.ID);
if (check != null)
return false;
if (folder.Type != (short)FolderType.None)
{
InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
InventoryFolderBase? rootFolder = GetRootFolder(folder.Owner);
if (rootFolder == null)
{
m_log.WarnFormat(
"[XINVENTORY]: Found no root folder for {0} in AddFolder() when looking for {1}",
folder.Owner, folder.Type);
m_logger.LogWarning($"[XINVENTORY]: Found no root folder for {folder.Owner} in AddFolder() when looking for {folder.Type}");
return false;
}
// Check we're not trying to add this as a system folder.
if (folder.ParentID == rootFolder.ID)
{
InventoryFolderBase existingSystemFolder
= GetSystemFolderForType(rootFolder, (FolderType)folder.Type);
InventoryFolderBase? existingSystemFolder = GetSystemFolderForType(rootFolder, (FolderType)folder.Type);
if (existingSystemFolder != null)
{
m_log.WarnFormat(
"[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}",
folder.Type, folder.Name, folder.ParentID, folder.Owner);
m_logger.LogWarning(
$"[XINVENTORY]: System folder of type {folder.Type} already exists when trying "+
$"to add {folder.Name} to {folder.ParentID} for {folder.Owner}");
return false;
}
@ -399,7 +394,7 @@ namespace OpenSim.Services.InventoryService
// m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID);
XInventoryFolder xFolder = ConvertFromOpenSim(folder);
InventoryFolderBase check = GetFolder(folder.Owner, folder.ID);
InventoryFolderBase? check = GetFolder(folder.Owner, folder.ID);
if (check == null)
return AddFolder(folder);
@ -510,13 +505,13 @@ namespace OpenSim.Services.InventoryService
// m_log.InfoFormat(
// "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder);
InventoryItemBase retrievedItem = GetItem(item.Owner, item.ID);
InventoryItemBase? retrievedItem = GetItem(item.Owner, item.ID);
if (retrievedItem == null)
{
m_log.WarnFormat(
"[XINVENTORY SERVICE]: Tried to update item {0} {1}, owner {2} but no existing item found.",
item.Name, item.ID, item.Owner);
m_logger.LogWarning(
$"[XINVENTORY SERVICE]: Tried to update item {item.Name} {item.ID}, " +
$"owner {item.Owner} but no existing item found.");
return false;
}
@ -528,20 +523,12 @@ namespace OpenSim.Services.InventoryService
|| retrievedItem.CreatorIdentification != item.CreatorIdentification
|| retrievedItem.Owner != item.Owner)
{
m_log.WarnFormat(
"[XINVENTORY SERVICE]: Caller to UpdateItem() for {0} {1} tried to alter property(s) that should be invariant, (InvType, AssetType, Folder, CreatorIdentification, Owner), existing ({2}, {3}, {4}, {5}, {6}), update ({7}, {8}, {9}, {10}, {11})",
retrievedItem.Name,
retrievedItem.ID,
retrievedItem.InvType,
retrievedItem.AssetType,
retrievedItem.Folder,
retrievedItem.CreatorIdentification,
retrievedItem.Owner,
item.InvType,
item.AssetType,
item.Folder,
item.CreatorIdentification,
item.Owner);
m_logger.LogWarning(
$"[XINVENTORY SERVICE]: Caller to UpdateItem() for {retrievedItem.Name} {retrievedItem.ID} " +
$"tried to alter property(s) that should be invariant, (InvType, AssetType, Folder, CreatorIdentification, Owner), " +
$"existing ({retrievedItem.InvType}, {retrievedItem.AssetType}, {retrievedItem.Folder}, {retrievedItem.CreatorIdentification}, " +
$"{retrievedItem.Owner}), update ({item.InvType}, {item.AssetType}, {item.Folder}, " +
$"{item.CreatorIdentification}, {item.Owner})");
item.InvType = retrievedItem.InvType;
item.AssetType = retrievedItem.AssetType;
@ -596,7 +583,7 @@ namespace OpenSim.Services.InventoryService
return true;
}
public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID)
public virtual InventoryItemBase? GetItem(UUID principalID, UUID itemID)
{
XInventoryItem[] items = m_Database.GetItems(
new string[] { "inventoryID" },
@ -610,15 +597,18 @@ namespace OpenSim.Services.InventoryService
public virtual InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] ids)
{
InventoryItemBase[] items = new InventoryItemBase[ids.Length];
InventoryItemBase?[] items = new InventoryItemBase[ids.Length];
int i = 0;
foreach (UUID id in ids)
{
items[i++] = GetItem(userID, id);
}
return items;
}
public virtual InventoryFolderBase GetFolder(UUID principalID, UUID folderID)
public virtual InventoryFolderBase? GetFolder(UUID principalID, UUID folderID)
{
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "folderID"},

View file

@ -27,10 +27,8 @@
using System.Collections;
using System.Net;
using System.Reflection;
using System.Text.RegularExpressions;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
@ -42,12 +40,13 @@ using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using OpenSim.Services.Connectors.Hypergrid;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Autofac;
namespace OpenSim.Services.LLLoginService
{
public class LLLoginService : ILoginService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[LLOGIN SERVICE]";
private static bool Initialized = false;
@ -68,59 +67,69 @@ namespace OpenSim.Services.LLLoginService
protected GatekeeperServiceConnector m_GatekeeperConnector;
protected string m_WelcomeMessage;
protected string? m_WelcomeMessage;
protected bool m_RequireInventory;
protected int m_MinLoginLevel;
protected string m_GatekeeperURL;
protected string? m_GatekeeperURL;
protected bool m_AllowRemoteSetLoginLevel;
protected string m_MapTileURL;
protected string m_ProfileURL;
protected string m_OpenIDURL;
protected string m_SearchURL;
protected string m_Currency;
protected string m_ClassifiedFee;
protected string? m_MapTileURL;
protected string? m_ProfileURL;
protected string? m_OpenIDURL;
protected string? m_SearchURL;
protected string? m_Currency;
protected string? m_ClassifiedFee;
protected int m_MaxAgentGroups = 42;
protected string m_DestinationGuide;
protected string m_AvatarPicker;
protected string? m_DestinationGuide;
protected string? m_AvatarPicker;
protected Regex m_AllowedClientsRegex;
protected Regex m_DeniedClientsRegex;
protected string m_DeniedMacs;
protected string m_DeniedID0s;
protected string m_MessageUrl;
protected string m_DSTZone;
protected string? m_DeniedMacs;
protected string? m_DeniedID0s;
protected string? m_MessageUrl;
protected string? m_DSTZone;
protected bool m_allowDuplicatePresences = false;
protected string m_messageKey;
protected string? m_messageKey;
protected bool m_allowLoginFallbackToAnyRegion = true; // if login requested region if not found and there are no Default or fallback regions,
public LLLoginService(IConfiguration config) :
this(config, null, null)
{
}
protected readonly IComponentContext m_context;
protected readonly IConfiguration m_config;
protected readonly ILogger<LLLoginService> m_logger;
public LLLoginService(IConfiguration config, ISimulationService simService, ILibraryService libraryService)
public LLLoginService(
IComponentContext componentContext,
IConfiguration config,
ILogger<LLLoginService> logger,
ISimulationService simService,
ILibraryService libraryService)
{
var loginServerConfig = config.GetSection("LoginService");
m_context = componentContext;
m_config = config;
m_logger = logger;
var loginServerConfig = m_config.GetSection("LoginService");
if (loginServerConfig.Exists() is false)
throw new Exception($"No section LoginService in config file");
string accountService = loginServerConfig.GetValue("UserAccountService", string.Empty);
string gridUserService = loginServerConfig.GetValue("GridUserService", string.Empty);
string agentService = loginServerConfig.GetValue("UserAgentService", string.Empty);
string authService = loginServerConfig.GetValue("AuthenticationService", string.Empty);
string invService = loginServerConfig.GetValue("InventoryService", string.Empty);
string gridService = loginServerConfig.GetValue("GridService", string.Empty);
string presenceService = loginServerConfig.GetValue("PresenceService", string.Empty);
string libService = loginServerConfig.GetValue("LibraryService", string.Empty);
string friendsService = loginServerConfig.GetValue("FriendsService", string.Empty);
string avatarService = loginServerConfig.GetValue("AvatarService", string.Empty);
string simulationService = loginServerConfig.GetValue("SimulationService", string.Empty);
string? accountService = loginServerConfig.GetValue("UserAccountService", string.Empty);
string? gridUserService = loginServerConfig.GetValue("GridUserService", string.Empty);
string? agentService = loginServerConfig.GetValue("UserAgentService", string.Empty);
string? authService = loginServerConfig.GetValue("AuthenticationService", string.Empty);
string? invService = loginServerConfig.GetValue("InventoryService", string.Empty);
string? gridService = loginServerConfig.GetValue("GridService", string.Empty);
string? presenceService = loginServerConfig.GetValue("PresenceService", string.Empty);
string? libService = loginServerConfig.GetValue("LibraryService", string.Empty);
string? friendsService = loginServerConfig.GetValue("FriendsService", string.Empty);
string? avatarService = loginServerConfig.GetValue("AvatarService", string.Empty);
string? simulationService = loginServerConfig.GetValue("SimulationService", string.Empty);
m_WelcomeMessage = loginServerConfig.GetValue("WelcomeMessage", "Welcome to OpenSim!");
m_RequireInventory = loginServerConfig.GetValue<bool>("RequireInventory", true);
m_AllowRemoteSetLoginLevel = loginServerConfig.GetValue<bool>("AllowRemoteSetLoginLevel", false);
m_MinLoginLevel = loginServerConfig.GetValue<int>("MinLoginLevel", 0);
m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
new string[] { "Startup", "Hypergrid", "LoginService" }, string.Empty);
m_MapTileURL = loginServerConfig.GetValue("MapTileURL", string.Empty);
m_ProfileURL = loginServerConfig.GetValue("ProfileServerURL", string.Empty);
m_OpenIDURL = loginServerConfig.GetValue("OpenIDServerURL", string.Empty);
@ -143,7 +152,7 @@ namespace OpenSim.Services.LLLoginService
catch
{
m_AllowedClientsRegex = null;
m_log.Error("[GATEKEEPER SERVICE]: failed to parse AllowedClients");
m_logger.LogError("[GATEKEEPER SERVICE]: failed to parse AllowedClients");
}
}
@ -157,7 +166,7 @@ namespace OpenSim.Services.LLLoginService
catch
{
m_DeniedClientsRegex = null;
m_log.Error("[GATEKEEPER SERVICE]: failed to parse DeniedClients");
m_logger.LogError("[GATEKEEPER SERVICE]: failed to parse DeniedClients");
}
}
@ -194,40 +203,43 @@ namespace OpenSim.Services.LLLoginService
throw new Exception("LoginService is missing service specifications");
// replace newlines in welcome message
m_WelcomeMessage = m_WelcomeMessage.Replace("\\n", "\n");
m_WelcomeMessage = m_WelcomeMessage?.Replace("\\n", "\n");
object[] args = new object[] { config };
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
m_UserAccountService = m_context.ResolveNamed<IUserAccountService>(accountService);
m_GridUserService = m_context.ResolveNamed<IGridUserService>(gridUserService);
object[] authArgs = new object[] { config, m_UserAccountService };
m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, authArgs);
m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
m_AuthenticationService = m_context.ResolveNamed<IAuthenticationService>(authService);
m_InventoryService = m_context.ResolveNamed<IInventoryService>(invService);
if (string.IsNullOrWhiteSpace(gridService) is false)
m_GridService = m_context.ResolveNamed<IGridService>(gridService);
if (string.IsNullOrWhiteSpace(presenceService) is false)
m_PresenceService = m_context.ResolveNamed<IPresenceService>(presenceService);
if (string.IsNullOrWhiteSpace(avatarService) is false)
m_AvatarService = m_context.ResolveNamed<IAvatarService>(avatarService);
if (string.IsNullOrWhiteSpace(friendsService) is false)
m_FriendsService = m_context.ResolveNamed<IFriendsService>(friendsService);
if (string.IsNullOrWhiteSpace(simulationService) is false)
m_RemoteSimulationService = m_context.ResolveNamed<ISimulationService>(simulationService);
if (!string.IsNullOrWhiteSpace(gridService))
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
if (!string.IsNullOrWhiteSpace(presenceService))
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
if (!string.IsNullOrWhiteSpace(avatarService))
m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args);
if (!string.IsNullOrWhiteSpace(friendsService))
m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(friendsService, args);
if (!string.IsNullOrWhiteSpace(simulationService))
m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
if (!string.IsNullOrWhiteSpace(agentService))
m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(agentService, args);
m_UserAgentService = m_context.ResolveNamed<IUserAgentService>(agentService);
// Get the Hypergrid inventory service (exists only if Hypergrid is enabled)
string hgInvServicePlugin = loginServerConfig.GetValue("HGInventoryServicePlugin", string.Empty);
if (!string.IsNullOrWhiteSpace(hgInvServicePlugin))
string? hgInvServicePlugin = loginServerConfig.GetValue("HGInventoryServicePlugin", string.Empty);
if (string.IsNullOrWhiteSpace(hgInvServicePlugin) is false)
{
string hgInvServiceArg = loginServerConfig.GetValue("HGInventoryServiceConstructorArg", string.Empty);
if (!string.IsNullOrWhiteSpace(hgInvServiceArg))
string? hgInvServiceArg = loginServerConfig.GetValue("HGInventoryServiceConstructorArg", string.Empty);
if (string.IsNullOrWhiteSpace(hgInvServiceArg) is false)
{
hgInvServicePlugin = hgInvServiceArg + "@" + hgInvServicePlugin;
}
m_HGInventoryService = ServerUtils.LoadPlugin<IInventoryService>(hgInvServicePlugin, args);
m_HGInventoryService = m_context.ResolveNamed<IInventoryService>(hgInvServicePlugin);
}
//
@ -236,13 +248,13 @@ namespace OpenSim.Services.LLLoginService
m_LocalSimulationService = simService;
if (libraryService is not null)
{
m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument");
m_logger.LogDebug("[LLOGIN SERVICE]: Using LibraryService given as argument");
m_LibraryService = libraryService;
}
else if (!string.IsNullOrWhiteSpace(libService))
else if (string.IsNullOrWhiteSpace(libService) is false)
{
m_log.DebugFormat("[LLOGIN SERVICE]: Using instantiated LibraryService");
m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args);
m_logger.LogDebug("[LLOGIN SERVICE]: Using instantiated LibraryService");
m_LibraryService = m_context.ResolveNamed<ILibraryService>(libService);
}
m_GatekeeperConnector = new GatekeeperServiceConnector();
@ -253,7 +265,7 @@ namespace OpenSim.Services.LLLoginService
RegisterCommands();
}
m_log.DebugFormat("[LLOGIN SERVICE]: Starting...");
m_logger.LogDebug("[LLOGIN SERVICE]: Starting...");
}
public Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP)

View file

@ -33,22 +33,22 @@
<ProjectReference Include="..\..\Source\OpenSim.Framework.Serialization\OpenSim.Framework.Serialization.csproj" />
<ProjectReference Include="..\..\Source\OpenSim.Server.Base\OpenSim.Server.Base.csproj" />
<ProjectReference Include="..\..\Source\OpenSim.Services.Interfaces\OpenSim.Services.Interfaces.csproj" />
<ProjectReference Include="..\OpenSim.Framework.AssetLoader.Filesystem\OpenSim.Framework.AssetLoader.Filesystem.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Remove="GridService/**" />
<Compile Remove="HypergridService/**" />
<Compile Remove="InventoryService/**" />
<Compile Remove="LLLoginService/**" />
<Compile Remove="PresenceService/**" />
<Compile Remove="SimulationService/**" />
<ProjectReference Include="..\..\Source\OpenSim.Framework.AssetLoader.Filesystem\OpenSim.Framework.AssetLoader.Filesystem.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Remove="GridService/**"/>
<Compile Remove="HypergridService/**"/>
<Compile Remove="LLLoginService/**"/>
<Compile Remove="PresenceService/**"/>
<Compile Remove="SimulationService/**"/>
</ItemGroup>
</Project>

View file

@ -5,6 +5,9 @@ using OpenSim.Services.UserAccountService;
using OpenSim.Services.EstateService;
using OpenSim.Framework;
using OpenSim.Framework.AssetLoader.Filesystem;
using OpenSim.Services.InventoryService;
using OpenSim.Services.AuthenticationService;
using OpenSim.Services.AuthorizationService;
namespace OpenSim.Services;
@ -12,18 +15,35 @@ public class OpenSimServicesModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<FSAssetConnector>()
.Named<IAssetService>("FSAssetConnector")
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<AssetService.AssetService>()
.Named<IAssetService>("AssetService")
.AsImplementedInterfaces().SingleInstance();
// [Obsolete]
// builder.RegisterType<AssetService.XAssetService>()
// .Named<IAssetService>("XAssetService")
// .AsImplementedInterfaces().SingleInstance();
builder.RegisterType<AssetLoaderFileSystem>()
.Named<IAssetLoader>("AssetLoaderFileSystem")
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<PasswordAuthenticationService>()
.Named<IAuthenticationService>("PasswordAuthenticationService")
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<WebkeyAuthenticationService>()
.Named<IAuthenticationService>("WebkeyAuthenticationService")
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<WebkeyOrPasswordAuthenticationService>()
.Named<IAuthenticationService>("WebkeyOrPasswordAuthenticationService")
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<AuthorizationService.AuthorizationService>()
.Named<IAuthorizationService>("AuthorizationService")
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<AgentPreferencesService>()
.Named<IAgentPreferencesService>("AgentPreferencesService")
.AsImplementedInterfaces().SingleInstance();
@ -33,6 +53,15 @@ public class OpenSimServicesModule : Module
.AsImplementedInterfaces()
.SingleInstance();
builder.RegisterType<FSAssetConnector>()
.Named<IAssetService>("FSAssetConnector")
.AsImplementedInterfaces().SingleInstance();
// builder.RegisterType<GridService.GridService>()
// .Named<IGridService>("GridService")
// .AsImplementedInterfaces().SingleInstance();
builder.RegisterType<GridUserService>()
.Named<IGridUserService>("GridUserService")
.AsImplementedInterfaces().SingleInstance();
@ -43,6 +72,10 @@ public class OpenSimServicesModule : Module
builder.RegisterType<UserAliasService>()
.Named<IUserAliasService>("UserAliasService")
.AsImplementedInterfaces().SingleInstance();
.AsImplementedInterfaces().SingleInstance();
builder.RegisterType<XInventoryService>()
.Named<IInventoryService>("XInventoryService")
.AsImplementedInterfaces().SingleInstance();
}
}

View file

@ -26,16 +26,13 @@
*/
using OpenMetaverse;
using OpenSim.Services.Base;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Microsoft.Extensions.Configuration;
namespace OpenSim.Services.SimulationService
{
public class SimulationDataService : ServiceBase, ISimulationDataService
public class SimulationDataService : ISimulationDataService
{
protected ISimulationDataStore m_database;

View file

@ -25,13 +25,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework.Tests
{
[TestFixture]
public class AgentCircuitDataTest : IDisposable
{
private UUID AgentId;
@ -48,6 +48,11 @@ namespace OpenSim.Framework.Tests
private Vector3 StartPos;
public AgentCircuitDataTest()
{
}
[SetUp]
public void Setup()
{
AgentId = UUID.Random();
BaseFolder = UUID.Random();
@ -225,7 +230,7 @@ namespace OpenSim.Framework.Tests
/// The idea is that if the current json serializer cannot parse the old serialization, then the underlying types
/// have changed and are incompatible.
/// </summary>
[Fact]
[Test]
public void HistoricalAgentCircuitDataOSDConversion()
{
string oldSerialization = "{\"agent_id\":\"522675bd-8214-40c1-b3ca-9c7f7fd170be\",\"base_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"caps_path\":\"http://www.opensimulator.org/Caps/Foo\",\"children_seeds\":[{\"handle\":\"18446744073709551615\",\"seed\":\"http://www.opensimulator.org/Caps/Foo2\"}],\"child\":false,\"circuit_code\":\"949030\",\"first_name\":\"CoolAvatarTest\",\"last_name\":\"test\",\"inventory_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"secure_session_id\":\"1e608e2b-0ddb-41f6-be0f-926f61cd3e0a\",\"session_id\":\"aa06f798-9d70-4bdb-9bbf-012a02ee2baf\",\"start_pos\":\"<5, 23, 125>\"}";
@ -283,7 +288,7 @@ namespace OpenSim.Framework.Tests
/// <summary>
/// Test to ensure that the packing and unpacking methods work.
/// </summary>
[Fact]
[Test]
public void TestAgentCircuitDataOSDConversion()
{
AgentCircuitData Agent1Data = new AgentCircuitData();
@ -340,10 +345,6 @@ namespace OpenSim.Framework.Tests
for (int i = 0; i < 208; i++)
Assert.True((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i]));
*/
}
}
}

View file

@ -24,11 +24,8 @@
* (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 Xunit;
using OpenSim.Framework;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework.Tests
{
@ -46,6 +43,11 @@ namespace OpenSim.Framework.Tests
private Random rnd = new Random(Environment.TickCount);
public AgentCircuitManagerTests()
{
}
[SetUp]
public void Setup()
{
AgentId1 = UUID.Random();
AgentId2 = UUID.Random();
@ -103,7 +105,7 @@ namespace OpenSim.Framework.Tests
/// <summary>
/// Validate that adding the circuit works appropriately
/// </summary>
[Fact]
[Test]
public void AddAgentCircuitTest()
{
AgentCircuitManager agentCircuitManager = new AgentCircuitManager();
@ -129,7 +131,7 @@ namespace OpenSim.Framework.Tests
/// <summary>
/// Validate that removing the circuit code removes it appropriately
/// </summary>
[Fact]
[Test]
public void RemoveAgentCircuitTest()
{
AgentCircuitManager agentCircuitManager = new AgentCircuitManager();
@ -145,7 +147,7 @@ namespace OpenSim.Framework.Tests
/// <summary>
/// Validate that changing the circuit code works
/// </summary>
[Fact]
[Test]
public void ChangeAgentCircuitCodeTest()
{
AgentCircuitManager agentCircuitManager = new AgentCircuitManager();
@ -169,7 +171,7 @@ namespace OpenSim.Framework.Tests
/// First one should be authorized
/// Rest should not be authorized
/// </summary>
[Fact]
[Test]
public void ValidateLoginTest()
{
AgentCircuitManager agentCircuitManager = new AgentCircuitManager();

View file

@ -25,9 +25,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@ -43,6 +40,11 @@ namespace OpenSim.Framework.Tests
private UUID objUUID2 = UUID.Zero;
public AnimationTests()
{
}
[SetUp]
public void Setup()
{
animUUID1 = UUID.Random();
animUUID2 = UUID.Random();
@ -58,7 +60,7 @@ namespace OpenSim.Framework.Tests
// throw new NotImplementedException();
}
[Fact]
[Test]
public void AnimationOSDTest()
{
Assert.True(anim1.AnimID==animUUID1 && anim1.ObjectID == objUUID1 && anim1.SequenceNum ==1, "The Animation Constructor didn't set the fields correctly");

View file

@ -25,11 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework.Tests
{
@ -44,7 +40,7 @@ namespace OpenSim.Framework.Tests
// throw new NotImplementedException();
}
[Fact]
[Test]
public void TestContainsReferences()
{
CheckContainsReferences(AssetType.Bodypart, true);

View file

@ -25,8 +25,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
using OpenMetaverse;
@ -38,6 +36,11 @@ namespace OpenSim.Framework.Tests
private UUID cacheItemUUID;
public CacheTests()
{
}
[SetUp]
public void Setup()
{
cache = new Cache();
cache = new Cache(CacheMedium.Memory,CacheStrategy.Aggressive,CacheFlags.AllowUpdate);
@ -54,7 +57,7 @@ namespace OpenSim.Framework.Tests
throw new NotImplementedException();
}
[Fact]
[Test]
public void TestRetreive()
{
CacheItemBase citem = (CacheItemBase)cache.Get(cacheItemUUID.ToString());
@ -63,7 +66,7 @@ namespace OpenSim.Framework.Tests
Assert.True(data[0] == 255, "Cached Item element should be 255");
}
[Fact]
[Test]
public void TestNotInCache()
{
UUID randomNotIn = UUID.Random();
@ -76,7 +79,7 @@ namespace OpenSim.Framework.Tests
}
[Fact]
[Test]
public void ExpireItemManually()
{
UUID ImmediateExpiryUUID = UUID.Random();
@ -91,7 +94,7 @@ namespace OpenSim.Framework.Tests
Assert.True(citem == null, "Item should not be in Cache because we manually invalidated it");
}
[Fact]
[Test]
public void ClearCacheTest()
{
UUID ImmediateExpiryUUID = UUID.Random();
@ -106,7 +109,7 @@ namespace OpenSim.Framework.Tests
Assert.True(citem == null, "Item should not be in Cache because we manually invalidated it");
}
[Fact]
[Test]
public void CacheItemMundane()
{
UUID Random1 = UUID.Random();

View file

@ -25,14 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
namespace OpenSim.Framework.Tests
{
public class LocationTest
{
[Fact]
[Test]
public void locationRegionHandleRegionHandle()
{
//1099511628032000
@ -47,7 +44,7 @@ namespace OpenSim.Framework.Tests
Assert.True(TestLocation1 != TestLocation2);
}
[Fact]
[Test]
public void locationXYRegionHandle()
{
Location TestLocation1 = new Location(255000,256000);

View file

@ -25,8 +25,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
using OpenMetaverse;
using System.Globalization;
@ -36,7 +34,7 @@ namespace OpenSim.Framework.Tests
{
private bool m_RegionSettingsOnSaveEventFired;
[Fact]
[Test]
public void ChildAgentDataUpdate01()
{
// code coverage
@ -44,7 +42,7 @@ namespace OpenSim.Framework.Tests
Assert.False(cadu.alwaysrun, "Default is false");
}
[Fact]
[Test]
public void AgentPositionTest01()
{
UUID AgentId1 = UUID.Random();
@ -125,7 +123,7 @@ namespace OpenSim.Framework.Tests
Assert.True(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
}
[Fact]
[Test]
public void RegionSettingsTest01()
{
RegionSettings settings = new RegionSettings();
@ -147,7 +145,7 @@ namespace OpenSim.Framework.Tests
m_RegionSettingsOnSaveEventFired = true;
}
[Fact]
[Test]
public void InventoryItemBaseConstructorTest01()
{
InventoryItemBase b1 = new InventoryItemBase();
@ -167,7 +165,7 @@ namespace OpenSim.Framework.Tests
}
[Fact]
[Test]
public void AssetMetaDataNonNullContentTypeTest01()
{
AssetMetadata assetMetadata = new AssetMetadata();
@ -181,7 +179,7 @@ namespace OpenSim.Framework.Tests
assetMetadata.CreationDate = fixedTime;
}
[Fact]
[Test]
public void EstateSettingsMundateTests()
{
EstateSettings es = new EstateSettings();
@ -229,7 +227,7 @@ namespace OpenSim.Framework.Tests
}
[Fact]
[Test]
public void InventoryFolderBaseConstructorTest01()
{
UUID uuid1 = UUID.Random();
@ -243,7 +241,7 @@ namespace OpenSim.Framework.Tests
Assert.True(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field.");
}
[Fact]
[Test]
public void AsssetBaseConstructorTest01()
{
AssetBase abase = new AssetBase();
@ -271,7 +269,7 @@ namespace OpenSim.Framework.Tests
Assert.True(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property");
}
[Fact]
[Test]
public void CultureSetCultureTest01()
{
CultureInfo ci = new CultureInfo("en-US", false);

View file

@ -25,15 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
using OpenMetaverse;
namespace OpenSim.Framework.Tests
{
public class PrimeNumberHelperTests
public class PrimeNumberHelperTests
{
[Fact]
[Test]
public void TestGetPrime()
{
int prime1 = PrimeNumberHelper.GetPrime(7919);
@ -45,7 +41,7 @@ namespace OpenSim.Framework.Tests
}
[Fact]
[Test]
public void Test1000SmallPrimeNumbers()
{
int[] primes = {

View file

@ -25,15 +25,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Xunit;
using OpenSim.Framework;
using OpenMetaverse;
namespace OpenSim.Framework.Tests
{
public class UtilTests
{
// [Fact]
// [Test]
// public void VectorOperationTests()
// {
// Vector3 v1, v2;
@ -137,7 +135,7 @@ namespace OpenSim.Framework.Tests
// }
// }
[Fact]
[Test]
public void UUIDTests()
{
Assert.True(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf"),
@ -152,24 +150,24 @@ namespace OpenSim.Framework.Tests
"UUIDs with wrong format are recognized as correct UUIDs.");
}
[Fact]
[Test]
public void GetHashGuidTests()
{
string string1 = "This is one string";
string string2 = "This is another";
// Two consecutive runs should equal the same
Assert.Equal(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret1"));
Assert.Equal(Util.GetHashGuid(string2, "secret1"), Util.GetHashGuid(string2, "secret1"));
Assert.AreEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret1"));
Assert.AreEqual(Util.GetHashGuid(string2, "secret1"), Util.GetHashGuid(string2, "secret1"));
// Varying data should not eqal the same
Assert.NotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string2, "secret1"));
Assert.That(Util.GetHashGuid(string2, "secret1"), Is.Not.EqualTo(Util.GetHashGuid(string1, "secret1")));
// Varying secrets should not eqal the same
Assert.NotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2"));
Assert.That(Util.GetHashGuid(string1, "secret2"), Is.Not.EqualTo(Util.GetHashGuid(string1, "secret1")));
}
[Fact]
[Test]
public void SLUtilTypeConvertTests()
{
int[] assettypes = new int[]{-1,0,1,2,3,5,6,7,8,10,11,12,13,17,18,19,20,21,22,24,25};
@ -277,7 +275,7 @@ namespace OpenSim.Framework.Tests
}
}
[Fact]
[Test]
public void FakeParcelIDTests()
{
byte[] hexBytes8 = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };

View file

@ -25,16 +25,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using OpenMetaverse;
using NUnit.Framework;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors;
using OpenSim.Tests.Common;
@ -44,10 +37,6 @@ namespace Robust.Tests
[TestFixture]
public class InventoryClient
{
// private static readonly ILog m_log =
// LogManager.GetLogger(
// MethodBase.GetCurrentMethod().DeclaringType);
private UUID m_userID = new UUID("00000000-0000-0000-0000-333333333333");
private UUID m_rootFolderID;
private UUID m_notecardsFolder;
@ -76,12 +65,12 @@ namespace Robust.Tests
Assert.IsTrue(success, "Failed to create user inventory");
m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID;
Assert.AreNotEqual(m_rootFolderID, UUID.Zero, "Root folder ID must not be UUID.Zero");
Assert.That(UUID.Zero, Is.Not.EqualTo(m_rootFolderID), "Root folder ID must not be UUID.Zero");
InventoryFolderBase of = m_Connector.GetFolderForType(m_userID, FolderType.Object);
Assert.IsNotNull(of, "Failed to retrieve Objects folder");
m_objectsFolder = of.ID;
Assert.AreNotEqual(m_objectsFolder, UUID.Zero, "Objects folder ID must not be UUID.Zero");
Assert.That(UUID.Zero, Is.Not.EqualTo(m_objectsFolder), "Objects folder ID must not be UUID.Zero");
// Add an object
InventoryItemBase item = new InventoryItemBase(new UUID("b0000000-0000-0000-0000-00000000000b"), m_userID);
@ -96,7 +85,7 @@ namespace Robust.Tests
InventoryFolderBase ncf = m_Connector.GetFolderForType(m_userID, FolderType.Notecard);
Assert.IsNotNull(of, "Failed to retrieve Notecards folder");
m_notecardsFolder = ncf.ID;
Assert.AreNotEqual(m_notecardsFolder, UUID.Zero, "Notecards folder ID must not be UUID.Zero");
Assert.That(UUID.Zero, Is.Not.EqualTo(m_notecardsFolder), "Notecards folder ID must not be UUID.Zero");
m_notecardsFolder = ncf.ID;
// Add a notecard
@ -148,7 +137,7 @@ namespace Robust.Tests
coll = m_Connector.GetFolderContent(m_userID, folder.ID);
Assert.IsNotNull(coll, "Failed to retrieve contents of Test Folder");
Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2, "Test Folder is expected to have exactly 2 things inside");
Assert.That(coll.Items.Count + coll.Folders.Count, Is.EqualTo(2), "Test Folder is expected to have exactly 2 things inside");
}
@ -161,7 +150,7 @@ namespace Robust.Tests
// Prefetch Notecard 1, will be cached from here on
InventoryItemBase item = m_Connector.GetItem(m_userID, new UUID("10000000-0000-0000-0000-000000000001"));
Assert.NotNull(item, "Failed to get Notecard 1");
Assert.AreEqual("Test Notecard 1", item.Name, "Wrong name for Notecard 1");
Assert.That(item.Name, Is.EqualTo("Test Notecard 1"), "Wrong name for Notecard 1");
UUID[] uuids = new UUID[2];
uuids[0] = item.ID;
@ -182,7 +171,7 @@ namespace Robust.Tests
items = m_Connector.GetMultipleItems(m_userID, uuids);
Assert.NotNull(items, "(Three times) Failed to get multiple items");
Assert.IsTrue(items.Length == 2, "(Three times) Requested 2 items, but didn't receive 2 items");
Assert.AreEqual("Test Notecard 1", items[0].Name, "(Three times) Wrong name for Notecard 1");
Assert.That(items[0].Name, Is.EqualTo("Test Notecard 1"), "(Three times) Wrong name for Notecard 1");
Assert.IsNull(items[1], "(Three times) Expecting 2nd item to be null");
// Now both don't exist
@ -197,9 +186,8 @@ namespace Robust.Tests
items = m_Connector.GetMultipleItems(m_userID, uuids);
Assert.NotNull(items, "(Four times) Failed to get multiple items");
Assert.IsTrue(items.Length == 2, "(Four times) Requested 2 items, but didn't receive 2 items");
Assert.AreEqual("Some Object", items[1].Name, "(Four times) Wrong name for Some Object");
Assert.That(items[1].Name, Is.EqualTo("Some Object"), "(Four times) Wrong name for Some Object");
Assert.IsNull(items[0], "(Four times) Expecting 1st item to be null");
}
}
}