cosmetics

This commit is contained in:
UbitUmarov
2022-12-16 19:38:10 +00:00
parent 41b718626f
commit 38ddb92cc3
8 changed files with 136 additions and 144 deletions

View File

@@ -29,15 +29,12 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.IO;
using System.Reflection;
using System.Threading;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
// using OpenSim.Region.Framework.Interfaces;
@@ -54,26 +51,23 @@ namespace OpenSim.Framework.Capabilities
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_httpListenerHostName;
private uint m_httpListenPort;
private readonly string m_httpListenerHostName;
private readonly uint m_httpListenPort;
/// <summary>
/// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester.
/// </summary>
private string m_capsObjectPath;
private readonly string m_capsObjectPath;
public string CapsObjectPath { get { return m_capsObjectPath; } }
private CapsHandlers m_capsHandlers;
private readonly CapsHandlers m_capsHandlers;
private readonly ConcurrentDictionary<string, PollServiceEventArgs> m_pollServiceHandlers = new ();
private readonly Dictionary<string, string> m_externalCapsHandlers = new ();
private ConcurrentDictionary<string, PollServiceEventArgs> m_pollServiceHandlers
= new ConcurrentDictionary<string, PollServiceEventArgs>();
private Dictionary<string, string> m_externalCapsHandlers = new Dictionary<string, string>();
private IHttpServer m_httpListener;
private UUID m_agentID;
private string m_regionName;
private ManualResetEvent m_capsActive = new ManualResetEvent(false);
private readonly IHttpServer m_httpListener;
private readonly UUID m_agentID;
private readonly string m_regionName;
private ManualResetEvent m_capsActive = new(false);
public UUID AgentID
{
@@ -142,7 +136,7 @@ namespace OpenSim.Framework.Capabilities
m_httpListenPort = httpPort;
if (httpServer != null && httpServer.UseSSL)
if (httpServer is not null && httpServer.UseSSL)
{
m_httpListenPort = httpServer.SSLPort;
httpListen = httpServer.SSLCommonName;
@@ -167,7 +161,7 @@ namespace OpenSim.Framework.Capabilities
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
public void Dispose(bool disposing)
{
Flags = CapsFlags.None;
if (m_capsActive != null)
@@ -197,9 +191,9 @@ namespace OpenSim.Framework.Capabilities
public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler)
{
// m_log.DebugFormat(
// "[CAPS]: Registering handler with name {0}, url {1} for {2}",
// capName, pollServiceHandler.Url, m_agentID, m_regionName);
//m_log.DebugFormat(
// "[CAPS]: Registering handler with name {0}, url {1} for {2}",
// capName, pollServiceHandler.Url, m_agentID, m_regionName);
if(!m_pollServiceHandlers.TryAdd(capName, pollServiceHandler))
{
@@ -211,19 +205,19 @@ namespace OpenSim.Framework.Capabilities
m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler);
// uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
// string protocol = "http";
// string hostName = m_httpListenerHostName;
//
// if (MainServer.Instance.UseSSL)
// {
// hostName = MainServer.Instance.SSLCommonName;
// port = MainServer.Instance.SSLPort;
// protocol = "https";
// }
//uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
//string protocol = "http";
//string hostName = m_httpListenerHostName;
// RegisterHandler(
// capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url));
//if (MainServer.Instance.UseSSL)
//{
// hostName = MainServer.Instance.SSLCommonName;
// port = MainServer.Instance.SSLPort;
// protocol = "https";
//}
//RegisterHandler(
// capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url));
}
/// <summary>
@@ -253,7 +247,6 @@ namespace OpenSim.Framework.Capabilities
}
m_pollServiceHandlers.Clear();
}
public bool TryGetPollHandler(string name, out PollServiceEventArgs pollHandler)
{
return m_pollServiceHandlers.TryGetValue(name, out pollHandler);
@@ -281,7 +274,7 @@ namespace OpenSim.Framework.Capabilities
continue;
string hostName = m_httpListenerHostName;
uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
uint port = (MainServer.Instance is null) ? 0 : MainServer.Instance.Port;
string protocol = "http";
if (MainServer.Instance.UseSSL)

View File

@@ -1565,6 +1565,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (IsClientAuthorized(uccp, out AuthenticateResponse sessionInfo))
{
AgentCircuitData aCircuit = m_circuitManager.GetAgentCircuitData(uccp.CircuitCode.Code);
if(!string.IsNullOrEmpty(aCircuit.IPAddress))
{
try
{
IPAddress aIP = IPAddress.Parse(aCircuit.IPAddress);
if(!endPoint.Address.Equals(aIP))
m_log.Debug($"[LLUDPSERVER]: HandleUseCircuitCode IP mismatch {endPoint.Address} != {aCircuit.IPAddress}");
}
catch
{
m_log.Debug($"[LLUDPSERVER]: HandleUseCircuitCode could not compare IP {endPoint.Address} {aCircuit.IPAddress}");
}
}
// Begin the process of adding the client to the simulator
client = AddClient(
@@ -1683,11 +1696,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo)
{
UUID agentID = useCircuitCode.CircuitCode.ID;
UUID sessionID = useCircuitCode.CircuitCode.SessionID;
uint circuitCode = useCircuitCode.CircuitCode.Code;
sessionInfo = m_circuitManager.AuthenticateSession(sessionID, agentID, circuitCode);
UseCircuitCodePacket.CircuitCodeBlock ucb = useCircuitCode.CircuitCode;
sessionInfo = m_circuitManager.AuthenticateSession(ucb.SessionID, ucb.ID, ucb.Code);
return sessionInfo.Authorised;
}

View File

@@ -960,76 +960,83 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <param name="saveAllScripted"></param>
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState)
{
if(!grp.HasGroupChanged)
{
if (DebugLevel > 0)
{
m_log.Debug(
$"[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {grp.UUID}, attachpoint {grp.AttachmentPoint}");
}
return;
}
grp.HasGroupChanged = false;
if (m_invAccessModule is null)
return;
if (grp.FromItemID.IsZero())
{
// We can't save temp attachments
grp.HasGroupChanged = false;
return;
}
if(sp.IsNPC)
return;
if (grp.HasGroupChanged)
if (sp.IsNPC)
{
m_log.Debug(
$"[ATTACHMENTS MODULE]: Updating asset for attachment {grp.UUID}, attachpoint {grp.AttachmentPoint}");
return;
}
m_log.Debug($"[ATTACHMENTS MODULE]: Updating asset for attachment {grp.UUID}, attachpoint {grp.AttachmentPoint}");
InventoryItemBase item = m_scene.InventoryService.GetItem(sp.UUID, grp.FromItemID);
if (item is not null)
{
if (item.Owner.NotEqual(sp.UUID))
{
m_log.Debug($"[ATTACHMENTS MODULE]: Updating asset for attachment owner mismach: agent {sp.UUID}, owner{item.Owner}");
return;
}
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState);
InventoryItemBase item = m_scene.InventoryService.GetItem(sp.UUID, grp.FromItemID);
if (item is not null)
{
// attach is rez, need to update permissions
item.Flags &= ~(uint)(InventoryItemFlags.ObjectSlamPerm | InventoryItemFlags.ObjectOverwriteBase |
InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup |
InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
// attach is rez, need to update permissions
item.Flags &= ~(uint)(InventoryItemFlags.ObjectSlamPerm | InventoryItemFlags.ObjectOverwriteBase |
InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup |
InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
uint permsBase = (uint)(PermissionMask.Copy | PermissionMask.Transfer |
PermissionMask.Modify | PermissionMask.Move |
PermissionMask.Export | PermissionMask.FoldedMask);
permsBase &= grp.CurrentAndFoldedNextPermissions();
permsBase |= (uint)PermissionMask.Move;
item.BasePermissions = permsBase;
item.CurrentPermissions = permsBase;
item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask | (uint)PermissionMask.Move;
item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
item.CurrentPermissions &=
((uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer |
(uint)PermissionMask.Modify |
(uint)PermissionMask.Move |
(uint)PermissionMask.Export |
(uint)PermissionMask.FoldedMask); // Preserve folded permissions ??
uint permsBase = (uint)(PermissionMask.Copy | PermissionMask.Transfer |
PermissionMask.Modify | PermissionMask.Move |
PermissionMask.Export | PermissionMask.FoldedMask);
string name = grp.RootPart.Name;
string desc = grp.RootPart.Description;
permsBase &= grp.CurrentAndFoldedNextPermissions();
permsBase |= (uint)PermissionMask.Move;
item.BasePermissions = permsBase;
item.CurrentPermissions = permsBase;
item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask | (uint)PermissionMask.Move;
item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask;
item.GroupPermissions = permsBase & grp.RootPart.GroupMask;
item.CurrentPermissions &=
((uint)PermissionMask.Copy |
(uint)PermissionMask.Transfer |
(uint)PermissionMask.Modify |
(uint)PermissionMask.Move |
(uint)PermissionMask.Export |
(uint)PermissionMask.FoldedMask); // Preserve folded permissions ??
AssetBase asset = m_scene.CreateAsset(
name, desc,
(sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml),
sp.UUID);
string name = grp.RootPart.Name;
string desc = grp.RootPart.Description;
item.Name = name;
item.Description = desc;
item.AssetID = asset.FullID;
item.AssetType = (int)AssetType.Object;
item.InvType = (int)InventoryType.Object;
m_invAccessModule?.UpdateInventoryItemAsset(sp.UUID, item, asset);
AssetBase asset = m_scene.CreateAsset(name, desc, (sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml), sp.UUID);
item.Name = name;
item.Description = desc;
item.AssetID = asset.FullID;
item.AssetType = (int)AssetType.Object;
item.InvType = (int)InventoryType.Object;
if(m_invAccessModule.UpdateInventoryItemAsset(sp.UUID, item, asset))
sp.ControllingClient?.SendInventoryItemCreateUpdate(item, 0);
}
grp.HasGroupChanged = false; // Prevent it being saved over and over
}
else if (DebugLevel > 0)
{
m_log.Debug(
$"[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {grp.UUID}, attachpoint {grp.AttachmentPoint}");
}
}

View File

@@ -120,16 +120,6 @@ namespace OpenSim.Region.CoreModules.Framework
public void CreateCaps(UUID agentId, uint circuitCode)
{
int ts = Util.EnvironmentTickCount();
/* this as no business here...
* must be done elsewhere ( and is )
int flags = m_scene.GetUserFlags(agentId);
m_log.ErrorFormat("[CreateCaps]: banCheck {0} ", Util.EnvironmentTickCountSubtract(ts));
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
return;
*/
string capsObjectPath = GetCapsPath(agentId);
Caps caps;
lock (m_capsObjects)
@@ -138,9 +128,9 @@ namespace OpenSim.Region.CoreModules.Framework
{
if (capsObjectPath == oldCaps.CapsObjectPath)
{
// m_log.WarnFormat(
// "[CAPS]: Reusing caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ",
// agentId, m_scene.RegionInfo.RegionName, oldCaps.CapsObjectPath, capsObjectPath);
//m_log.WarnFormat(
// "[CAPS]: Reusing caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ",
// agentId, m_scene.RegionInfo.RegionName, oldCaps.CapsObjectPath, capsObjectPath);
return;
}
else
@@ -156,22 +146,19 @@ namespace OpenSim.Region.CoreModules.Framework
}
}
// m_log.DebugFormat(
// "[CAPS]: Adding capabilities for agent {0} in {1} with path {2}",
// agentId, m_scene.RegionInfo.RegionName, capsObjectPath);
//m_log.DebugFormat(
// "[CAPS]: Adding capabilities for agent {0} in {1} with path {2}",
// agentId, m_scene.RegionInfo.RegionName, capsObjectPath);
caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
(MainServer.Instance == null) ? 0: MainServer.Instance.Port,
(MainServer.Instance is null) ? 0: MainServer.Instance.Port,
capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
m_log.DebugFormat("[CreateCaps]: new caps agent {0}, circuit {1}, path {2}, time {3} ",agentId,
circuitCode,caps.CapsObjectPath, Util.EnvironmentTickCountSubtract(ts));
m_log.Debug($"[CreateCaps]: new caps agent {agentId}, circuit {circuitCode}, path {caps.CapsObjectPath}");
m_capsObjects[circuitCode] = caps;
}
m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
// m_log.ErrorFormat("[CreateCaps]: end {0} ", Util.EnvironmentTickCountSubtract(ts));
}
public void RemoveCaps(UUID agentId, uint circuitCode)
@@ -299,8 +286,7 @@ namespace OpenSim.Region.CoreModules.Framework
{
foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
{
uint x, y;
Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
Util.RegionHandleToRegionLoc(kvp.Key, out uint x, out uint y);
m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
}
}

View File

@@ -423,22 +423,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset)
{
if (item != null && item.Owner == ownerID && asset != null)
if (item is not null && item.Owner.Equals(ownerID) && asset is not null)
{
// m_log.DebugFormat(
// "[INVENTORY ACCESS MODULE]: Updating item {0} {1} with new asset {2}",
// item.Name, item.ID, asset.ID);
//m_log.DebugFormat(
// "[INVENTORY ACCESS MODULE]: Updating item {0} {1} with new asset {2}",
// item.Name, item.ID, asset.ID);
m_Scene.AssetService.Store(asset);
m_Scene.InventoryService.UpdateItem(item);
return true;
}
else
{
m_log.ErrorFormat("[INVENTORY ACCESS MODULE]: Given invalid item for inventory update: {0}",
(item == null || asset == null? "null item or asset" : "wrong owner"));
(item is null || asset is null? "null item or asset" : "wrong owner"));
return false;
}
}

