mantis 7885: robust asset services have no cache and only accept a asset ID that is a uuid, so regions hack to cache several image formats is not possible. Robut GetTexture is very heavy unless image format is the default (j2k mime type x-j2k), since with no cache image convertions is performed on every request. Adicionally it does expose all textures if the tcp port is public. Avoid using it.

0.9.0.1-postfixes
UbitUmarov 2018-03-10 20:50:24 +00:00
parent 8c390ef3fe
commit a0d0d65c70
1 changed files with 31 additions and 68 deletions

View File

@ -134,26 +134,7 @@ namespace OpenSim.Capabilities.Handlers
// m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format); // m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format);
AssetBase texture; AssetBase texture;
string fullID = textureID.ToString();
if (format != DefaultFormat)
fullID = fullID + "-" + format;
if(!String.IsNullOrEmpty(m_RedirectURL)) if(!String.IsNullOrEmpty(m_RedirectURL))
{
// Only try to fetch locally cached textures. Misses are redirected
texture = m_assetService.GetCached(fullID);
if (texture != null)
{
if (texture.Type != (sbyte)AssetType.Texture)
{
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
return true;
}
WriteTextureData(httpRequest, httpResponse, texture, format);
return true;
}
else
{ {
string textureUrl = m_RedirectURL + "?texture_id=" + textureID.ToString(); string textureUrl = m_RedirectURL + "?texture_id=" + textureID.ToString();
m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
@ -161,19 +142,9 @@ namespace OpenSim.Capabilities.Handlers
httpResponse.RedirectLocation = textureUrl; httpResponse.RedirectLocation = textureUrl;
return true; return true;
} }
}
else // no redirect else // no redirect
{ {
// try the cache
texture = m_assetService.GetCached(fullID);
if (texture == null)
{
// m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
// Fetch locally or remotely. Misses return a 404
texture = m_assetService.Get(textureID.ToString()); texture = m_assetService.Get(textureID.ToString());
if(texture != null) if(texture != null)
{ {
if(texture.Type != (sbyte)AssetType.Texture) if(texture.Type != (sbyte)AssetType.Texture)
@ -196,19 +167,11 @@ namespace OpenSim.Capabilities.Handlers
newTexture.Flags = AssetFlags.Collectable; newTexture.Flags = AssetFlags.Collectable;
newTexture.Temporary = true; newTexture.Temporary = true;
newTexture.Local = true; newTexture.Local = true;
m_assetService.Store(newTexture);
WriteTextureData(httpRequest, httpResponse, newTexture, format); WriteTextureData(httpRequest, httpResponse, newTexture, format);
return true; return true;
} }
} }
} }
else // it was on the cache
{
// m_log.DebugFormat("[GETTEXTURE]: texture was in the cache");
WriteTextureData(httpRequest, httpResponse, texture, format);
return true;
}
}
// not found // not found
// m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); // m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found");