simplify output of show caps list a bit

This commit is contained in:
UbitUmarov 2024-04-17 20:31:21 +01:00
parent 863ff6bc9f
commit 604282c482
2 changed files with 34 additions and 27 deletions

View file

@ -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;
/// <summary></summary>
/// CapsHandlers is a cap handler container but also takes
@ -58,14 +59,14 @@ namespace OpenSim.Framework.Capabilities
/// <param name="httpListenerHostname">host name of the HTTP server</param>
/// <param name="httpListenerPort">HTTP port</param>
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}";
}
/// <summary>
@ -178,9 +179,9 @@ namespace OpenSim.Framework.Capabilities
lock (m_capsHandlers)
{
foreach (KeyValuePair<string, ISimpleStreamHandler> kvp in m_capsSimpleHandlers)
caps[kvp.Key] = m_baseURL + kvp.Value.Path;
caps[kvp.Key] = BaseURL + kvp.Value.Path;
foreach (KeyValuePair<string, IRequestHandler> 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<string, string> GetCapsLocalPaths()
{
Dictionary<string, string> caps = new();
lock (m_capsHandlers)
{
foreach (KeyValuePair<string, ISimpleStreamHandler> kvp in m_capsSimpleHandlers)
caps[kvp.Key] = kvp.Value.Path;
foreach (KeyValuePair<string, IRequestHandler> kvp in m_capsHandlers)
caps[kvp.Key] = kvp.Value.Path;
}
return caps;
}
public void GetCapsDetailsLLSDxml(HashSet<string> 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);
}
}
}

View file

@ -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;
/// <summary>
/// Each agent has its own capabilities handler.
/// </summary>
protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>();
protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds
= new Dictionary<UUID, Dictionary<ulong, string>>();
protected readonly Dictionary<uint, Caps> m_capsObjects = new();
protected readonly Dictionary<UUID, string> m_capsPaths = new();
protected readonly Dictionary<UUID, Dictionary<ulong, string>> 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<string, string> capsPaths = caps.CapsHandlers.GetCapsLocalPaths();
foreach(KeyValuePair<string, string> kvp2 in capsPaths)
capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value);
foreach (KeyValuePair<string, PollServiceEventArgs> kvp2 in caps.GetPollHandlers())
capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value.Url);