A few unmistakable bugs I saw while poking (#140)
* Invalid comparison (map to bool/int) Check for null and count properly * Fix a bad comparison. Good thing OpenSim doesn't support oblong regions. * Assuming this should throw being that an exception is being created and all... * ServerReleaseNotesModule.Initialize() returns unless capURL equals "localhost", which is almost certainly unintended. * Same for EstateAccess * Harden MapImageServicesConnector a lil bit.
This commit is contained in:
@@ -192,7 +192,7 @@ namespace OpenSim.Data.Null
|
||||
foreach (RegionData r in m_regionData.Values)
|
||||
{
|
||||
if (r.posX + r.sizeX > startX && r.posX <= endX
|
||||
&& r.posY + r.sizeX > startY && r.posY <= endY)
|
||||
&& r.posY + r.sizeY > startY && r.posY <= endY)
|
||||
ret.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
return;
|
||||
}
|
||||
|
||||
if(map == map.Count < 3)
|
||||
// Ensure we have a valid map with the expected minimum number of entries
|
||||
if (map == null || map.Count < 3)
|
||||
{
|
||||
response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
return;
|
||||
|
||||
@@ -65,8 +65,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
return;
|
||||
|
||||
m_capUrl = config.GetString("Cap_EstateAccess", string.Empty);
|
||||
if (!String.IsNullOrEmpty(m_capUrl) && m_capUrl.Equals("localhost"))
|
||||
// enable when configured (non-empty and not explicitly false/0)
|
||||
if (!String.IsNullOrEmpty(m_capUrl) &&
|
||||
!m_capUrl.Equals("false", StringComparison.OrdinalIgnoreCase) &&
|
||||
m_capUrl != "0")
|
||||
{
|
||||
m_Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
|
||||
@@ -67,8 +67,14 @@ namespace OpenSim.Region.ClientStack.LindenCaps
|
||||
return;
|
||||
|
||||
string capURL = config.GetString("Cap_ServerReleaseNotes", string.Empty);
|
||||
if (string.IsNullOrEmpty(capURL) || capURL != "localhost")
|
||||
// If capability not configured or explicitly turned off, leave disabled
|
||||
if (string.IsNullOrEmpty(capURL) ||
|
||||
capURL.Equals("false", StringComparison.OrdinalIgnoreCase) ||
|
||||
capURL == "0")
|
||||
{
|
||||
m_log.DebugFormat("[ServerReleaseNotesModule]: Cap_ServerReleaseNotes not enabled in config");
|
||||
return;
|
||||
}
|
||||
|
||||
config = source.Configs["ServerReleaseNotes"];
|
||||
if (config == null)
|
||||
@@ -76,16 +82,19 @@ namespace OpenSim.Region.ClientStack.LindenCaps
|
||||
|
||||
m_ServerReleaseNotesURL = config.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
|
||||
if (string.IsNullOrEmpty(m_ServerReleaseNotesURL))
|
||||
return;
|
||||
|
||||
Uri dummy;
|
||||
if(!Uri.TryCreate(m_ServerReleaseNotesURL,UriKind.Absolute, out dummy))
|
||||
{
|
||||
m_log.Error("[Cap_ServerReleaseNotes]: Invalid ServerReleaseNotesURL. Cap Disabled");
|
||||
m_log.Error("[ServerReleaseNotesModule]: ServerReleaseNotesURL not configured. Cap disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Uri.IsWellFormedUriString(m_ServerReleaseNotesURL, UriKind.Absolute))
|
||||
{
|
||||
m_log.ErrorFormat("[ServerReleaseNotesModule]: Invalid ServerReleaseNotesURL '{0}'. Cap Disabled", m_ServerReleaseNotesURL);
|
||||
return;
|
||||
}
|
||||
|
||||
m_enabled = true;
|
||||
m_log.InfoFormat("[ServerReleaseNotesModule]: Enabled. Redirecting ServerReleaseNotes cap to {0}", m_ServerReleaseNotesURL);
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
|
||||
@@ -26,21 +26,14 @@
|
||||
*/
|
||||
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
using OpenSim.Framework.ServiceAuth;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
namespace OpenSim.Services.Connectors
|
||||
{
|
||||
@@ -105,12 +98,12 @@ namespace OpenSim.Services.Connectors
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not include SCOPE when it's zero
|
||||
reqString = ServerUtils.BuildQueryString(
|
||||
new Dictionary<string, object>()
|
||||
{
|
||||
{"X" , x.ToString() },
|
||||
{"Y" , y.ToString() },
|
||||
{ "SCOPE" , scopeID.ToString() },
|
||||
{"Y" , y.ToString() }
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -118,7 +111,7 @@ namespace OpenSim.Services.Connectors
|
||||
try
|
||||
{
|
||||
string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/map", reqString, 10, null, false);
|
||||
if (reply.Length > 0)
|
||||
if (!string.IsNullOrEmpty(reply))
|
||||
{
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||
if(replyData.TryGetValue("Result", out object resultobj))
|
||||
@@ -133,17 +126,17 @@ namespace OpenSim.Services.Connectors
|
||||
return true;
|
||||
else if (res.Equals("failure", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
reason = replyData["Message"].ToString();
|
||||
reason = replyData.TryGetValue("Message", out var value) ? value.ToString() : "";
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile failed: {0}", reason);
|
||||
return false;
|
||||
}
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile unknown result field contents");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile reply data does not contain result field");
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile reply data does not contain result field");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -188,7 +181,7 @@ namespace OpenSim.Services.Connectors
|
||||
try
|
||||
{
|
||||
string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/map", reqString, 10, m_Auth, false);
|
||||
if (reply.Length > 0)
|
||||
if (!string.IsNullOrEmpty(reply))
|
||||
{
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||
if (replyData.TryGetValue("Result", out object resultobj))
|
||||
@@ -203,7 +196,7 @@ namespace OpenSim.Services.Connectors
|
||||
return true;
|
||||
else if (res.Equals("failure", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
reason = replyData["Message"].ToString();
|
||||
reason = replyData.TryGetValue("Message", out var value) ? value.ToString() : "";
|
||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: AddMapTile failed: {0}", reason);
|
||||
return false;
|
||||
}
|
||||
@@ -231,9 +224,7 @@ namespace OpenSim.Services.Connectors
|
||||
|
||||
public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
|
||||
{
|
||||
format = string.Empty;
|
||||
new Exception("GetMapTile method not Implemented");
|
||||
return null;
|
||||
throw new Exception("GetMapTile method not Implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user