Merge branch 'master' of /home/opensim/var/repo/opensim

integration
BlueWall 2012-04-27 12:50:31 -04:00
commit 0bf3f597fe
4 changed files with 90 additions and 6 deletions

View File

@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (sp.UserLevel < m_levelHGTeleport)
{
m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel.");
reason = "HyperGrid teleport not permitted";
reason = "Hypergrid teleport not allowed";
return false;
}

View File

@ -33,17 +33,24 @@ using System.Xml;
using Nini.Config;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Server.Handlers.MapImage
{
public class MapAddServiceConnector : ServiceConnector
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IMapImageService m_MapService;
private IGridService m_GridService;
private string m_ConfigName = "MapImageService";
public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) :
@ -53,16 +60,27 @@ namespace OpenSim.Server.Handlers.MapImage
if (serverConfig == null)
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);
if (gridService == String.Empty)
if (mapService == String.Empty)
throw new Exception("No LocalServiceModule in config file");
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");
bool proxy = serverConfig.GetBoolean("HasProxy", false);
server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy));
server.AddStreamHandler(new MapServerPostHandler(m_MapService));
}
}
@ -70,11 +88,15 @@ namespace OpenSim.Server.Handlers.MapImage
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IMapImageService m_MapService;
private IGridService m_GridService;
bool m_Proxy;
public MapServerPostHandler(IMapImageService service) :
public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) :
base("POST", "/map")
{
m_MapService = service;
m_GridService = grid;
m_Proxy = proxy;
}
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
@ -105,6 +127,27 @@ namespace OpenSim.Server.Handlers.MapImage
// if (request.ContainsKey("TYPE"))
// 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)
{
System.Net.IPAddress ipAddr = GetCallerIP(httpRequest);
if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString())
{
m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be trying to impersonate region in IP {1}", ipAddr, r.ExternalEndPoint.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. Region not found at coordinates {1}-{2}",
httpRequest.RemoteIPEndPoint.Address, x, y);
return FailureResult("Region not found at given coordinates");
}
}
byte[] data = Convert.FromBase64String(request["DATA"].ToString());
string reason = string.Empty;
@ -183,5 +226,31 @@ namespace OpenSim.Server.Handlers.MapImage
return ms.ToArray();
}
private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
{
if (!m_Proxy)
return request.RemoteIPEndPoint.Address;
// We're behind a proxy
string xff = "X-Forwarded-For";
string xffValue = request.Headers[xff.ToLower()];
if (xffValue == null || (xffValue != null && xffValue == string.Empty))
xffValue = request.Headers[xff];
if (xffValue == null || (xffValue != null && xffValue == string.Empty))
{
m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header");
return request.RemoteIPEndPoint.Address;
}
System.Net.IPEndPoint ep = Util.GetClientIPFromXFF(xffValue);
if (ep != null)
return ep.Address;
// Oops
return request.RemoteIPEndPoint.Address;
}
}
}

View File

@ -279,6 +279,13 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService"
; Set this if you want to change the default
; 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"
;
; Additionally, if you run this server behind a proxy, set this to true
; HasProxy = false
[GridInfoService]
; These settings are used to return information on a get_grid_info call.

View File

@ -254,6 +254,14 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService"
; Set this if you want to change the default
; 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"
;
; Additionally, if you run this server behind a proxy, set this to true
; HasProxy = false
[GridInfoService]