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)
|
foreach (RegionData r in m_regionData.Values)
|
||||||
{
|
{
|
||||||
if (r.posX + r.sizeX > startX && r.posX <= endX
|
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);
|
ret.Add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||||||
return;
|
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;
|
response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -65,8 +65,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_capUrl = config.GetString("Cap_EstateAccess", string.Empty);
|
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;
|
m_Enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRegion(Scene scene)
|
public void AddRegion(Scene scene)
|
||||||
|
|||||||
@@ -67,8 +67,14 @@ namespace OpenSim.Region.ClientStack.LindenCaps
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
string capURL = config.GetString("Cap_ServerReleaseNotes", string.Empty);
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
config = source.Configs["ServerReleaseNotes"];
|
config = source.Configs["ServerReleaseNotes"];
|
||||||
if (config == null)
|
if (config == null)
|
||||||
@@ -76,16 +82,19 @@ namespace OpenSim.Region.ClientStack.LindenCaps
|
|||||||
|
|
||||||
m_ServerReleaseNotesURL = config.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
|
m_ServerReleaseNotesURL = config.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL);
|
||||||
if (string.IsNullOrEmpty(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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
|
m_log.InfoFormat("[ServerReleaseNotesModule]: Enabled. Redirecting ServerReleaseNotes cap to {0}", m_ServerReleaseNotesURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRegion(Scene scene)
|
public void AddRegion(Scene scene)
|
||||||
|
|||||||
@@ -26,21 +26,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using log4net;
|
using log4net;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
|
||||||
|
|
||||||
using OpenSim.Framework.ServiceAuth;
|
|
||||||
using OpenSim.Server.Base;
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
|
||||||
|
|
||||||
namespace OpenSim.Services.Connectors
|
namespace OpenSim.Services.Connectors
|
||||||
{
|
{
|
||||||
@@ -105,12 +98,12 @@ namespace OpenSim.Services.Connectors
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Do not include SCOPE when it's zero
|
||||||
reqString = ServerUtils.BuildQueryString(
|
reqString = ServerUtils.BuildQueryString(
|
||||||
new Dictionary<string, object>()
|
new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{"X" , x.ToString() },
|
{"X" , x.ToString() },
|
||||||
{"Y" , y.ToString() },
|
{"Y" , y.ToString() }
|
||||||
{ "SCOPE" , scopeID.ToString() },
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -118,7 +111,7 @@ namespace OpenSim.Services.Connectors
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/map", reqString, 10, null, false);
|
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);
|
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||||
if(replyData.TryGetValue("Result", out object resultobj))
|
if(replyData.TryGetValue("Result", out object resultobj))
|
||||||
@@ -133,17 +126,17 @@ namespace OpenSim.Services.Connectors
|
|||||||
return true;
|
return true;
|
||||||
else if (res.Equals("failure", StringComparison.InvariantCultureIgnoreCase))
|
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);
|
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile failed: {0}", reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile unknown result field contents");
|
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile unknown result field contents");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile reply data does not contain result field");
|
||||||
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile reply data does not contain result field");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -188,7 +181,7 @@ namespace OpenSim.Services.Connectors
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/map", reqString, 10, m_Auth, false);
|
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);
|
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
|
||||||
if (replyData.TryGetValue("Result", out object resultobj))
|
if (replyData.TryGetValue("Result", out object resultobj))
|
||||||
@@ -203,7 +196,7 @@ namespace OpenSim.Services.Connectors
|
|||||||
return true;
|
return true;
|
||||||
else if (res.Equals("failure", StringComparison.InvariantCultureIgnoreCase))
|
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);
|
m_log.DebugFormat("[MAP IMAGE CONNECTOR]: AddMapTile failed: {0}", reason);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -231,9 +224,7 @@ namespace OpenSim.Services.Connectors
|
|||||||
|
|
||||||
public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
|
public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
|
||||||
{
|
{
|
||||||
format = string.Empty;
|
throw new Exception("GetMapTile method not Implemented");
|
||||||
new Exception("GetMapTile method not Implemented");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user