diff --git a/OpenSim/Capabilities/CapsHandlers.cs b/OpenSim/Capabilities/CapsHandlers.cs index c63fee2ae3..dade92ddd1 100644 --- a/OpenSim/Capabilities/CapsHandlers.cs +++ b/OpenSim/Capabilities/CapsHandlers.cs @@ -47,7 +47,8 @@ namespace OpenSim.Framework.Capabilities private IHttpServer m_httpListener; private string m_httpListenerHostName; private uint m_httpListenerPort; - private readonly string m_baseURL; + + public readonly string BaseURL; /// /// CapsHandlers is a cap handler container but also takes @@ -58,14 +59,14 @@ namespace OpenSim.Framework.Capabilities /// host name of the HTTP server /// HTTP port public CapsHandlers(IHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) - { + { m_httpListener = httpListener; m_httpListenerHostName = httpListenerHostname; m_httpListenerPort = httpListenerPort; if (httpListener != null && httpListener.UseSSL) - m_baseURL = $"https://{m_httpListenerHostName}:{m_httpListenerPort}"; + BaseURL = $"https://{m_httpListenerHostName}:{m_httpListenerPort}"; else - m_baseURL = $"http://{m_httpListenerHostName}:{m_httpListenerPort}"; + BaseURL = $"http://{m_httpListenerHostName}:{m_httpListenerPort}"; } /// @@ -178,9 +179,9 @@ namespace OpenSim.Framework.Capabilities lock (m_capsHandlers) { foreach (KeyValuePair kvp in m_capsSimpleHandlers) - caps[kvp.Key] = m_baseURL + kvp.Value.Path; + caps[kvp.Key] = BaseURL + kvp.Value.Path; foreach (KeyValuePair kvp in m_capsHandlers) - caps[kvp.Key] = m_baseURL + kvp.Value.Path; + caps[kvp.Key] = BaseURL + kvp.Value.Path; } return caps; } @@ -195,12 +196,12 @@ namespace OpenSim.Framework.Capabilities if (m_capsSimpleHandlers.TryGetValue(capsName, out ISimpleStreamHandler shdr)) { - caps[capsName] = m_baseURL + shdr.Path; + caps[capsName] = BaseURL + shdr.Path; continue; } if (m_capsHandlers.TryGetValue(capsName, out IRequestHandler chdr)) { - caps[capsName] = m_baseURL + chdr.Path; + caps[capsName] = BaseURL + chdr.Path; } } } @@ -208,6 +209,19 @@ namespace OpenSim.Framework.Capabilities return caps; } + public Dictionary GetCapsLocalPaths() + { + Dictionary caps = new(); + lock (m_capsHandlers) + { + foreach (KeyValuePair kvp in m_capsSimpleHandlers) + caps[kvp.Key] = kvp.Value.Path; + foreach (KeyValuePair kvp in m_capsHandlers) + caps[kvp.Key] = kvp.Value.Path; + } + return caps; + } + public void GetCapsDetailsLLSDxml(HashSet requestedCaps, osUTF8 sb) { lock (m_capsHandlers) @@ -218,9 +232,9 @@ namespace OpenSim.Framework.Capabilities foreach (string capsName in requestedCaps) { if (m_capsSimpleHandlers.TryGetValue(capsName, out ISimpleStreamHandler shdr)) - LLSDxmlEncode2.AddElem(capsName, m_baseURL + shdr.Path, sb); + LLSDxmlEncode2.AddElem(capsName, BaseURL + shdr.Path, sb); else if (m_capsHandlers.TryGetValue(capsName, out IRequestHandler chdr)) - LLSDxmlEncode2.AddElem(capsName, m_baseURL + chdr.Path, sb); + LLSDxmlEncode2.AddElem(capsName, BaseURL + chdr.Path, sb); } } } diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index 3fd63a0d16..d04b179647 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs @@ -26,9 +26,7 @@ */ using System; -using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Reflection; using System.Text; using log4net; @@ -36,7 +34,6 @@ using Nini.Config; using Mono.Addins; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; @@ -50,19 +47,16 @@ namespace OpenSim.Region.CoreModules.Framework { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private string m_showCapsCommandFormat = " {0,-38} {1,-60}\n"; + private static readonly string m_showCapsCommandFormat = " {0,-38} {1,-60}\n"; protected Scene m_scene; /// /// Each agent has its own capabilities handler. /// - protected Dictionary m_capsObjects = new Dictionary(); - - protected Dictionary m_capsPaths = new Dictionary(); - - protected Dictionary> m_childrenSeeds - = new Dictionary>(); + protected readonly Dictionary m_capsObjects = new(); + protected readonly Dictionary m_capsPaths = new(); + protected readonly Dictionary> m_childrenSeeds = new(); public void Initialise(IConfigSource source) { @@ -296,7 +290,7 @@ namespace OpenSim.Region.CoreModules.Framework if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) return; - StringBuilder capsReport = new StringBuilder(); + StringBuilder capsReport = new(); capsReport.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); lock (m_capsObjects) @@ -308,13 +302,12 @@ namespace OpenSim.Region.CoreModules.Framework if(m_scene.TryGetScenePresence(caps.AgentID, out ScenePresence sp) && sp!=null) name = sp.Name; capsReport.AppendFormat("** Circuit {0}; {1} {2}:\n", kvp.Key, caps.AgentID,name); + capsReport.AppendFormat("** Base URL {0}\n", caps.CapsHandlers.BaseURL); - for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) - { - Uri uri = new Uri(kvp2.Value.ToString()); - capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); - } - + Dictionary capsPaths = caps.CapsHandlers.GetCapsLocalPaths(); + foreach(KeyValuePair kvp2 in capsPaths) + capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value); + foreach (KeyValuePair kvp2 in caps.GetPollHandlers()) capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value.Url);