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 /OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |
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 'OpenSim/Server/Handlers/Map/MapAddServerConnector.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | 48 |
1 files changed, 43 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; |