View File

@@ -196,7 +196,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
if (m_scenes.TryGetValue(destination.RegionID, out Scene destScene))
{
// m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName);
//m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName);
return destScene.NewUserConnection(aCircuit, teleportFlags, source, out reason);
}
@@ -268,7 +268,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
}
return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, features, out reason);
}

View File

@@ -3949,7 +3949,7 @@ namespace OpenSim.Region.Framework.Scenes
//
// TeleportFlags.ViaGodlikeLure - Border Crossing
// TeleportFlags.ViaLogin - Login
// TeleportFlags.TeleportFlags.ViaLure - Teleport request sent by another user
// TeleportFlags.ViaLure - Teleport request sent by another user
// TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport
// Don't disable this log message - it's too helpful
@@ -3969,7 +3969,7 @@ namespace OpenSim.Region.Framework.Scenes
(source is null) ? "" : string.Format("From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI is null) ? "" : " @ " + source.ServerURI)
);
// m_log.DebugFormat("NewUserConnection stack {0}", Environment.StackTrace);
//m_log.DebugFormat("NewUserConnection stack {0}", Environment.StackTrace);
if (!LoginsEnabled)
{
@@ -4048,15 +4048,16 @@ namespace OpenSim.Region.Framework.Scenes
// vulnerable to an issue when a viewer quits a region without sending a proper logout but then
// re-establishes the connection on a relogin. This could wrongly set the DoNotCloseAfterTeleport
// flag when no teleport had taken place (and hence no close was going to come).
// if (!acd.ChildrenCapSeeds.ContainsKey(RegionInfo.RegionHandle))
// {
// m_log.DebugFormat(
// "[SCENE]: Setting DoNotCloseAfterTeleport for child scene presence {0} in {1} because source will attempt close.",
// sp.Name, Name);
//
// sp.DoNotCloseAfterTeleport = true;
// }
// else if (EntityTransferModule.IsInTransit(sp.UUID))
//if (!acd.ChildrenCapSeeds.ContainsKey(RegionInfo.RegionHandle))
//{
// m_log.DebugFormat(
// "[SCENE]: Setting DoNotCloseAfterTeleport for child scene presence {0} in {1} because source will attempt close.",
// sp.Name, Name);
// sp.DoNotCloseAfterTeleport = true;
//}
//else if (EntityTransferModule.IsInTransit(sp.UUID))
sp.LifecycleState = ScenePresenceState.Running;
@@ -6035,8 +6036,6 @@ Environment.Exit(1);
return false;
}
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(agentID);
// Fake AgentCircuitData to keep IAuthorizationModule smiling
aCircuit ??= new AgentCircuitData()

View File

@@ -114,10 +114,11 @@ namespace OpenSim.Services.PresenceService
(presence == null) ? null : presence.RegionID.ToString());
bool ret = m_Database.Delete("SessionID", sessionID.ToString());
if(inCache && presence != null)
if(inCache)
{
BySessionCache.Remove(presence.SessionID);
ByUserCache.Remove(presence.UserID);
BySessionCache.Remove(sessionID);
if(presence is not null)
ByUserCache.Remove(presence.UserID);
}
return ret;
}
@@ -125,7 +126,7 @@ namespace OpenSim.Services.PresenceService
public bool LogoutRegionAgents(UUID regionID)
{
PresenceData[] prevSessions = GetRegionAgents(regionID);
if ((prevSessions == null) || (prevSessions.Length == 0))
if ((prevSessions is null) || (prevSessions.Length == 0))
return true;
m_log.DebugFormat("[PRESENCE SERVICE]: Logout users in region {0}", regionID);
@@ -136,7 +137,6 @@ namespace OpenSim.Services.PresenceService
ByUserCache.Remove(pd.UserID);
}
// There's a small chance that LogoutRegionAgents() will logout different users than the
// list that was logged above, but it's unlikely and not worth dealing with.