MapImageService: added an additional security check for OSGrid and other grids like it.
parent
7aa25c6762
commit
e4e754ee93
|
@ -33,17 +33,24 @@ using System.Xml;
|
||||||
|
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using OpenMetaverse;
|
||||||
|
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenSim.Server.Base;
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
using OpenSim.Server.Handlers.Base;
|
using OpenSim.Server.Handlers.Base;
|
||||||
|
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
|
||||||
namespace OpenSim.Server.Handlers.MapImage
|
namespace OpenSim.Server.Handlers.MapImage
|
||||||
{
|
{
|
||||||
public class MapAddServiceConnector : ServiceConnector
|
public class MapAddServiceConnector : ServiceConnector
|
||||||
{
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private IMapImageService m_MapService;
|
private IMapImageService m_MapService;
|
||||||
|
private IGridService m_GridService;
|
||||||
private string m_ConfigName = "MapImageService";
|
private string m_ConfigName = "MapImageService";
|
||||||
|
|
||||||
public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) :
|
public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||||
|
@ -53,16 +60,26 @@ namespace OpenSim.Server.Handlers.MapImage
|
||||||
if (serverConfig == null)
|
if (serverConfig == null)
|
||||||
throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
|
throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
|
||||||
|
|
||||||
string gridService = serverConfig.GetString("LocalServiceModule",
|
string mapService = serverConfig.GetString("LocalServiceModule",
|
||||||
String.Empty);
|
String.Empty);
|
||||||
|
|
||||||
if (gridService == String.Empty)
|
if (mapService == String.Empty)
|
||||||
throw new Exception("No LocalServiceModule in config file");
|
throw new Exception("No LocalServiceModule in config file");
|
||||||
|
|
||||||
Object[] args = new Object[] { config };
|
Object[] args = new Object[] { config };
|
||||||
m_MapService = ServerUtils.LoadPlugin<IMapImageService>(gridService, args);
|
m_MapService = ServerUtils.LoadPlugin<IMapImageService>(mapService, args);
|
||||||
|
|
||||||
|
string gridService = serverConfig.GetString("GridService", String.Empty);
|
||||||
|
if (gridService != string.Empty)
|
||||||
|
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
|
||||||
|
|
||||||
|
if (m_GridService != null)
|
||||||
|
m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is ON");
|
||||||
|
else
|
||||||
|
m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF");
|
||||||
|
|
||||||
|
server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService));
|
||||||
|
|
||||||
server.AddStreamHandler(new MapServerPostHandler(m_MapService));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +87,13 @@ namespace OpenSim.Server.Handlers.MapImage
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private IMapImageService m_MapService;
|
private IMapImageService m_MapService;
|
||||||
|
private IGridService m_GridService;
|
||||||
|
|
||||||
public MapServerPostHandler(IMapImageService service) :
|
public MapServerPostHandler(IMapImageService service, IGridService grid) :
|
||||||
base("POST", "/map")
|
base("POST", "/map")
|
||||||
{
|
{
|
||||||
m_MapService = service;
|
m_MapService = service;
|
||||||
|
m_GridService = grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
|
@ -105,6 +124,25 @@ namespace OpenSim.Server.Handlers.MapImage
|
||||||
// if (request.ContainsKey("TYPE"))
|
// if (request.ContainsKey("TYPE"))
|
||||||
// type = request["TYPE"].ToString();
|
// type = request["TYPE"].ToString();
|
||||||
|
|
||||||
|
if (m_GridService != null)
|
||||||
|
{
|
||||||
|
GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize);
|
||||||
|
if (r != null)
|
||||||
|
{
|
||||||
|
if (r.ExternalEndPoint.Address != httpRequest.RemoteIPEndPoint.Address)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue", httpRequest.RemoteIPEndPoint.Address);
|
||||||
|
return FailureResult("IP address of caller does not match IP address of registered region");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue", httpRequest.RemoteIPEndPoint.Address);
|
||||||
|
return FailureResult("Region not found at given coordinates");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
byte[] data = Convert.FromBase64String(request["DATA"].ToString());
|
byte[] data = Convert.FromBase64String(request["DATA"].ToString());
|
||||||
|
|
||||||
string reason = string.Empty;
|
string reason = string.Empty;
|
||||||
|
|
|
@ -279,6 +279,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService"
|
LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService"
|
||||||
; Set this if you want to change the default
|
; Set this if you want to change the default
|
||||||
; TilesStoragePath = "maptiles"
|
; TilesStoragePath = "maptiles"
|
||||||
|
;
|
||||||
|
; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002),
|
||||||
|
; you may want to set this. Otherwise, don't set it, because it's already protected.
|
||||||
|
; GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||||
|
|
||||||
[GridInfoService]
|
[GridInfoService]
|
||||||
; These settings are used to return information on a get_grid_info call.
|
; These settings are used to return information on a get_grid_info call.
|
||||||
|
|
|
@ -254,6 +254,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService"
|
LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService"
|
||||||
; Set this if you want to change the default
|
; Set this if you want to change the default
|
||||||
; TilesStoragePath = "maptiles"
|
; TilesStoragePath = "maptiles"
|
||||||
|
;
|
||||||
|
; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002),
|
||||||
|
; you may want to set this. Otherwise, don't set it, because it's already protected.
|
||||||
|
; GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||||
|
|
||||||
|
|
||||||
[GridInfoService]
|
[GridInfoService]
|
||||||
|
|
Loading…
Reference in New Issue