diff options
author | Diva Canto | 2012-04-27 09:23:56 -0700 |
---|---|---|
committer | Diva Canto | 2012-04-27 09:23:56 -0700 |
commit | e4e754ee93de0e0b6fde3b3ccd20085d3d4a09a1 (patch) | |
tree | 8f43db2c396d727cc6575528b51489b73c7cdfbf | |
parent | Slight rewording of output messages. (diff) | |
download | opensim-SC-e4e754ee93de0e0b6fde3b3ccd20085d3d4a09a1.zip opensim-SC-e4e754ee93de0e0b6fde3b3ccd20085d3d4a09a1.tar.gz opensim-SC-e4e754ee93de0e0b6fde3b3ccd20085d3d4a09a1.tar.bz2 opensim-SC-e4e754ee93de0e0b6fde3b3ccd20085d3d4a09a1.tar.xz |
MapImageService: added an additional security check for OSGrid and other grids like it.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | 48 | ||||
-rw-r--r-- | bin/Robust.HG.ini.example | 4 | ||||
-rw-r--r-- | bin/Robust.ini.example | 4 |
3 files changed, 51 insertions, 5 deletions
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index 75dd711..c87de92 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |||
@@ -33,17 +33,24 @@ using System.Xml; | |||
33 | 33 | ||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenMetaverse; | ||
36 | 37 | ||
38 | using OpenSim.Framework; | ||
37 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
38 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
39 | using OpenSim.Framework.Servers.HttpServer; | 41 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Server.Handlers.Base; | 42 | using OpenSim.Server.Handlers.Base; |
41 | 43 | ||
44 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | |||
42 | namespace OpenSim.Server.Handlers.MapImage | 46 | namespace OpenSim.Server.Handlers.MapImage |
43 | { | 47 | { |
44 | public class MapAddServiceConnector : ServiceConnector | 48 | public class MapAddServiceConnector : ServiceConnector |
45 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
46 | private IMapImageService m_MapService; | 52 | private IMapImageService m_MapService; |
53 | private IGridService m_GridService; | ||
47 | private string m_ConfigName = "MapImageService"; | 54 | private string m_ConfigName = "MapImageService"; |
48 | 55 | ||
49 | public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) : | 56 | public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) : |
@@ -53,16 +60,26 @@ namespace OpenSim.Server.Handlers.MapImage | |||
53 | if (serverConfig == null) | 60 | if (serverConfig == null) |
54 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | 61 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); |
55 | 62 | ||
56 | string gridService = serverConfig.GetString("LocalServiceModule", | 63 | string mapService = serverConfig.GetString("LocalServiceModule", |
57 | String.Empty); | 64 | String.Empty); |
58 | 65 | ||
59 | if (gridService == String.Empty) | 66 | if (mapService == String.Empty) |
60 | throw new Exception("No LocalServiceModule in config file"); | 67 | throw new Exception("No LocalServiceModule in config file"); |
61 | 68 | ||
62 | Object[] args = new Object[] { config }; | 69 | Object[] args = new Object[] { config }; |
63 | m_MapService = ServerUtils.LoadPlugin<IMapImageService>(gridService, args); | 70 | m_MapService = ServerUtils.LoadPlugin<IMapImageService>(mapService, args); |
71 | |||
72 | string gridService = serverConfig.GetString("GridService", String.Empty); | ||
73 | if (gridService != string.Empty) | ||
74 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | ||
75 | |||
76 | if (m_GridService != null) | ||
77 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is ON"); | ||
78 | else | ||
79 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); | ||
80 | |||
81 | server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService)); | ||
64 | 82 | ||
65 | server.AddStreamHandler(new MapServerPostHandler(m_MapService)); | ||
66 | } | 83 | } |
67 | } | 84 | } |
68 | 85 | ||
@@ -70,11 +87,13 @@ namespace OpenSim.Server.Handlers.MapImage | |||
70 | { | 87 | { |
71 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 88 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
72 | private IMapImageService m_MapService; | 89 | private IMapImageService m_MapService; |
90 | private IGridService m_GridService; | ||
73 | 91 | ||
74 | public MapServerPostHandler(IMapImageService service) : | 92 | public MapServerPostHandler(IMapImageService service, IGridService grid) : |
75 | base("POST", "/map") | 93 | base("POST", "/map") |
76 | { | 94 | { |
77 | m_MapService = service; | 95 | m_MapService = service; |
96 | m_GridService = grid; | ||
78 | } | 97 | } |
79 | 98 | ||
80 | public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 99 | public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
@@ -105,6 +124,25 @@ namespace OpenSim.Server.Handlers.MapImage | |||
105 | // if (request.ContainsKey("TYPE")) | 124 | // if (request.ContainsKey("TYPE")) |
106 | // type = request["TYPE"].ToString(); | 125 | // type = request["TYPE"].ToString(); |
107 | 126 | ||
127 | if (m_GridService != null) | ||
128 | { | ||
129 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); | ||
130 | if (r != null) | ||
131 | { | ||
132 | if (r.ExternalEndPoint.Address != httpRequest.RemoteIPEndPoint.Address) | ||
133 | { | ||
134 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue", httpRequest.RemoteIPEndPoint.Address); | ||
135 | return FailureResult("IP address of caller does not match IP address of registered region"); | ||
136 | } | ||
137 | |||
138 | } | ||
139 | else | ||
140 | { | ||
141 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue", httpRequest.RemoteIPEndPoint.Address); | ||
142 | return FailureResult("Region not found at given coordinates"); | ||
143 | } | ||
144 | } | ||
145 | |||
108 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); | 146 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); |
109 | 147 | ||
110 | string reason = string.Empty; | 148 | string reason = string.Empty; |
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 4ea5ffd..1b5d37c 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example | |||
@@ -279,6 +279,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
279 | LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService" | 279 | LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService" |
280 | ; Set this if you want to change the default | 280 | ; Set this if you want to change the default |
281 | ; TilesStoragePath = "maptiles" | 281 | ; TilesStoragePath = "maptiles" |
282 | ; | ||
283 | ; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002), | ||
284 | ; you may want to set this. Otherwise, don't set it, because it's already protected. | ||
285 | ; GridService = "OpenSim.Services.GridService.dll:GridService" | ||
282 | 286 | ||
283 | [GridInfoService] | 287 | [GridInfoService] |
284 | ; These settings are used to return information on a get_grid_info call. | 288 | ; These settings are used to return information on a get_grid_info call. |
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 69e94a5..40b8d83 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example | |||
@@ -254,6 +254,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
254 | LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService" | 254 | LocalServiceModule = "OpenSim.Services.MapImageService.dll:MapImageService" |
255 | ; Set this if you want to change the default | 255 | ; Set this if you want to change the default |
256 | ; TilesStoragePath = "maptiles" | 256 | ; TilesStoragePath = "maptiles" |
257 | ; | ||
258 | ; If for some reason you have the AddMapTile service outside the firewall (e.g. 8002), | ||
259 | ; you may want to set this. Otherwise, don't set it, because it's already protected. | ||
260 | ; GridService = "OpenSim.Services.GridService.dll:GridService" | ||
257 | 261 | ||
258 | 262 | ||
259 | [GridInfoService] | 263 | [GridInfoService] |